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.
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
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
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
Python 3.8 or higher
- pip package manager
- Clone the repository
git clone https://github.com/yasir227/Snake_Game.git
cd Snake_Game
- Install dependencies
pip install -r requirements.txt
- Run the game
python main.py
That's it! The game will start immediately.
| Control | Action |
|---------|--------|
| โ โ โ โ or WASD | Move snake |
| SPACE | Pause/Resume |
| R | Restart (when game over) |
| ESC | Quit game |
- 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!
- Score and game length
- Game duration and efficiency metrics
- Movement patterns and direction changes
- Food consumption rate
- Performance trends over time
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
๐ 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
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)
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"
}
}
}- 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
- 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
- Efficient collision detection algorithms
- Optimized rendering with pygame
- Memory-efficient data structures
- Configurable frame rate control
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
-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
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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
โญ Star this repository if you found it helpful!
Built with โค๏ธ and Python