Skip to content

Repository files navigation

Snake AI vs Human Performance Study

A comprehensive genetic algorithm-based AI system for playing Snake, with tools for comparing AI and human performance.

🚀 Quick Start

Quick Start

Prerequisites

  • Python 3.8 or higher
  • Git (for cloning the repository)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Snake_AI
  2. 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
  3. Install dependencies

    pip install -r requirements.txt

Usage

Method 1: Complete Experiment Workflow (Recommended)

Run the full experiment workflow, including training, evaluation, and result analysis:

python experiment_manager.py

This script guides you through the entire process step-by-step.

Method 2: Individual Components

Train AI Models

# Quick training (for testing)
python ga_train.py --quick-test

# Advanced training (longer runtime)
python ga_train.py

Evaluate Trained Models

python ga_snake.py --model experiment_data/best_ai/enhanced_model_final.pkl --display --games 10

Collect Human Performance Data including playing by adding users

python human_performance.py

Compare AI vs Human Performance

python compare_performance.py

Analyze Experiment Results

Use analyze_results.py to process experiment output files:

python analyze_results.py

Remember to change the file names in the script to match your output files.

Method 3: Play as Human

python snake_game.py

Use arrow keys to control the snake.

Project Structure

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages