diff --git a/__pycache__/cursor.cpython-312.pyc b/__pycache__/cursor.cpython-312.pyc index 7e3f3c7..d0d3dc8 100644 Binary files a/__pycache__/cursor.cpython-312.pyc and b/__pycache__/cursor.cpython-312.pyc differ diff --git a/__pycache__/mine.cpython-312.pyc b/__pycache__/mine.cpython-312.pyc new file mode 100644 index 0000000..dd3da80 Binary files /dev/null and b/__pycache__/mine.cpython-312.pyc differ diff --git a/__pycache__/mine_spawner.cpython-312.pyc b/__pycache__/mine_spawner.cpython-312.pyc new file mode 100644 index 0000000..12e8251 Binary files /dev/null and b/__pycache__/mine_spawner.cpython-312.pyc differ diff --git a/cursor.py b/cursor.py index f8c48da..c4b5765 100644 --- a/cursor.py +++ b/cursor.py @@ -1,9 +1,9 @@ # cursor.py # ------------ -# By MWC Contributors -# This module defines a spaceship agent class. +# By Cory +# This module defines a cursor agent class. class Cursor: - name = "cursos" + name = "cursor" character = 'O' def __init__(self, board_size): @@ -24,5 +24,4 @@ class Cursor: if game.on_board(new_position): if game.is_empty(new_position): self.position = new_position - else: - game.end() \ No newline at end of file + game.log(self.position) \ No newline at end of file diff --git a/mine.py b/mine.py new file mode 100644 index 0000000..4cce7c5 --- /dev/null +++ b/mine.py @@ -0,0 +1,14 @@ +# mine.py +# ------------ +# By Cory +# This module defines a mine agent class. It doesn't do anything except exist in a position +class Mine: + display = False + + def __init__(self, position): + self.position = position + + def play_turn(self, game): + if not game.is_empty(self.position): + game.log("You hit a mine at " + str(self.position) + ".") + game.end() \ No newline at end of file diff --git a/mine_spawner.py b/mine_spawner.py new file mode 100644 index 0000000..ecdceb3 --- /dev/null +++ b/mine_spawner.py @@ -0,0 +1,20 @@ +# mine_spawner.py +# ------------ +# By Cory +# This module defines a mine spawner agent class. It spawns mines! + +from random import randint +from mine import Mine + +class MineSpawner: + display = False + + def __init__(self, board_size): + width, height = board_size + self.board_width, self.board_height = width, height + + def play_turn(self, game): + if game.turn_number == 1: + mine = Mine(((randint(0, self.board_width - 1)),(randint(0, self.board_height - 1)))) + game.log(mine.position) + game.add_agent(mine) \ No newline at end of file diff --git a/minesweeper_game.py b/minesweeper_game.py index 1841ef8..b6f99b4 100644 --- a/minesweeper_game.py +++ b/minesweeper_game.py @@ -4,9 +4,11 @@ # This class implements a simple minesweeper game on a 9x9 gird. from retro.game import Game from cursor import Cursor +from mine_spawner import MineSpawner board_size = (9, 9) cursor = Cursor(board_size) +spawner = MineSpawner(board_size) # spawner = AsteroidSpawner(board_size) -game = Game([cursor], {"score": 0}, board_size=board_size) +game = Game([cursor,spawner], {"score": 0}, board_size=board_size,debug=True) game.play() \ No newline at end of file