This commit is contained in:
kdang
2025-12-16 09:23:39 -05:00
parent 93becc1a2b
commit 51765051b1
6 changed files with 134 additions and 28 deletions

42
game.py
View File

@@ -1,32 +1,20 @@
from random import randint
from retro.game import Game
from retro.graph import Graph
from catcher import Catcher
from fruit import Fruit
class Agent:
RIGHT = (1, 0)
UP = (0, -1)
LEFT = (-1, 0)
DOWN = (0, 1)
character = ">"
direction = RIGHT
position = (15, 0)
name = "agent"
color = "white_on_black"
display = True
g = Graph()
g.get_or_create_edge(26, 10, 26, 22)
agents = g.get_agents()
for agent in agents:
agent.color = "white_on_indigo"
def handle_keystroke(self, keystroke, game):
x, y = self.position
if keystroke.name == "M":
self.direction = self.RIGHT
self.character = '>'
elif keystroke.name == "I":
self.direction = self.LEFT
self.character = '<'
agents = [
Catcher((14, 24)),
Fruit((14, 2)),
]
def can_move(self, position, game):
on_board = game.on_board(position)
empty = game.is_empty(position)
if __name__ == '__main__':
player = Agent()
game = Game([player], {'score': 0}, board_size:=(24, 20), framerate:=12)
game.play()
state = {'Score': 0}
game = Game(agents, state, board_size=(35, 25), framerate=24, color="white_on_indigo")
game.play()