How wajih1234/snake-game-ai works
This is a Snake game agent trained with deep Q-learning. The training loop observes the game, selects and applies actions, learns from rewards and next states, and tracks scores. The graph separates game simulation, agent behavior and replay memory, and model training and persistence. Calls within these components are supported by the sampled files; the repository provides no README, so broader product capabilities are not documented.
Main entry points: agent.py Training Loop · game.py Game Environment · model.py Q Network · helper.py Score Plotting
Components 11
Training and Agent
- Training Loop
agent.py - Agent Policy
agent.py - Replay Memory
agent.py - Score Plotting
helper.py
Snake Game
- Game Environment
game.py - Snake Movement
game.py - Collision and Food
game.py - Game Display
game.py
Q Learning
- Q Network
model.py - Q Trainer
model.py - Model Checkpoint
model.py
Connections 13
- Training Loop → Agent Policy: uses policy
agent.py - Training Loop → Game Environment: steps game
agent.py - Training Loop → Replay Memory: stores transitions
agent.py - Training Loop → Q Trainer: trains model
agent.py - Training Loop → Score Plotting: plots scores
agent.py - Agent Policy → Game Environment: reads state
agent.py - Agent Policy → Q Network: predicts action
agent.py - Agent Policy → Q Trainer: trains step
agent.py - Game Environment → Snake Movement: updates position
game.py - Game Environment → Collision and Food: checks outcome
game.py - Game Environment → Game Display: updates display
game.py - Q Trainer → Q Network: evaluates values
model.py - Q Network → Model Checkpoint: saves weights
model.py