Compare commits

...

3 Commits

Author SHA1 Message Date
ilmabura
f0840a02fc Resubmit commit 1
Re-wrote the player and board game because i kept getting stuck on creating the walls. There was an agent error so i needed to start from the begining again. I looked up resources online and used the tic tac toe and retro labs for help.
2025-12-07 11:20:03 -05:00
ilmabura
cdafa795fc Checkpoint 1: Create player
I created an agent the shape of a penguin. I used the retro lab to help guide its movement and how to run the program.
The penguin moves left, right, up, and down. I noticed that when I move it over to the far right, the wall disappears. I think that's something I need to work on while figuring out collision detection.
However, my penguin does not move beyond the board.
2025-11-29 15:19:54 -05:00
ilmabura
bce3c8508c Proposal.md
Created a game proposal. I will be creating a simple maze game. I think i will struggle with coming up with a maze layout
2025-11-29 14:44:42 -05:00
7 changed files with 102 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

25
escape_the_maze.py Normal file
View File

@@ -0,0 +1,25 @@
from retro.game import Game
from player import Player
def main():
board_size = (100, 40)
player = Player(board_size)
state = {
"win": False,
}
game = Game(
agents=[player],
state=state,
board_size=board_size,
debug=False,
framerate=24,
color="white_on_black",
)
game.play()
if __name__ == "__main__":
main()

8
game_signature.py Normal file
View File

@@ -0,0 +1,8 @@
from retro.game import Game
import inspect
print("Game.__init__ signature:")
print(inspect.signature(Game.__init__))
print("\nFull source of Game.__init__:\n")
print(inspect.getsource(Game.__init__))

38
player.py Normal file
View File

@@ -0,0 +1,38 @@
class Player:
"""
Player agent for Escape the Maze.
Moves one step at a time using the arrow keys.
"""
name = "player"
character = "🐧" # Penguin icon
def __init__(self, board_size):
# Start near the top-left corner
width, height = board_size
self.position = (1, 1)
def handle_keystroke(self, keystroke, game):
"""
Called once for each key pressed since the last turn.
Moves the player using the arrow keys.
"""
x, y = self.position
new_position = None
if keystroke.name == "KEY_UP":
new_position = (x, y - 1)
elif keystroke.name == "KEY_DOWN":
new_position = (x, y + 1)
elif keystroke.name == "KEY_LEFT":
new_position = (x - 1, y)
elif keystroke.name == "KEY_RIGHT":
new_position = (x + 1, y)
if new_position is None:
return
if game.on_board(new_position) and game.is_empty(new_position):
self.position = new_position

31
proposal.md Normal file
View File

@@ -0,0 +1,31 @@
# Game Proposal
## Game Overview
Title: Escape the Maze
Vision: A puzzle style game where the player must complete a maze. I think it's compelling because it combines problem solving and interactive play.
Layout: A grid based maze with a player and exit.
Objective: Player uses arrow keys to navigate and end the game by reaching the exit.
## Core Mechanics
- Player movement: Move one step at a time using arrow keys.
- Collision detection: Prevents player from walking through walls.
- Win condition: End the game when the player reaches the exit.
## Milestone
1. Player agent moves correctly.
2. Walls block movement.
3. Exit agent ends the game when reached.
6. (Optional) Add scoring, timer, or multiple levels.
## Challenges
- Designing the maze
- Implementing collision detection
- Adding optional features