]> git.sesse.net Git - stockfish/blob - tests/reprosearch.sh
gcc 7 port
[stockfish] / tests / reprosearch.sh
1 #!/bin/bash
2 # verify reproducible search
3
4 error()
5 {
6   echo "reprosearch testing failed on line $1"
7   exit 1
8 }
9 trap 'error ${LINENO}' ERR
10
11 echo "reprosearch testing started"
12
13 # repeat two short games, separated by ucinewgame. 
14 # with go nodes $nodes they should result in exactly
15 # the same node count for each iteration.
16 cat << EOF > repeat.exp
17  set timeout 10
18  spawn ./stockfish
19  lassign \$argv nodes
20
21  send "uci\n"
22  expect "uciok"
23
24  send "ucinewgame\n"
25  send "position startpos\n"
26  send "go nodes \$nodes\n"
27  expect "bestmove"
28
29  send "position startpos moves e2e4 e7e6\n"
30  send "go nodes \$nodes\n"
31  expect "bestmove"
32
33  send "ucinewgame\n"
34  send "position startpos\n"
35  send "go nodes \$nodes\n"
36  expect "bestmove"
37
38  send "position startpos moves e2e4 e7e6\n"
39  send "go nodes \$nodes\n"
40  expect "bestmove"
41
42  send "quit\n"
43  expect eof
44 EOF
45
46 # to increase the likelyhood of finding a non-reproducible case,
47 # the allowed number of nodes are varied systematically
48 for i in `seq 1 20`
49 do
50
51   nodes=$((100*3**i/2**i))
52   echo "reprosearch testing with $nodes nodes"
53
54   # each line should appear exactly an even number of times
55   expect repeat.exp $nodes 2>&1 | grep -o "nodes [0-9]*" | sort | uniq -c | awk '{if ($1%2!=0) exit(1)}'
56
57 done
58
59 rm repeat.exp
60
61 echo "reprosearch testing OK"