Merge pull request #50 from lemonsqueeze/can_countercap
[pachi.git] / tools / autobook / eval.sh
blob027ccd53fa5827d2d10fabca4a83c244960082e5
1 #!/bin/sh
3 # Choose next move to choose in the current directory (node)
5 # Config:
6 # Exploration coefficient
7 explore_p=0.8
9 best_move=
10 best_val=-9999
12 { read mwins; read msims; } <stats
14 for move in $(find . -maxdepth 1 -type d | tail -n +2); do
15 { read wins; read sims; } <"$move"/stats
16 val="$(echo "($wins/$sims+$explore_p*sqrt(l($msims)/$sims))*1000" | bc -l)"
17 val="${val%.*}"
18 if [ "$val" -gt "$best_val" ]; then
19 best_val="$val"
20 best_move="$move"
22 done
24 echo ${best_move#./}