Skip to content
Snippets Groups Projects
Commit a296ca9c authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Add detection test suite

parent 05436333
No related branches found
No related tags found
No related merge requests found
__pycache__
*.swp
screens/bitmap*.png
screens/all.png
check.py 0 → 100755
#!/usr/bin/env python3
import glob
import os
from PIL import Image
from strategy import State
def saved_idents():
return sorted(int(path[13:-4]) for path in glob.glob('screens/board*.png'))
if __name__ == '__main__':
ok = fail = notfound = 0
for ident in saved_idents():
truth_path = 'screens/true%d.txt' % ident
if os.path.exists(truth_path):
board = Image.open('screens/board%d.png' % ident).convert('HSV')
state = State.detect(board, pad=0)
detected = state.tostring()
with open(truth_path) as f:
expected = f.read()
if detected != expected:
print('=' * 20)
print('board', ident, 'FAIL')
print('expected:')
print(expected)
print('detected:')
print(detected, end='')
print('=' * 20)
fail += 1
else:
print('board', ident, 'OK')
ok += 1
else:
print(truth_path, 'does not exist')
notfound += 1
print('%d boards, %d ok, %d fail' %(ok + fail, ok, fail))
screens/board1.png

242 KiB

screens/board10.png

284 KiB

screens/board11.png

261 KiB

screens/board12.png

326 KiB

screens/board13.png

322 KiB

screens/board14.png

251 KiB

screens/board15.png

286 KiB

screens/board16.png

208 KiB

screens/board17.png

235 KiB

screens/board18.png

268 KiB

screens/board19.png

294 KiB

screens/board2.png

314 KiB

screens/board20.png

310 KiB

screens/board21.png

200 KiB

screens/board3.png

363 KiB

screens/board4.png

356 KiB

screens/board5.png

312 KiB

screens/board6.png

232 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment