Chess

A two-player chess engine with per-piece move rules, check detection, and undo.

Hard50 minPolymorphic movesCommand (undo)Rule validation

Design a two-player chess game: board, pieces, legal move generation, check and checkmate detection, special moves, and undo. It's hard mainly because of rule validation, and it's a great showcase for polymorphism and the Command pattern.

Requirements

Functional

  • 8 x 8 board with the standard initial setup; White moves first.
  • Each piece type moves by its own rules; captures by moving onto an opponent's piece.
  • Reject illegal moves, including moves that leave your own king in check.
  • Detect check, checkmate, and stalemate.
  • Special moves: castling, en passant, pawn promotion.
  • Undo/redo moves; move history in algebraic notation.
  • Optional: clocks, draw by threefold repetition and the 50-move rule, resignation.

Non-functional

  • Clear separation between rules, board state, and UI/IO.
  • Adding a variant piece or rule should not require rewriting the game loop.
  • Move validation fast enough for interactive play (a bot is a follow-up).

Try it first

Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.

50:00

Complete & continue

Defend it out loud

The AI interviewer will probe your design for Chess and score it.

Mock interview