A comprehensive genetic algorithm-based AI system for playing Snake, with tools for comparing AI and human performance.
- Python 3.8 or higher
- Git (for cloning the repository)
-
Clone the repository
git clone <repository-url> cd Snake_AI
-
Create and activate virtual environment
# On Windows python -m venv venv venv\Scripts\activate # On macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
Run the full experiment workflow, including training, evaluation, and result analysis:
python experiment_manager.pyThis script guides you through the entire process step-by-step.
# Quick training (for testing)
python ga_train.py --quick-test
# Advanced training (longer runtime)
python ga_train.pypython ga_snake.py --model experiment_data/best_ai/enhanced_model_final.pkl --display --games 10
python human_performance.pypython compare_performance.pyUse analyze_results.py to process experiment output files:
python analyze_results.pyRemember to change the file names in the script to match your output files.
python snake_game.pyUse arrow keys to control the snake.
Snake_AI/
├── experiment_data/ # Experiment output directory
│ ├── ai_models/ # Trained AI models
│ ├── human_data/ # Human gameplay data
│ ├── results/ # Generated result files
│ └── best_ai/ # Best performing models
├── ga_models/ # Neural network implementations
├── experiment_manager.py # Full experiment workflow
├── ga_train.py # AI training script
├── ga_snake.py # AI evaluation script
├── human_performance.py # Human data collection
├── compare_performance.py # Performance comparison
├── analyze_results.py # Script to analyze experiment results
├── compare_performance.py # Performance comparison
├── analyze_results.py # Script to analyze experiment results
├── snake.py # Core game logic
├── game_controller.py # Human game interface
├── ga_controller.py # AI game interface
├── continue_training.py # Fine-tuning script
├── continue_training.py # Fine-tuning script
└── requirements.txt # Python dependencies