How abhishek21112000/reinforcement-learning works
This repository implements Snake in two modes: a human-controlled Pygame game and an AI training loop that learns to play using Q-learning. In the AI workflow, the training loop reads game state, selects and executes actions, trains from transitions, and plots scores; the game engine handles movement, rewards, collisions, and rendering. The model module supplies the neural network and trainer. Source excerpts support these calls; the README is empty, and the existing checkpoint’s use is not shown.
Main entry points: agent2.py Training Loop · model.py Q Trainer · game2.py AI Snake Engine · snake_game_human.py Human Snake Game
Components 9
Snake Gameplay
- Human Snake Game
snake_game_human.py - AI Snake Engine
game2.py
AI Training
- Training Loop
agent2.py - Learning Agent
agent2.py
Model and Feedback
- Q Network
model.py - Q Trainer
model.py - Score Plotter
helper.py
Other components
- Human Player
- Training Operator
Connections 10
- Human Player → Human Snake Game: controls
snake_game_human.py - Training Operator → Training Loop: starts training
agent2.py - Training Loop → Learning Agent: requests actions
agent2.py - Training Loop → AI Snake Engine: executes moves
agent2.py - Training Loop → Learning Agent: trains transitions
agent2.py - Training Loop → Score Plotter: plots scores
agent2.py - Learning Agent → AI Snake Engine: reads game state
agent2.py - Learning Agent → Q Network: predicts actions
agent2.py - Learning Agent → Q Trainer: trains Q values
agent2.py - Q Trainer → Q Network: updates weights
model.py