def main(): path = os.path.join(utils.get_data_dir(), 'qualifier/problem_4.json') with open(path) as fin: data = json.load(fin) m = re.match('.*/problem_(\\d+)\\.json', path) assert m data['problemId'] = int(m.group(1)) game = Game(data, data['sourceSeeds'][0]) ui = Gui(game, buttons=Gui.DEFAULT_BUTTONS_INTERACTIVE) while True: cmd = ui.wait_for_action() log.debug('{!r}'.format(cmd)) if cmd is None: log.debug('done') break game.execute_char(CHARS_BY_COMMAND[cmd][0]) ui.update(game)
c, b = it c = c.lower() cc = ord(c) - ord("n") # print(cc, b) print(c, cc % 6, COMMAND_BY_CHAR[c], b) print_seq() print() json = { "width": 20, "height": 20, "filled": [], "sourceLength": 1, "units": [{"pivot": {"x": 0, "y": 1}, "members": [{"x": 0, "y": 0}]}], } marks = [] g = Game(json, 0) ui = Gui(g) for it in s.split(): c, b = it print(it, COMMAND_BY_CHAR[c.lower()]) if b == "1": marks.append(next(iter(g.get_current_figure_cells()))) ui.update(g, marks) action = ui.wait_for_action() if action is None: break g.execute_char(c)