I didnt understand this well, I kind of understood how you did it, but most of it is confusing because I. Did. Not. Learn. ANY. OF. THIS.

This commit is contained in:
jbayati
2025-11-18 09:33:55 -05:00
parent ffe1993926
commit 3a2fdf30f0
7 changed files with 65 additions and 0 deletions

View File

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