More notes on the possible min/max method.
[pachi/pachi-r6144.git] / t-play / autotest / autotest-gather
blobfde7a0e9c45923623b5d3ab0ae6bc7ffed60ca56
1 #!/bin/sh
2 # This is autotest gathering tool, collecting game result info from
3 # all clients and putting it in single place (which is completely
4 # wiped otherwise).
6 . ./autotest-lib
8 mkdir -p "r/"
9 rm -f r/*
11 # First, gather pairing data:
13 for dir in c/*/*/; do
14 pairing="${dir%/}"; pairing="${pairing#c/*/}"
15 datfile="r/$pairing.dat"
17 if [ ! -s "$datfile" ]; then
18 # Common datfile header, required for twogtp -analyze
20 echo "#"
21 echo -e "#GAME\tRES_B\tRES_W\tRES_R\tALT\tDUP\tLEN\tTIME_B\tTIME_W\tCPU_B\tCPU_W\tERR\tERR_MSG"
22 } >"$datfile"
23 num=0
24 else
25 lastgame="$(tail -n 1 "$datfile")"
26 num="$((${lastgame%% *} + 1))"
28 # We cannot simply concatenate all the datfiles because
29 # twogtp -analyze is pedantic about the games numbering;
30 # we need to renumber the games to a single sequence.
31 while read orignum line; do
32 echo -e "$num\t$line"
33 num=$((num+1))
34 done <"$dir/game.dat" >>"$datfile"
35 done
38 # Next, fill per-pairing metadata:
40 for datfile in r/*.dat; do
41 pairing="${datfile%.dat}"; pairing="${pairing#r/}"
43 # Look at last change in pairing:
44 stat -c %Z "$(ls --sort=time c/*/"$pairing"/* | head -n 1)" >"r/$pairing.beacon"
46 # Check pairing for errors:
47 tail -n +3 "$datfile" | cut -f 12 | { grep -c -vF 0 >"r/$pairing.error" || :; }
48 done