if tiles is None: self.screen.addstr(18, 13, f'GAME OVER') self.screen.addstr(19, 13, f'SCORE: {self.score}') key = self.screen.getch() break else: self.render_screen(tiles) def main(screen: Any, bot_player: bool): program = read_program('./inputs/day13.txt') cabinet = ArcadeCabinet(screen, program) cabinet.game_loop(bot_player=bot_player) if __name__ == '__main__': program = read_program('./inputs/day13.txt') computer = IntcodeComputer(program) output = computer.run() print(f"Number of block tiles: {sum([1 for i in range(2, len(output), 3) if output[i] == 2])}") if len(sys.argv) > 1: bot_player = int(sys.argv[1]) == 1 else: bot_player = False curses.wrapper(main, bot_player)
from day05 import IntcodeComputer, read_program if __name__ == "__main__": test_program = [109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99] test_computer = IntcodeComputer(test_program) output = test_computer.run() assert len(output) == len(test_program) assert all(o == p for o, p in zip(output, test_program)) test_program = [109, -1, 4, 1, 99] # -1 test_program = [109, -1, 104, 1, 99] # 1 test_program = [109, -1, 204, 1, 99] # 109 test_program = [109, 1, 9, 2, 204, -6, 99] # 204 test_program = [109, 1, 109, 9, 204, -6, 99] # 204 test_program = [109, 1, 209, -1, 204, -106, 99] # 204 test_computer = IntcodeComputer(test_program) output = test_computer.run() assert output[0] == 204 test_program = [109, 1, 3, 3, 204, 2, 99] # input test_program = [109, 1, 203, 2, 204, 2, 99] # input test_computer = IntcodeComputer(test_program) output = test_computer.run(234) print(test_computer.memory) assert output[0] == 234 test_program = [1102,34915192,34915192,7,4,7,99,0] test_computer = IntcodeComputer(test_program) output = test_computer.run()[0] assert len(str(output)) == 16