Skip to content

Commit b68bfb3

Browse files
committed
Better debugging
1 parent c1fba18 commit b68bfb3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,18 @@ def play(version1_version2_secs_plus_fen):
176176
if m is not None:
177177
pos = pos.move(m)
178178
# Test repetition draws
179+
# This is by far the most common type of draw
179180
if pos in seen:
180181
return None
181182
seen.add(pos)
182183
else:
183184
if score == 0:
185+
# This is actually a bit interesting. Why would we ever throw away a win like this?
186+
print('Stalemate?', tools.renderFEN(pos))
184187
return None
185-
assert score <= -sunfish.MATE_LOWER, "We lost?"
188+
assert score <= -sunfish.MATE_LOWER, "move is None, but we didn't lose?"
186189
return version1 if d%2 == 1 else version2
190+
print('Game too long', tools.renderFEN(pos))
187191
return None
188192

189193

@@ -207,12 +211,12 @@ def test_xboard(python='python3', verbose=True):
207211
if verbose:
208212
print('Xboard test \'%s\'' % python)
209213
fish = subprocess.Popen(
210-
[python, '-u', 'tools.py'],
214+
[python, '-u', 'xboard.py'],
211215
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
212216
universal_newlines=True)
213217

214218
def wait_for(regex):
215-
with timeout(20, '%s was never encountered'%regex):
219+
with timeout(20, '{} was never encountered'.format(regex)):
216220
while True:
217221
line = fish.stdout.readline()
218222
if verbose:
@@ -262,9 +266,9 @@ def allperft(f, depth=4, verbose=True):
262266
print('ERROR at depth %d. Gave %d rather than %d' % (d, res, score))
263267
print('=========================================')
264268
print(tools.renderFEN(pos,0))
265-
sunfish.print_pos(pos)
266-
#print(' '.join(renderSAN(pos, 0, mov) for mov in pos.gen_moves()))
267-
print(' '.join(sunfish.render(m[0])+sunfish.render(m[1]) for m in pos.gen_moves()))
269+
for move in pos.gen_moves():
270+
split = sum(1 for _ in tools.collect_tree_depth(tools.expand_position(pos.move(move)),1))
271+
print('{}: {}'.format(tools.mrender(pos, move), split))
268272
return False
269273
if verbose:
270274
print('')

0 commit comments

Comments
 (0)