asteroid.py asteroid_spawner.py spaceship.py nav_game.py

This commit is contained in:
njmason2
2025-11-14 00:29:44 -05:00
parent 5356f5076b
commit 24476f3bed
8 changed files with 79 additions and 0 deletions

View File

@@ -2,3 +2,19 @@
# -------------------
# 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