#!/usr/bin/env python3 import time from strategy import State, moves_to_keys from interaction import get_exapunks_window, focus_window, \ screenshot_board, press_keys if __name__ == '__main__': win = get_exapunks_window() focus_window(win) prev_score = None while True: board = screenshot_board(win) try: state = State.detect(board) except (TypeError, AssertionError): print('error during parsing, wait for a bit') time.sleep(.1) continue print('\033c', end='') print('parsed:') state.print() print() moves = state.solve() if moves: print('moves:', moves_to_keys(moves)) points, newstate = state.simulate(moves) score = newstate.score(points, moves, state) print(' score:', score) print('prev score:', prev_score) empty_points, empty_state = state.simulate(()) print(' () score:', empty_state.score(empty_points, (), state)) print() prev_score = score print('target after moves:') newstate.print() print() press_keys(win, moves_to_keys(moves)) else: print('no moves') press_keys(win, 'l') time.sleep(.1)