Design a chess game
PremiumLow-level designHard
- Move validation
- Polymorphism
- Command pattern
Quick answer
This low-level design interview question asks you to design a chess game. Aim for a design that is modelled as clear classes, interfaces and relationships that can handle new requirements without a rewrite. Interviewers want to see how you name responsibilities, keep classes small and reason about change.
The problem
Chess game low level design: build the object model for a two-player chess game on one device or over a network. It must reject every illegal move and detect check, checkmate, stalemate and draws. The hard parts are special moves, king safety, and an undo that restores the exact previous position.
The game accepts a move, decides whether it is legal under the full rules of chess, applies it, keeps the move history in standard notation, allows undo, and supports resignation and a draw offer.
What must a chess game do?
- Move rules: Each piece moves by its own rule. Sliding pieces (rook, bishop, queen) cannot jump; the knight can. A pawn moves one square forward, two from its start square, and captures diagonally.
- Game end: Detect checkmate, stalemate, resignation, agreed draw, the fifty-move rule and threefold repetition.
How well must it do it?
- Correct: No illegal move may ever be applied; the move generator and the validator must agree.
- Fast enough: Validating one move, including the king-safety check, must take under 1 ms so a server can run 10,000 games at once.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- Move validation
- Polymorphism
- Command pattern
- Checkmate detection
- Game state
- Board games
How you’ll practise
- Requirements
- Core objects
- Class relationships
- Key flows
- Extensibility
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any low-level design round.
- Lists the use cases before writing classes
- Gives each class one clear responsibility
- Uses interfaces where behaviour is likely to change
- Applies a design pattern only when it solves a real problem
- Handles edge cases and invalid states explicitly
- Walks through one use case end to end with the model
Questions people ask about this interview question
- Which design type is this question?
- It is a low-level design question. You design a chess game and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Hard. It suits engineers preparing for senior interviews, where you are expected to drive the discussion and go deep on trade-offs.
- What should I cover first?
- Start with the use cases and the core entities, then the responsibilities of each one. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
Updated · Written by the SevyDevy team