Skip to content

yasir227/Snake_Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ Snake Game - Data-Driven Portfolio Project

A modern implementation of the classic Snake game with advanced data analytics and visualization features. Built to showcase Python programming skills, object-oriented design, and data engineering capabilities.

Screenshot 2025-08-06 122356 Screenshot 2025-08-06 122406

๐ŸŽฎ Features

Core Gameplay

Classic Snake mechanics with smooth controls Configurable game settings via JSON configuration Multiple control schemes (Arrow keys + WASD) Pause/Resume functionality Game over handling with restart option

Data Analytics & Visualization

Comprehensive statistics tracking for each game session Performance analytics including efficiency metrics Data persistence with JSON file storage Interactive data visualization with matplotlib Progress reports and achievement system High scores leaderboard

Technical Features

Object-oriented architecture with clean separation of concerns Modular design for easy extension and maintenance Configuration management system Professional code structure following Python best practices Error handling and logging Cross-platform compatibility

๐Ÿš€ Quick Start

Prerequisites

Python 3.8 or higher

  • pip package manager

Installation

  1. Clone the repository
git clone https://github.com/yasir227/Snake_Game.git
cd Snake_Game
  1. Install dependencies
pip install -r requirements.txt
  1. Run the game
python main.py

That's it! The game will start immediately.

๐ŸŽฏ How to Play

| Control | Action |

|---------|--------|

| โ†‘ โ†“ โ† โ†’ or WASD | Move snake |

| SPACE | Pause/Resume |

| R | Restart (when game over) |

| ESC | Quit game |

Objective

  • Control the snake to eat food (red circles)
  • Grow longer with each food consumed
  • Avoid hitting walls or your own tail
  • Achieve the highest score possible!

๐Ÿ“Š Data Analytics Features

Game Statistics Tracked

  • Score and game length
  • Game duration and efficiency metrics
  • Movement patterns and direction changes
  • Food consumption rate
  • Performance trends over time

Visualizations Available

Run the data visualizer to see your gaming analytics:

python src/data_visualizer.py

Generated Charts:

  • Score progression over time with trend analysis
  • Score distribution histogram
  • Game duration vs performance correlation
  • Performance metrics correlation matrix

Sample Analytics Output


๐Ÿ SNAKE GAME PROGRESS REPORT ๐Ÿ

================================

๐Ÿ“Š GAME SUMMARY:

Total Games Played: 25

Total Playtime: 0.75 hours

Average Score: 85.6

Best Score: 180

Score Consistency (ฯƒ): 32.4



๐Ÿ† ACHIEVEMENTS:

๐ŸŽฎ Dedicated Player - Played 10+ games

๐Ÿ’ฏ Century Club - Scored 100+ points

๐Ÿ“Š Consistent Player - Low score variation

๐Ÿ—๏ธ Project Structure

snake-game-portfolio/
โ”œโ”€โ”€ README.md                 # Project documentation
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ main.py                   # Main game runner
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ settings.json        # Game configuration
โ”œโ”€โ”€ src/                     # Source code
โ”‚   โ”œโ”€โ”€ game.py              # Main game logic
โ”‚   โ”œโ”€โ”€ snake.py             # Snake class
โ”‚   โ”œโ”€โ”€ food.py              # Food class
โ”‚   โ”œโ”€โ”€ game_stats.py        # Statistics tracking
โ”‚   โ””โ”€โ”€ data_visualizer.py   # Data visualization
โ”œโ”€โ”€ data/                    # Generated data files
โ”‚   โ”œโ”€โ”€ game_stats.json      # Game history
โ”‚   โ””โ”€โ”€ high_scores.json     # High scores
โ””โ”€โ”€ tests/                   # Unit tests (future)

โš™๏ธ Configuration

Customize your game experience by editing config/settings.json:

{
   "game": {
       "width": 800,
       "height": 600,
       "cell_size": 20,
       "initial_speed": 150,
       "colors": {
           "background": "#000000",
           "snake": "#00FF00",
           "food": "#FF0000"
       }
   }
}

๐Ÿงช Technical Implementation

Object-Oriented Design

  • Snake class: Handles movement, collision detection, and rendering
  • Food class: Manages food placement and collision detection
  • GameStats class: Tracks and persists game statistics
  • SnakeGame class: Main game orchestrator
  • GameDataVisualizer class: Analytics and visualization engine

Data Engineering Features

  • JSON-based data persistence for game statistics
  • Pandas integration for data analysis
  • Efficient data structures for game state management
  • Real-time statistics calculation and tracking
  • Data validation and error handling

Performance Optimizations

  • Efficient collision detection algorithms
  • Optimized rendering with pygame
  • Memory-efficient data structures
  • Configurable frame rate control

๐Ÿ“ˆ Skills Demonstrated

This project showcases proficiency in:

  • Python Programming: Advanced OOP concepts and design patterns
  • Game Development: pygame library and game loop architecture
  • Data Engineering: Data collection, storage, and processing
  • Data Visualization: matplotlib and statistical analysis
  • Software Architecture: Modular design and separation of concerns
  • Configuration Management: JSON-based configuration systems
  • Error Handling: Robust error management and logging
  • Documentation: Comprehensive project documentation
  • Git Workflow: Professional version control practices

๐Ÿ”ฎ Future Enhancements

-Multiplayer support with networking -Advanced AI opponents with different difficulty levels -Power-ups and special items -Sound effects and background music -Web deployment with Flask/FastAPI -Database integration (PostgreSQL/MongoDB) -Machine learning for gameplay pattern analysis -Real-time dashboard with live statistics -Mobile responsive web version -Tournament mode with brackets

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

โญ Star this repository if you found it helpful!

Screenshot 2025-08-06 122733

Built with โค๏ธ and Python

Screenshot 2025-08-06 123353

About

Snake is a genre of action video games where the player maneuvers the end of a growing line, often themed as a snake. The player must keep the snake from colliding with both other obstacles and itself, which gets harder as the snake lengthens.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages