Skip to the guide

Design a chess game: moves, rules and a move validator

AdvancedCase study12 pages

The interviewer asks you to design chess for two people at one screen, and to say how a move gets checked. Picture a child learning at a kitchen table. She slides her bishop to a new square and keeps one finger on it while you both look around. If anything can now reach her king, the bishop goes back, and nothing has happened.

It is also asked as "design a chess validator", and the closest case study is 2048. Interviewers like it because each piece's moves are easy, and "is this move allowed?" needs the whole board.

Below is a full 45-minute round on the LLD framework. You are the candidate. At each Guess before you read on, stop and answer first. The full runnable project, with its tests, is a download in Java, JavaScript and Python.

Run the full project

This design as a project you can run, with its tests and a demo. You only need Java 21, Node 24 or Python 3.13. The README says how to run it.

Step 1 · Clarify the requirements and cut the scope

Minutes 0–5 · How this step works

Interviewer: Design chess. I care most about how you validate a move.

You: Who plays? Is it two people, or a computer as well?

Interviewer: Two people at one screen. A computer player may come later.

You: I assume all six pieces, with check, checkmate and stalemate. Is castling in, where the king moves two squares towards a rook and the rook jumps over it? And en passant?

Interviewer: Castling is in. Leave en passant out for now, because I'll come back to it.

You: Can a player choose what a pawn becomes on the last row? And can a player take a move back?

Interviewer: A queen for now. And yes, any number of moves.

You: Then I'll build those, with castling, promotion to a queen and take-back. Draws by repetition, the 50-move rule, clocks and network play are out. OK?

Interviewer: Good.