More notes on the possible min/max method.
[pachi/pachi-r6144.git] / t-play / autotest / autotest-show
blobcde680b345ba556122d9bb4ce257ff543bfbec5b
1 #!/bin/sh
2 # This is autotest display tool, showing gathered information in
3 # a hopefully meaningful way.
5 mask="$1"
6 [ -n "$mask" ] || mask="*"
7 . ./autotest-lib
9 if [ ! -d "r" ]; then
10 echo "Did you run autotest-gather?" >&2
11 exit 1
14 # Load rc quickly:
15 player() { :; }
16 pknown=" "
17 pairing() { pknown="$pknown$(pairid "$@") "; }
18 . ./rc
20 color_stale="\033[33m"
21 color_bad="\033[31m"
22 color_fresh="\033[1m"
23 color_stop="\033[0m"
25 pairing_status() {
26 # See README for explanation of flags.
27 error=0;
28 if [ -s "r/$pairing.error" ] && [ "$(cat "r/$pairing.error")" -gt 0 ]; then
29 error=1;
31 known=1; [ "${pknown#* $pairing *}" != "$pknown" ] || known=0
32 active=1; ([ -s "r/$pairing.beacon" ] && [ "$(cat "r/$pairing.beacon")" -ge "$(($(date +%s) - 60*60*2))" ]) || active=0
33 case $error$known$active in
34 001) status="${color_stale}?";;
35 000) status="${color_stale}/";;
36 011) status="${color_fresh}.";;
37 010) status="${color_fresh}${color_bad}!";;
38 1*0) status="${color_bad}x";;
39 1*1) status="${color_fresh}${color_bad}X";;
40 esac
43 rm -f r/*.summary.dat r/*.html
45 echo -e "S GAMES\tWINRATE\tS.D.\tPAIRING"
46 for pairing in $((echo "$pknown" | tr ' ' '\n'; ls r/*.dat | sed 's#^r/##; s#\.dat$##') | sort | uniq); do
47 [ ! -s "r/$pairing.dat" ] || $twogtp_path -analyze "r/$pairing.dat"
48 pairing_status "$pairing" # sets status
49 if [ -s "r/$pairing.summary.dat" ]; then
50 echo -e "$status $(cat "r/${pairing}".summary.dat | cut -f 1,7,8 | tail -n +2)\t$pairing$color_stop"
51 else
52 echo -e "$status 0\t-\t-\t$pairing$color_stop"
54 done