Skip to content
K1lluaZkPublic

About

PyChess is a chess game developed with Pygame, designed to offer an interactive and fluid experience. With stylized graphics and an intuitive interface, it allows for matches between players or against an artificial intelligence. Its focus is on accessibility and entertainment, ideal for those who enjoy chess in digital format. โ™Ÿ๏ธ๐ŸŽฎ

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

ย 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PyChess โ™Ÿ๏ธ๐ŸŽฎ

PyChess is a modular chess game built in Python and Pygame featuring full chess mechanics, an AI opponent, a progression and points system, guest and registered account support with SQLite persistence, multiple board visual themes, and a responsive modern user interface.


๐ŸŒŸ Key Features

  • Full Chess Engine & Mechanics:
    • Valid move generation for all piece types (Pawns, Knights, Bishops, Rooks, Queens, Kings).
    • Proper check, checkmate, and stalemate detection.
    • Automatic pawn promotion to Queen on back rank.
    • Turn system with responsive AI opponent for Black.
    • Visual valid-move indicators and check warnings.
  • Account & Guest System:
    • Guest Mode: Play instantly without registration. Session points are tracked during current gameplay.
    • Registered Accounts: Create or log into user accounts. Points are permanently saved in a local SQLite database (pychess.db).
  • Points & Rewards Engine:
    • Configurable points rewards for piece captures, promotions, delivering check, checkmate, and winning matches.
    • Real-time match score calculation and breakdown summary on game conclusion.
  • Modern User Interface:
    • Interactive Main Menu with hover animations and player profile status.
    • In-game Side Panel displaying current turn, match score, captured pieces list, and controls.
    • Points & Leaderboard Screen with scoring guide and top players ranking.
    • Game Settings Screen with customizable board themes (Classic Slate, Emerald Forest, Ocean Breeze, Warm Wood) and audio/visual toggles.
    • Result Screen detailing match outcome and points breakdown.
  • Modular & Maintainable Architecture:
    • Clean separation of concerns across config/, database/, player/, game/, and ui/.

๐Ÿ“‚ Project Structure

PyChess/
โ”œโ”€โ”€ main.py                     # Main application entry point
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ pychess.db                  # SQLite database (auto-generated)
โ”‚
โ”œโ”€โ”€ config/                     # Settings and point values
โ”‚   โ”œโ”€โ”€ settings.py             # Display, board themes, UI palette
โ”‚   โ””โ”€โ”€ points_config.py        # Centralized point values & reward rules
โ”‚
โ”œโ”€โ”€ database/                   # SQLite data persistence layer
โ”‚   โ”œโ”€โ”€ db.py                   # DB connection & schema initialization
โ”‚   โ”œโ”€โ”€ models.py               # User and score models
โ”‚   โ””โ”€โ”€ repository.py           # UserRepository CRUD operations & leaderboards
โ”‚
โ”œโ”€โ”€ player/                     # Player state & session handling
โ”‚   โ””โ”€โ”€ session.py              # Guest vs Authenticated user session manager
โ”‚
โ”œโ”€โ”€ game/                       # Core chess game logic
โ”‚   โ”œโ”€โ”€ constants.py            # Piece identifiers, colors, board layout
โ”‚   โ”œโ”€โ”€ board.py                # Board 8x8 matrix representation & state
โ”‚   โ”œโ”€โ”€ moves.py                # Move generation for all 6 piece types
โ”‚   โ”œโ”€โ”€ rules.py                # Check, checkmate, and stalemate validation
โ”‚   โ”œโ”€โ”€ ai.py                   # AI move selection for Black
โ”‚   โ”œโ”€โ”€ points_engine.py        # Match events & score calculation
โ”‚   โ””โ”€โ”€ game_state.py           # Turn coordinator & match state manager
โ”‚
โ”œโ”€โ”€ ui/                         # Pygame graphical user interface
โ”‚   โ”œโ”€โ”€ screen_manager.py       # Screen transition & state manager
โ”‚   โ”œโ”€โ”€ components/             # Reusable UI widgets (Buttons, Inputs, Cards, Theme)
โ”‚   โ””โ”€โ”€ screens/                # UI Screens (Home, Account, Game, Points, Settings, Result)
โ”‚
โ”œโ”€โ”€ assets/                     # Game assets
โ”‚   โ””โ”€โ”€ images/
โ”‚       โ””โ”€โ”€ pieces/             # Chess piece PNG graphics
โ”‚
โ””โ”€โ”€ tests/                      # Automated test suite
    โ”œโ”€โ”€ test_chess_logic.py     # Move generation, check, checkmate, points tests
    โ”œโ”€โ”€ test_database.py        # SQLite persistence & session tests
    โ””โ”€โ”€ test_ui_smoke.py        # Screen lifecycle & navigation smoke tests

๐Ÿ“ฆ Requirements & Installation

  1. Python 3.8+ installed.
  2. Clone the repository:
    git clone https://github.com/K1lluaZk/pychess.git
    cd pychess
  3. Install dependencies:
    pip install -r requirements.txt

๐Ÿ•น๏ธ How to Play

Run the application:

python main.py

Gameplay Controls:

  1. Home Screen: Start game, manage accounts, view points & rules, or adjust settings.
  2. Move Pieces: Click on any of your white pieces to see highlighted valid moves, then click a valid destination square.
  3. Capture & Score: Earn points by capturing enemy pieces, delivering checks, and winning by checkmate.
  4. End Game: When the game concludes, review your earned points and return to the main menu or play again.

๐Ÿ† Points System Reference

Event Reward
Capture Pawn +10 pts
Capture Knight +30 pts
Capture Bishop +30 pts
Capture Rook +50 pts
Capture Queen +90 pts
Pawn Promotion +40 pts
Deliver Check +20 pts
Deliver Checkmate +100 pts
Victory Bonus +200 pts

๐Ÿงช Running Tests

To run the automated unit test suite:

python -m unittest discover -s tests

๐Ÿ“„ License

This project is licensed under the MIT License.

About

PyChess is a chess game developed with Pygame, designed to offer an interactive and fluid experience. With stylized graphics and an intuitive interface, it allows for matches between players or against an artificial intelligence. Its focus is on accessibility and entertainment, ideal for those who enjoy chess in digital format. โ™Ÿ๏ธ๐ŸŽฎ

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages