Skip to content

mathisdelsart/CheckAndCrown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

98 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Check & Crown β™ŸοΈ

Python Pygame

A beautiful, feature-rich chess game built with Python and Pygame. Play against a friend with an elegant interface, multiple board themes, sound effects, and smooth gameplay!

Features β€’ Installation β€’ How to Play β€’ Customization β€’ Contributing

Main Menu Chess Board
Menu Board & Pieces

Visual Showcase

Legal Move Highlighting

Watch the magic happen - click any piece and see all legal moves instantly highlighted!

Board Highlighted Moves
Standard Board Legal Moves Highlighted

Color Themes

Customize your playing experience with three beautiful themes:

Brown Theme Green Theme Blue Theme
Classic Brown Forest Green Ocean Blue

Features

Gameplay Features

Feature Description
Full Chess Rules Complete implementation including castling, en passant, pawn promotion
Legal Move Detection Automatic highlighting of all legal moves for selected piece
Check & Checkmate Proper detection with special sound effects
Stalemate Detection Automatic draw detection when no legal moves available
Move Validation Prevents illegal moves, including those that expose the king

Visual Features

Feature Description
3 Board Themes Choose between Brown, Green, and Blue color schemes
Move Highlighting Selected pieces and legal moves clearly highlighted
Professional UI Modern menu system with smooth animations
Responsive Design Clean 800x800 game board with intuitive controls

Audio Features

Feature Description
Sound Effects Unique sounds for moves, captures, checks, checkmate, castling
Sound Toggle Easily enable/disable sounds with top-left button
Game Start Music Welcome audio when starting a new game

Game Modes

Mode Status
Player vs Player Fully implemented
Player vs AI Coming soon! (Contribute your AI!)

Installation

Prerequisites

  • Python 3.7 or higher
  • Pygame library

Setup

# Clone the repository
git clone https://github.com/mathisdelsart/CheckAndCrown.git
cd CheckAndCrown

# Install dependencies
pip install -r requirements.txt

# Run the game
python main.py

That's it! The game will launch and you're ready to play!

How to Play

Starting a Game

  1. Launch the game by running python main.py
  2. You'll see a main menu with two options:
    • Player vs Player: Play against a friend on the same computer
    • Player vs AI: Play against the computer (coming soon!)
  3. Click your preferred mode to start

Menu Controls

Control Function
Sound Button Toggle sound effects on/off (top-left corner)
Theme Button Cycle through Brown β†’ Green β†’ Blue themes (top-right corner)
Mouse Click Select menu options and interact with pieces

Playing Chess

  1. Select a Piece

    • Click on any of your pieces (white starts first)
    • Legal moves will be highlighted in a lighter shade
  2. Make a Move

    • Click on a highlighted square to move there
    • Click the same piece again or another piece to cancel
  3. Special Moves

    • Castling: Click your king and then click two squares toward the rook
    • En Passant: Automatically detected when capturing a pawn diagonally
    • Pawn Promotion: Automatically promotes to Queen when reaching the end
  4. Game End

    • Checkmate: The game announces the winner!
    • Stalemate: Declared when no legal moves but not in check
    • A menu appears with options to replay or return to main menu

Controls Summary

Key/Action Function
Left Click Select piece / Make move
Sound Button Toggle sounds on/off
Theme Button Change board color theme
ESC Quit game (during gameplay)

πŸ“ Project Structure

Python-Chess/
β”œβ”€β”€ main.py                     # Game entry point
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ music/                  # Sound effects (.wav files)
β”‚   β”œβ”€β”€ pieces/                 # Chess piece images
β”‚   └── screenshots/            # Game screenshots for README
└── src/
    β”œβ”€β”€ piece.py                # Piece classes and movement logic (686 lines)
    β”œβ”€β”€ game_state.py           # Game state management
    β”œβ”€β”€ game.py                 # Main game loop and event handling
    β”œβ”€β”€ board.py                # Board rendering
    β”œβ”€β”€ menu.py                 # Menu system (main + end game)
    β”œβ”€β”€ button.py               # UI button components
    β”œβ”€β”€ assets.py               # Asset loading
    β”œβ”€β”€ configs.py              # Game constants and colors
    └── player_ai.py            # AI placeholder (contribute here!)

Customization

You can easily customize the game by modifying src/configs.py:

Board Size

SIZE_SQUARE = 100  # Size of each square in pixels (default: 100)
ROW = 8            # Number of rows (standard chess)
COL = 8            # Number of columns (standard chess)

Color Themes

Add your own theme to COLORS_BOARD:

COLORS_BOARD = [
    [(240, 217, 181), (181, 136, 99)],   # Brown theme
    [(238, 238, 210), (118, 150, 86)],   # Green theme
    [(222, 227, 230), (140, 162, 173)],  # Blue theme
    # Add your custom theme here!
    [(your_light_color), (your_dark_color)]
]

Move Highlight Colors

COLOR_POSSIBLE_MOVES_LIGHT = (186, 202, 43)  # Light square moves
COLOR_POSSIBLE_MOVES_DARK = (186, 202, 43)   # Dark square moves

Contributing

Contributions are welcome! Here are some ideas to get you started:

High Priority: AI Development

We need your help to create a chess AI!

The file src/player_ai.py contains a placeholder AI that currently makes random legal moves. This is your chance to implement a real chess engine!

How to Create an AI

  1. Start Simple - Improve the random AI:

    • Add piece value scoring (Pawn=1, Knight=3, Bishop=3, Rook=5, Queen=9)
    • Prefer captures over normal moves
    • Avoid moves that lose material
  2. Implement Minimax Algorithm:

    • Recursively search future positions (3-5 moves deep)
    • Evaluate positions using material + positional bonuses
    • Choose the move with the best outcome
  3. Add Alpha-Beta Pruning:

    • Optimize minimax to skip unnecessary branches
    • Doubles your search depth!
  4. Position Evaluation:

    • Material: Count piece values
    • Position: Reward center control, piece development
    • King Safety: Penalize exposed kings
    • Pawn Structure: Evaluate doubled/passed pawns
  5. Advanced Features:

    • Opening book (pre-stored opening moves)
    • Endgame tablebases
    • Iterative deepening
    • Transposition tables

The player_ai.py file includes detailed comments and example code structure to guide you!

AI Resources

Other Ideas

  • Time Control: Add chess clocks for timed games
  • Move History: Display notation of moves played
  • Undo/Redo: Let players take back moves
  • Save/Load Games: Store games in PGN format
  • Online Multiplayer: Play against friends remotely
  • Different Piece Sets: Add alternative piece designs
  • Animated Moves: Smooth piece movement animations
  • Analysis Mode: Show position evaluation and best moves

How to Contribute

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

License

This project is open source and available for educational purposes.

Author

Mathis DELSART


Checkmate your way to victory! β™ŸοΈπŸ‘‘

About

CheckAndCrown delivers a clean, elegant chess experience with smooth visuals, multiple themes, and full chess rules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages