Back to Projects

Software Development

Chess Application

Jun 2025

An interactive chess application built with Python and Pygame featuring legal move validation, checkmate and stalemate detection, castling, en passant, and pawn promotion.

PythonPygameGame LogicEvent Handling
Chess Application project preview

Project Overview

What I built

The Chess Application was developed to practise game-state management and rule-based programming through a complex board-game problem. The application tracks the behaviour of every piece, validates legal moves, protects king safety, and continuously updates the board after each turn.

Challenge

The problem I needed to solve

Each chess piece follows a different movement rule, and those rules needed to interact correctly with occupied squares, captures, special moves, player turns, and king safety. The application also needed to reject moves that would leave the player in check and determine when no legal moves remain.

Approach

How I approached it

I implemented movement validation for each piece type and integrated it with Pygame input handling and board rendering. The rule engine filters out moves that expose the player's king, validates castling and en passant, and checks the resulting board state for check, checkmate, and stalemate.

Implementation

Key implementation details

  • Implemented legal movement validation for pawns, rooks, knights, bishops, queens, and kings.
  • Prevented moves that leave the player's own king in check and blocked kings from moving into attacked squares.
  • Implemented check, checkmate, and stalemate detection by evaluating the legal moves available to the active player.
  • Added chess-specific rules including castling validation, en passant, and pawn promotion.
  • Developed turn-based Pygame interaction, legal-move highlighting, captured-piece tracking, and game restart functionality.