def visualise(): memory = load_game(playForFree=True) pygame.init() size = (50 * CELLSIZE), (50 * CELLSIZE) screen = pygame.display.set_mode(size) runner = DisplayGame(pygame, screen) com = Computer(memory) com.run_program(runner.capture) next_move_event = pygame.USEREVENT + 1 pygame.time.set_timer(next_move_event, 100) while (True): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() elif event.type == next_move_event: if runner.paddle < runner.ball: com.input_and_continue(1) elif runner.paddle > runner.ball: com.input_and_continue(-1) else: com.input_and_continue(0)
def play_game(): memory = load_game(playForFree=True) pygame.init() size = (50 * CELLSIZE), (50 * CELLSIZE) screen = pygame.display.set_mode(size) runner = DisplayGame(pygame, screen) com = Computer(memory) com.run_program(runner.capture) while (True): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: com.input_and_continue(-1) if event.key == pygame.K_UP: com.input_and_continue(0) if event.key == pygame.K_RIGHT: com.input_and_continue(1)