GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - azelthong/chess-pygame: Interactive chess application built with Python and Pygame featuring piece movement, captures, special moves, and check detection.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
assets/images
assets/images
 
 
images
images
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
chess.py
chess.py
 
 
constant.py
constant.py
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Chess Application

An interactive chess application developed in Python using Pygame.

The project implements chess-piece movement, turn-based gameplay, captures, special moves, pawn promotion, check indication, and graphical interaction.

Preview

Chess Application

Features

  • Interactive 8×8 chess board
  • White and black piece movement
  • Turn-based gameplay
  • Legal movement calculation for:
    • Pawns
    • Rooks
    • Knights
    • Bishops
    • Queens
    • Kings
  • Piece selection and valid-move indicators
  • Piece capture
  • Captured-piece display
  • Check indication
  • Pawn promotion
  • Castling
  • En passant
  • Game restart functionality
  • Checkmate detection
  • Stalemate detection
  • Legal-move validation to prevent moves that leave the king in check
  • King safety validation
  • Castling validation through attacked squares

Technologies

  • Python
  • Pygame

Project Structure

chess-pygame/
│
├── assets/
│   └── images/
│       └── chess piece images
│
├── images/
│   └── demo.png
│
├── chess.py
├── constant.py
├── requirements.txt
├── .gitignore
└── README.md

Installation

Clone the repository:

git clone https://github.com/azelthong/chess-pygame.git

Navigate into the project:

cd chess-pygame

Install the required dependency:

pip install -r requirements.txt

Running the Game

Run:

python chess.py

How It Works

The application maintains the position and state of each chess piece and calculates available moves according to the movement rules of the selected piece.

Pygame is used for:

  • Rendering the chess board
  • Displaying chess pieces
  • Processing mouse input
  • Highlighting available moves
  • Displaying captured pieces
  • Indicating check
  • Handling game interaction

Special Moves

The project includes implementations for:

Castling

The game tracks whether the king and rooks have moved and determines whether the required squares are available for castling.

En Passant

Pawn movement state is tracked to determine when an en-passant capture is available.

Pawn Promotion

When a pawn reaches the opposite side of the board, the player can promote it to:

  • Queen
  • Rook
  • Bishop
  • Knight

What I Learned

Through this project, I gained experience with:

  • Python game development
  • Pygame
  • Game-state management
  • Event-driven programming
  • Movement-validation algorithms
  • Coordinate-based logic
  • Managing interactions between graphical interfaces and application state
  • Implementing rule-based systems

Future Improvements

Potential improvements include:

  • Move history
  • Undo functionality
  • Chess notation
  • Computer opponent
  • Improved user interface
  • Unit tests for movement logic

Author

Azel Thong

  • GitHub: https://github.com/azelthong
  • LinkedIn: https://www.linkedin.com/in/azel-thong-532084274/

About

Interactive chess application built with Python and Pygame featuring piece movement, captures, special moves, and check detection.

Topics

algorithmscheckmatechessgame-developmentgame-logicobject-oriented-programmingpygamepython

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.