Design Chess Game
| Difficulty: Hard | Source: awesome-low-level-design |
Requirements
- Standard chess rules
- Two players with own pieces
- 8x8 grid, alternating colors
- 16 pieces per player (king, queen, 2 rooks, 2 bishops, 2 knights, 8 pawns)
- Validate legal moves, prevent illegal ones
- Detect checkmate and stalemate
- Handle player turns
- User interface
Class Diagram

Classes, Interfaces and Enumerations
| Class/Interface | Description |
|---|---|
| Piece | Abstract class; color, row, column; abstract canMove method |
| King | Subclass of Piece; moves one square in any direction |
| Queen | Subclass of Piece; moves any number of squares along rank, file, or diagonal |
| Rook | Subclass of Piece; moves any number of squares along rank or file |
| Bishop | Subclass of Piece; moves any number of squares diagonally |
| Knight | Subclass of Piece; moves in an L-shape (2+1 squares) |
| Pawn | Subclass of Piece; moves forward one square (or two from starting position), captures diagonally |
| Board | 8x8 grid; piece placement, move validation, checkmate/stalemate detection |
| Player | Name; make move method |
| Move | Piece, destination coordinates |
| Game | Game flow, turns, result |
Design Patterns Used
| Pattern | Application |
|---|---|
| Strategy/Polymorphism | Each piece type implements its own movement logic via the abstract canMove method, allowing uniform move validation |
Code Implementations
| Language | Source Code |
|---|---|
| Java | View on GitHub |
| Python | View on GitHub |
| C++ | View on GitHub |
| C# | View on GitHub |
| Go | View on GitHub |