Note: This project is forked from linyiLYi/snake-ai. See Modifications section for details on what has been changed.
This project contains the program scripts for the classic game "Snake" and an artificial intelligence agent that can play the game automatically. The intelligent agent is trained using deep reinforcement learning with a Convolutional Neural Network (CNN).
This fork includes the following enhancements:
- Custom
SnakeMetricsCallbackfor real-time TensorBoard logging - Tracks game score, win rate, and detailed episode statistics
- Better insights into training progress
- Multiple reward function variations for experimentation
- Progressive reward scaling based on snake length
- Configurable reward strategies in
snake_game_custom_wrapper_cnn.py
trained_models_cnn_original/- Original training runtrained_models_cnn_v1/- First experimenttrained_models_cnn_v2/- Second experimenttrained_models_cnn_v3/- Third experiment
- Detailed step-by-step reward logging
- Min/Max/Average score statistics
- Configurable render speed and episode count
├───main
│ ├───logs # TensorBoard training logs
│ ├───trained_models_cnn/ # Default trained model
│ ├───trained_models_cnn_original/ # Original training run
│ ├───trained_models_cnn_v1/ # Experiment v1
│ ├───trained_models_cnn_v2/ # Experiment v2
│ ├───trained_models_cnn_v3/ # Experiment v3
│ ├───trained_models_cnn_mps/ # Apple Silicon model
│ ├───snake_game.py # Base game implementation
│ ├───snake_game_custom_wrapper_cnn.py # Gym environment wrapper
│ ├───train_cnn.py # Training script
│ └───test_cnn.py # Testing script
├───utils
│ ├───check_gpu_status.py # CUDA GPU check
│ └───check_gpu_status_mps.py # Apple MPS check