-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_win_at_chess.py
165 lines (135 loc) · 15.3 KB
/
test_win_at_chess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"""
Verifying engine strength with moves from the book "Win At Chess"
Make xboard run the WAC test set:
xboard -epd -mg 300 -lpf win_at_chess.epd -lpi -1 -fcp ./jangine.sh
That somehow gives me a result of 1 right and 299 wrong, even though
the moves it outputs in the log file are the correct ones. Sigh.
So I use this script instead.
"""
import subprocess
import functools
# Run unbuffered so printed single characters will show up immediately
print = functools.partial(print, flush=True)
ENGINE = "./jangine"
DEBUG = 0
p = subprocess.Popen([ENGINE], stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1, text=True)
lines = [line for line in open("win_at_chess.epd").read().split("\n") if line]
solved = [False] * len(lines)
for time in [10 * 2**i for i in range(20)]:
score = 0
print(f"{time:6d} ", end="")
p = subprocess.Popen([ENGINE], stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1, text=True)
for i, line in enumerate(lines):
if solved[i]:
score += 1
print(" ", end="")
continue
line = line.split(";")[0]
try:
pos, sols = line.split(" bm ") # bm best move, am avoid move
except:
pos, sols = line.split(" am ")
sols = sols.split(" ")
if DEBUG:
print(f"Running test {i} pos={pos} sols={sols} am={'am' in line}")
print(f"setboard {pos}")
p.stdin.write(f"setboard {pos}\n")
p.stdin.write(f"time {time}\n")
p.stdin.write("white\n" if " w " in line else "black\n") # really need to fix next-move handling
p.stdin.write("go\n")
reply = ""
while not reply.startswith("bestmove "):
reply = p.stdout.readline()
if DEBUG:
print(reply, end="")
reply = reply.split("bestmove ")[1].strip()
if "bm" in line and reply in sols:
score += 1
print("+", end="")
solved[i] = True
elif "am" in line and reply not in sols:
score += 1
print("+", end="")
solved[i] = True
else:
print(".", end="")
print(f"{score:4d}/{len(lines):4d}")
"""
Git commit tested: 63208852
10 .........+..............+..+..+.+..+++..+...+.+.........+.+..........+.+...+.....+.............+.+.+........+..+..+..............................+....+.....................+....................+..+.+..+............+............+...+.........................................+...+...............+...... 36/ 300
20 +.+++++++++++++++.++++++++++..++++++++++.++++.++.+++++.++++++++++.++.+.+++.+++..++++++.+..+.++++++++++..+++.+++++++.++..+++..+.++.....+++..+.+++.+..+++..+.+++++...+++.+.+.++++.+.+.+..+.+++..++....+++.+++.++........+..+++....+.++...++++......+...+.+....+++...+..+.+..++..+.++.+.++..+...++.+..+.++..+++ 183/ 300
40 +.+++++++++++++++.+++.++++++++++++++++++.+++++++.+++++++++++++++++++.+.+++.++++.++++++.+++..+++++++++++++++++++++++.+++++++++++++.++.+++++++.+++.+.++.+..+.+++++++.+++++++.++++.+.+.+..++++++.++....+++.++++++.++.++..++.+++..+++.++....++++...+.+.+.+.++..++++..++..+++..++..+.++.+.+++++..++++++.+..++.+++ 227/ 300
80 +.+++++++++++++++++++.++++++++++++++++++.+++++++++++++++++++++++++++++.+++.++++.++++++.+++..+++++++++++++++++++++++++++++++++++++.+++++++.++.+++++.++++.++.+++++++.++++++++++++++.+.+++++++++.++.++.++++++++++.+++++.+++++++..++++++....++++...+.+.+++.++.++++++.+++.++..+++.+++++.+++++++..++++++.+.+++.+++ 253/ 300
160 +.++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++.++++.++++++.+++..+++++++.+++++++++++++++++++++++++++++.+++++++.++.+++++++++..++.+.+++++.++++++++++++++.+.++++++++++++.++.++++++++++..++++.+++++++..++++++....++++.+.+.+.+++.+++++++++.++++++..+++.+++++.+++++++++++++++.+.+++.+++ 257/ 300
320 +.++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++.++++.++++++.+++..++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++..++.+.+++++.++++++++++++++.+.++++++++++++.++.++++++++++++++++.+++++++..++++++..++++++.+.+.+.+++.+++++++++++++++++.+++.+++++++++++++++++++++.+.+++.+++ 267/ 300
640 +.++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++.+++++++++++.+++..++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++.++.+.+++++.++++++++++++++.+.++++++++++++.++.++++++++++++++++.+++++++..++++++..++++++.+.+.+.+++.+++++++++++++++++.+++.+++++++++++++++++++++.+.+++.+++ 269/ 300
1280 +.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++.+++++++++++.+++..++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++..++.+.+++++.++++++++++++++.+.++++++++++++.++.++++++++++++++++.+++++++..++++++..++++++.+.+.+.+++.++++++++++++++++..+++.+++++++++++++++++++++.+.+++.+++ 268/ 300
2560 +.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++.+++++++++++.+++..+++++++.++++++++++++++++++++++++++++++++++++++++.++++++++++.++.+++++++.++++++++++++++++.+++++++++++++++.++++++++++++++++.+++++++..++++++..++++++.+++.+.+++.+++++++++++++++++.+++++++++++++++++++++++++.+.+++.+++ 274/ 300
5120 +.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++.+++++++++++.+++..+++++++.++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++.++++++++++++++++.+++++++++++++++.++++++++++++++++.+++++++..++++++..++++++.+++.+.+++++++++++++++++++++.+++++++++++++++++++++++++.+++++.+++ 277/ 300
10240 +.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++.+++++++++++.+++..+++++++.++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++.++++++++++++++++.+++++++++++++++.++++++++++++++++.+++++++..++++++..++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++.+++++.+++ 280/ 300
20480 +.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++.+++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++.++++++++++++++++.++++++++++++++++++++++++++++++++.+++++++..+++++++.++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++.+++++++++ 287/ 300
40960 +.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++.+++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++.+++++++..+++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 290/ 300
10 .........+..............+..+..+.+..+++..+...+.+.........+.+..........+.+...+.....+.............+.+.+........+..+..+..............................+....+.....................+....................+..+.+..+............+............+...+.........................................+...+...............+...... 36/ 300
20 +.+++++++ +++++++.++.+.+ ++ .. + ++ ++ +++ . +.+++++.+ . ++++++.++. . +++ ++..+ ++++....+.+++ + + ++..+.+. ++ ++ .++..+++..+.++.....+++..+.+++. ..++ ..+.+++++...+++.+.+.+ ++.+.+.+..+.+++..++. .. + .+ +.++........ ..+++....+.+ ... +++......+...+.+....+++...+..+.+..++..+.+ .+. +..+...++.+..+. +..+++ 181/ 300
40 . . + + +. . . . . . . . +. .+++ . ++ + + . .. .+ . ..... +. . . .. .. . ++. . . . . . . .. . .. . .. . . .++.+... .. .... . ... ....+. .+. . .... ... .. . .. .. . . . .. ... . .. . .. 201/ 300
80 . . + . . . + + . . . . . . +. + + ..+.+ + . . .+ .. . . . . . . . . .. + +. . .. . . . . ... .. .... . ... +... . . . . ...+ ..+ .. + .. .. . . . ++ ... . +. . +. 221/ 300
160 . + + . + . . . . . . + .+ . . . . .+ . . + + . . . . .. . . .. . + . . +.. +. ..++ . ... ... . . . . +.. .. +. .. .+ . . . ..+ + . . . 239/ 300
320 . + . . . . . . . + . . + . . . + . . . ++ . . +. + . . .+ + .. . ... ... . . . . .. .. . .. . . . + .. . . . 250/ 300
640 . + . . . . + + . . . . . . . . + . . + + . .. + ... ... . . + . .+ +. . .+ . + + .+ . . . 264/ 300
1280 . . . . . . . . . . + . . . . . .. ..+ .+. . . . + + . . . + . . . 270/ 300
2560 . . + . . . + . . . + . + . . .. .. . + . . . + . + . . . 277/ 300
5120 . . . . . . + . . . . .. .. . . . + . . + . 280/ 300
10240 . . . . . . . . . . .. .. + + . + . . 283/ 300
20480 . + . . + . . . + . .. +. . . + 288/ 300
40960 . + . . . + . .. . + + 292/ 300
81920 + + . . . .+ . 295/ 300
163840 . . . . . 295/ 300
327680 . + . . . 296/ 300
655360 . . . . 296/ 300
1310720 . . . . 296/ 300
2621440 . + . . 297/ 300
5242880 . . . 297/ 300
setboard 3r1r1k/1b4pp/ppn1p3/4Pp1R/Pn5P/3P4/4QP2/1qB1NKR1 w - - 0 1
INPUT: setboard 3r1r1k/1b4pp/ppn1p3/4Pp1R/Pn5P/3P4/4QP2/1qB1NKR1 w - - 0 1
time 9999999
INPUT: time 9999999
go
INPUT: go
Setting piece-square tables to middlegame
Starting iterative deepening alphabeta search at ZOB 286137647667421848 eval -515
MOVE B e3 (c1e3 ) | EVAL -5.20 | D 1 | NN 38 | NQ 497 | t 0.001 | VAR ...
MOVE B e3 (c1e3 ) | EVAL -5.20 | D 2 | NN 231 | NQ 1461 | t 0.002 | VAR ... Nxe5 (c6e5 )
MOVE B e3 (c1e3 ) | EVAL -5.20 | D 3 | NN 1585 | NQ 3658 | t 0.004 | VAR ... Nxe5 (c6e5 ) Bxb6 (e3b6 )
MOVE B e3 (c1e3 ) | EVAL -5.25 | D 4 | NN 7844 | NQ 15283 | t 0.018 | VAR ... Nxd3 (b4d3 ) Bxb6 (e3b6 ) N d4 (c6d4 )
MOVE Q b2 (e2b2 ) | EVAL -5.80 | D 5 | NN 56684 | NQ 87018 | t 0.068 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 )
MOVE Q b2 (e2b2 ) | EVAL -5.80 | D 6 | NN 174388 | NQ 231692 | t 0.178 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 ) Rxd3 (d8d3 )
MOVE Q b2 (e2b2 ) | EVAL -5.70 | D 7 | NN 696176 | NQ 705086 | t 0.505 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 ) Rxd3 (d8d3 ) K e1 (f1e1 )
MOVE Q b2 (e2b2 ) | EVAL -5.75 | D 8 | NN 3376206 | NQ 3211146 | t 2.104 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 ) Rxd3 (d8d3 ) R g5 (h5g5 ) R g8 (f8g8 )
MOVE Q b2 (e2b2 ) | EVAL -5.75 | D 9 | NN 12723783 | NQ 12025997 | t 7.559 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 ) Rxd3 (d8d3 ) [HASH COLLISION]
MOVE Q b2 (e2b2 ) | EVAL -5.75 | D10 | NN 59854998 | NQ 59809903 | t 35.710 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 ) Rxd3 (d8d3 ) [HASH COLLISION]
MOVE Q b2 (e2b2 ) | EVAL -6.00 | D11 | NN347005363 | NQ335783892 | t195.725 | VAR ... Qxb2 (b1b2 ) Bxb2 (c1b2 ) Nxd3 (b4d3 ) Nxd3 (e1d3 ) Rxd3 (d8d3 ) [HASH COLLISION]
MOVE Rxh7 (h5h7 ) | EVAL -5.40 | D12 | NN1628409081 | NQ1531583989 | t897.291 | VAR ... Kxh7 (h8h7 ) Q h5 (e2h5 ) K g8 (h7g8 ) Rxg7 (g1g7 ) Kxg7 (g8g7 ) B h6 (c1h6 ) [HASH COLLISION]
MOVE Rxh7 (h5h7 ) | EVAL -4.80 | D13 | NN4847500612 | NQ4536094667 | t2649.679 | VAR ... Kxh7 (h8h7 ) Q h5 (e2h5 ) K g8 (h7g8 ) Rxg7 (g1g7 ) Kxg7 (g8g7 ) B h6 (c1h6 ) [HASH COLLISION]
Used up time budget of 499999cs allocated to finding this move
|End|ing iterative deepening alphabeta search at ZOB 286137647667421848 eval -515
8 . . . ♜ . ♜ . ♚
7 . ♝ . . . . ♟ ♖
6 ♟ ♟ ♞ . ♟ . . .
5 . . . . ♙ ♟ . .
4 ♙ ♞ . . . . . ♙
3 . . . ♙ . . . .
2 . . . . ♕ ♙ . .
1 . ♛ ♗ . ♘ ♔ ♖ .
a b c d e f g h
move h5h7
-8
2
92
100 DDD
152 ***
163
213 ***
221 *** does not solve in isolation
222
230 ***
"""