if new_obstacle is not None: obstacles.append(new_obstacle) screen_object.screen.fill(LIGHT_BLUE) ground.animate() for obst in obstacles: obst.animate() if IS_PLAYER_CONTROLLED: dino.animate() if not IS_PLAYER_CONTROLLED: for dino in dino_population: if screen_object.assess_death(dino, obstacles): dino_population.remove(dino) dead_dinos.append(dino) # the inputs to the bots yvel = dino.yvel / dino.VELOCITY_LIMIT next_obstacle = screen_object.get_next_obstacle(dino, obstacles) next_obstacle_dist = (next_obstacle.xpos - dino.xpos + dino.sprite_width) / SCREEN_X if next_obstacle is not None else 1 next_obstacle_ypos = next_obstacle.ypos / GROUND_BASELINE if next_obstacle is not None else 1 dino.input_data(np.array([yvel, next_obstacle_dist, next_obstacle_ypos])) dino.animate() if len(dino_population) == 0: generation_counter += 1 dino_population = get_next_generation(dead_dinos, 0.1, screen_object) dead_dinos.clear() obstacles.clear()