Skip to content

DeepSquare is an Intelligent Chess Engine built in Python with Pygame, offering multiple AI algorithms, beautiful themes, and a complete chess experience.

License

Notifications You must be signed in to change notification settings

aman-chhetri/DeepSquare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepSquare: An Intelligent Chess Engine ♟️

Python Pygame License Status

A sophisticated chess engine with multiple AI algorithms and beautiful GUI

Cover Image Chessboard

🎯 Overview

DeepSquare is a feature-rich chess engine built in Python with Pygame, offering multiple AI algorithms, beautiful themes, and a complete chess experience. Whether you're a beginner learning chess or an advanced player testing your skills against sophisticated AI, DeepSquare provides an engaging and educational platform.

🧾 Table of Contents

  • Features
  • Installation
  • Usage
  • Algorithms (AI)
  • Future Enhancements
  • Feedback and Contributions

✨ Features

🎮 Game Modes

  • Player vs Player: Classic human vs human gameplay
  • Player vs AI: Challenge yourself against intelligent computer opponents
  • AI vs AI: Watch different algorithms battle it out

🤖 AI Algorithms

  • Random Move: Basic random selection for casual play
  • Minimax: Classic minimax algorithm with depth-3 search
  • NegaMax: Optimized negamax implementation for better performance
  • Alpha-Beta Pruning: Advanced algorithm with pruning for optimal play

🎨 Visual Experience

  • Multiple Themes: Choose from Classic, Blue, Brown, or Gray board themes
  • Move Highlighting: Visual feedback for selected pieces and valid moves
  • Smooth Animations: Beautiful piece movement animations
  • Move Log: Real-time display of game history in algebraic notation

🎯 Game Features

  • Complete Chess Rules: All standard chess rules implemented
  • Special Moves: Castling, en passant, and pawn promotion
  • Game State Management: Check, checkmate, and stalemate detection
  • Undo/Reset: Keyboard shortcuts for game control
  • Responsive UI: Intuitive mouse and keyboard controls

🚀 Installation

Prerequisites

  • Python 3.7 or higher
  • Pygame 2.0 or higher

Quick Start

# Clone the repository
git clone https://github.com/aman-chhetri/deepsquare.git
cd deepsquare

# Install dependencies
pip install pygame

# Run the game
python main.py

🎮 Usage

Starting the Game

  1. Launch: Run python main.py
  2. Select Theme: Choose your preferred board theme
  3. Choose Game Mode: Select Player vs Player, Player vs AI, or AI vs AI
  4. Select AI Algorithm : Choose from Random, Minimax, NegaMax, or Alpha-Beta Pruning

Controls

  • Mouse: Click to select pieces and make moves
  • Z Key: Undo the last move
  • R Key: Reset the game
  • Close Window: Exit the game

Game Rules

  • White moves first
  • Standard chess rules apply
  • Special moves are automatically detected and executed
  • Game ends on checkmate or stalemate

🤖 AI Algorithms Explained

Random Move

  • Strategy: Completely random move selection
  • Use Case: Casual play, testing, or when you want unpredictable opponents
  • Difficulty: Very Easy

Minimax

  • Strategy: Classic minimax algorithm with depth-3 search
  • Use Case: Good for learning and intermediate play
  • Difficulty: Medium
  • Performance: Evaluates all possible moves up to 3 moves ahead

NegaMax

  • Strategy: Optimized negamax implementation
  • Use Case: More efficient than minimax with same results
  • Difficulty: Medium-Hard
  • Performance: Same evaluation as minimax but with cleaner code structure

Alpha-Beta Pruning

  • Strategy: Advanced algorithm with alpha-beta pruning optimization
  • Use Case: Strongest AI opponent, tournament-level play
  • Difficulty: Hard
  • Performance: Significantly faster than minimax/negamax with same results

🔧 Technical Details

Architecture

DeepSquare/
├── main.py          # Main game interface and UI
├── engine.py        # Core chess logic and rules
├── ai_engine.py       # AI algorithms and evaluation
├── assets/          # Chess piece images
└── README.md        # Project Description

Key Components

Game Engine (engine.py)

  • Board Representation: 8x8 2D array with piece notation
  • Move Validation: Comprehensive legal move checking
  • State Management: Game state tracking and restoration
  • Special Moves: Castling, en passant, pawn promotion

AI Engine (ai_engine.py)

  • Evaluation Function: Material counting + position-based scoring
  • Search Algorithms: Multiple AI implementations
  • Piece-Square Tables: Strategic position evaluation
  • Performance Optimization: Alpha-beta pruning

User Interface (main.py)

  • Pygame GUI: Responsive and intuitive interface
  • Theme System: Multiple visual themes
  • Animation System: Smooth piece movements
  • Event Handling: Mouse and keyboard input

Performance Metrics

  • Search Depth: 3 moves ahead for all AI algorithms
  • Move Generation: Real-time legal move calculation
  • UI Responsiveness: 15 FPS target for smooth gameplay
  • Memory Usage: Efficient state management

🎯 Future Enhancements

  • Opening Book: Add common chess openings
  • Difficulty Levels: Adjustable AI strength
  • Save/Load Games: Persistent game state
  • Network Play: Online multiplayer support
  • Analysis Mode: Move analysis and suggestions
  • Custom Themes: User-defined board themes
  • Sound Effects: Audio feedback for moves
  • Tournament Mode: Round-robin AI competitions

🤝 Feedback and Contribution

It is publicly open for any contribution. Bugfixes, new features, and extra modules are welcome.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub Issues.

📬 Connect

© 2025 Aman Kshetri 👨‍💻

About

DeepSquare is an Intelligent Chess Engine built in Python with Pygame, offering multiple AI algorithms, beautiful themes, and a complete chess experience.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages