Files
lab_retro/asteroid_spawner.py
tsmith37 2bfaa54f1d finished the game
The program in unit 1, the turtle would draw whatever you made when it starts, but for the
nav_game the objects are already made, and you can move things around after it starts
2025-12-01 16:15:27 -05:00

20 lines
577 B
Python

# asteroid_spawner.py
# -------------------
# By MWC Contributors
# This module defines an AsteroidSpawner agent class.
from random import randint
from asteroid import Asteroid
class AsteroidSpawner:
display = False
def play_turn(self, game):
width, height = game.board_size
game.state['score'] += 1
if self.should_spawn_asteroid(game.turn_number):
asteroid = Asteroid((randint(0, width - 1), 0))
game.add_agent(asteroid)
def should_spawn_asteroid(self, turn_number):
return randint(0, 1000) < turn_number