|
|
@@ -1,13 +1,29 @@
|
|
|
#!/usr/bin/env python3
|
|
|
+import os
|
|
|
import time
|
|
|
+from itertools import count
|
|
|
from strategy import State, moves_to_keys
|
|
|
from interaction import get_exapunks_window, focus_window, \
|
|
|
- screenshot_board, press_keys
|
|
|
+ screenshot_board, press_keys, listen_keys
|
|
|
+
|
|
|
+
|
|
|
+def save_screenshot(win):
|
|
|
+ board = screenshot_board(win).convert('RGB')
|
|
|
+ os.makedirs('screens', exist_ok=True)
|
|
|
+ for i in count(1):
|
|
|
+ path = 'screens/board%d.png' % i
|
|
|
+ if not os.path.exists(path):
|
|
|
+ print('save screenshot in', path)
|
|
|
+ board.save(path)
|
|
|
+ break
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
win = get_exapunks_window()
|
|
|
focus_window(win)
|
|
|
+
|
|
|
+ listen_keys({'s': lambda: save_screenshot(win)})
|
|
|
+
|
|
|
prev_score = None
|
|
|
|
|
|
while True:
|