ArchitectAI resilience reviews are here. See what's new
Back to all articles
Low Level Design Sep 14, 2026 14 min read

Low Level Design: Chess Game Engine with Move Validation & State Management

Design an extensible, clean Chess game engine. Polymorphic piece behaviors, Command pattern for undo/redo, checkmate detection, and clean OOP boundaries.

LLDChessDesign PatternsCommand PatternOOP
HFHLDForge Architecture TeamLead Machine Coding Specialist

1. Domain Modeling: Board, Cells & Pieces

A chess board is an 8x8 grid of `Cell` objects. Each cell optionally holds a `Piece`. An abstract `Piece` class encapsulates piece color (WHITE/BLACK) and defines an abstract method: `canMove(board: Board, start: Cell, end: Cell): boolean`.

2. Polymorphic Piece Movement Rules

Concrete subclasses (`King`, `Queen`, `Rook`, `Bishop`, `Knight`, `Pawn`) implement their specific movement logic. Knights can jump over pieces; Pawns move forward but capture diagonally; Rooks move horizontally/vertically with path clearance checks.

3. Command Pattern for Move Execution & Undo

Every player turn is encapsulated in a `MoveCommand` object holding the start cell, destination cell, piece moved, and any piece captured. This makes supporting Undo, Redo, and move history trivial by maintaining a command stack.

typescript
enum Color { WHITE, BLACK }

abstract class Piece {
  constructor(public color: Color) {}
  abstract canMove(start: [number, number], end: [number, number], board: Piece[][]): boolean;
}

class Knight extends Piece {
  canMove(start: [number, number], end: [number, number]): boolean {
    const dx = Math.abs(start[0] - end[0]);
    const dy = Math.abs(start[1] - end[1]);
    return (dx === 1 && dy === 2) || (dx === 2 && dy === 1);
  }
}
Interactive Modeling ArchitectAI

Model this architecture on the HLDForge Canvas

Turn static box diagrams into living, collaborative systems. Drag and drop microservices, Kafka clusters, and cache tiers. Run automated SPOF detection and STRIDE threat modeling in real time.

HF

Written by HLDForge Architecture Team

Lead Machine Coding Specialist

The HLDForge Architecture Team publishes practical engineering guides, real-world case studies, and high-concurrency blueprints to help engineers build scalable and fault-tolerant software.

Free forever plan

Ready to master distributed system design?

HLDForge gives you the tools, templates, and AI reviews to design systems like a Staff Engineer. Get started free.

SOC 2 Type II · ISO 27001 aligned · SSO on every paid plan