from random import randint from obstacle import Obstacle class ObstacleSpawner: display = False def play_turn(self, game): width, height = game.board_size game.state['score'] += 1 if self.should_spawn_obstacle(game.turn_number): obstacle = Obstacle((randint(0, width - 1), 0)) game.add_agent(obstacle) def should_spawn_obstacle(self, turn_number): return randint(0, 1000) < turn_number