Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.23 KB

File metadata and controls

51 lines (40 loc) · 2.23 KB

SnakeAI

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).

Modifications

This fork includes the following enhancements:

Enhanced Training Monitoring

  • Custom SnakeMetricsCallback for real-time TensorBoard logging
  • Tracks game score, win rate, and detailed episode statistics
  • Better insights into training progress

Reward Function Experiments

  • Multiple reward function variations for experimentation
  • Progressive reward scaling based on snake length
  • Configurable reward strategies in snake_game_custom_wrapper_cnn.py

Multiple Training Versions

  • trained_models_cnn_original/ - Original training run
  • trained_models_cnn_v1/ - First experiment
  • trained_models_cnn_v2/ - Second experiment
  • trained_models_cnn_v3/ - Third experiment

🎮 Improved Testing

  • Detailed step-by-step reward logging
  • Min/Max/Average score statistics
  • Configurable render speed and episode count

File Structure

├───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