Lahore, Pakistan
← Back to Coursework

CS110 · CS110 - Programming Fundamentals

Chess

A complete C++ chess coursework project recreated as a playable browser game with legal movement, check detection, castling, promotion, AI play, and game history.

Overview

Chess was developed as a Programming Fundamentals coursework project using C++.

The original console implementation is preserved in the public repository, while its game rules and functionality were recreated as an interactive web application using HTML, CSS, and Vanilla JavaScript.

Original C++ Implementation

The original application uses an 8×8 character board and separate validation logic for pawns, knights, bishops, rooks, queens, and kings.

It also implements:

  • Friendly-piece validation
  • Sliding-piece path validation
  • King-safety checks
  • Check detection
  • Checkmate
  • Stalemate
  • Kingside and queenside castling
  • Pawn promotion
  • Legal-move hints
  • Player vs Player mode
  • Player vs Computer mode
  • Save and load through a text file
  • Undo and redo history

Browser Recreation

The web version replaces row-and-column console input with an interactive chess board.

Players select a piece and then choose one of its legal highlighted destinations.

The browser implementation includes:

  • Standard 8×8 chess board
  • Full legal movement for the six chess-piece types
  • Check and king-safety protection
  • Checkmate and stalemate handling
  • Castling validation
  • Pawn-promotion selection
  • Player vs Player mode
  • Player vs Computer mode
  • Legal-move highlighting
  • Move log
  • Undo and redo
  • Save and load through local browser storage
  • Responsive desktop and mobile presentation

Technical Approach

The original C++ board and move-validation functions were translated into a JavaScript game-state engine.

Moves are simulated before being accepted so a player cannot make a move that leaves their own king in check.

The browser AI follows the coursework strategy of prioritising safe captures, captures, castling, forward development, and finally another valid move.

Scope

The project preserves the coursework feature scope.

Rules that were not implemented in the original application, such as en passant, repetition draws, and insufficient-material draws, were not artificially added to the portfolio recreation.

Repository Structure

The repository includes:

  • cpp/Chess.cpp — original C++ source
  • cpp/chess_save.txt — supplied save-state example
  • website root — browser recreation
  • docs/feature-parity.md — implementation comparison

Outcome

The project demonstrates structured board representation, algorithmic move validation, state simulation, game-history management, and translating a console application into a visual browser experience.