Babysnake training works

This commit is contained in:
Chris Proctor
2026-06-25 13:00:03 -04:00
parent aeb610d04b
commit 048cb1c02b
7 changed files with 105 additions and 171 deletions

View File

@@ -9,6 +9,14 @@ The game ends when energy reaches 0.
from random import randint, choice
from retro.game import Game
ACTIONS = ["KEY_RIGHT", "KEY_DOWN", "KEY_LEFT", "KEY_UP"]
def get_state(game):
"""Return the game state as a hashable (agent_x, agent_y, food_x, food_y) tuple."""
s = game.state
return (int(s['agent_x']), int(s['agent_y']), int(s['food_x']), int(s['food_y']))
BOARD_SIZE = 4
START_ENERGY = 50
FOOD_ENERGY = 30