def main(): """The application's entry point. If someone executes this module (instead of importing it, for example), this function is called. """ pygame.init() display_surface = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT)) pygame.display.set_caption('Pygame Flappy Bird') clock = pygame.time.Clock() score_font = pygame.font.SysFont(None, 32, bold=True) # default font images = load_images() stop = False agent = FlappyLearner() loops = 0 high = -1 scores = [] while not stop: stop, score = game_logic(clock, display_surface, images, score_font, agent=agent) scores.append(score) loops += 1 if len(scores) > 100: del scores[0] r_mean = sum(scores) / float(len(scores)) high = max(high, score) print 'Score:', score, '-----', 'High:', high, '-----', 'Rolling Mean:', r_mean if loops == 100 or stop: print 'Saving...' loops = 0 agent.save() pygame.quit()