Chess Rules - How to Play
Learn the chess rules implemented here, including legal moves, check, castling, en passant, promotion, checkmate, stalemate, and draws.
Board, setup, and objective
Chess is played on an 8×8 board. White starts with a rook, knight, bishop, queen, king, bishop, knight, and rook on the first rank, with eight pawns in front; Black mirrors that arrangement. White moves first, then players alternate one legal move. The objective is checkmate: attack the opposing king so that player has no legal way to escape. You never capture a king in this implementation. Instead, a move that would leave your own king attacked is illegal, and a position with an attacked king and no legal move is checkmate. The king is therefore the piece that defines every legal decision, even when an apparently valuable capture is available.
How each piece moves
A rook moves any unobstructed number of squares horizontally or vertically. A bishop moves any unobstructed number diagonally, while the queen combines both patterns. Knights move in an L shape—two squares in one direction and one perpendicular—and can jump over pieces. Kings move one square in any direction except when castling. Sliding pieces stop before a friendly piece and may capture the first enemy piece on their line; they cannot pass through it. A move may not land on a friendly piece. Because lines are blocked by every occupied square, opening a file for a rook or diagonal for a bishop can change the safety of both kings immediately.
Pawns, captures, and promotion
Pawns move straight forward one square into an empty square. From their starting rank, a pawn may move two squares if both the intermediate and destination squares are empty. Pawns do not capture forward: they capture one square diagonally forward. A pawn reaching the last rank must promote, and this engine offers a queen, rook, bishop, or knight. Promotion is not limited by previously captured pieces, so a side may have more than one queen. The engine records a two-square pawn move because it can enable en passant on the next move. Before advancing a pawn, distinguish the square it attacks from the square it can move to; that distinction is essential for checks and king safety.
Check, castling, and en passant
Check means the king is attacked. You must answer check by moving the king, capturing the attacking piece, or blocking the attack when the line permits it. You may not make a move that exposes your king to a rook, bishop, queen, knight, pawn, or opposing king. Castling moves the king two squares toward a rook and places that rook beside it. It is available only when the relevant king and rook still have their rights, the squares between them are empty, the king is not in check, and the king does not cross or finish on an attacked square. En passant is available only immediately after an adjacent enemy pawn advances two squares; your pawn captures it as though it had advanced one square.
How games end in this engine
Checkmate wins the game, while stalemate is a draw: the side to move has no legal move but its king is not in check. The engine also declares a draw after 100 half-moves without a pawn move or capture, implementing the fifty-move rule, and when neither side has enough material under its implemented test: king against king, or king plus one bishop or knight against king. It also tracks position keys for threefold repetition in the playing session, including the board, side to move, castling rights, and en-passant target. A repeated arrangement is not enough if those rights differ. When practicing, look at legal replies rather than assuming a checked king or a bare king automatically loses.
Chess rules FAQ
- Can I move while my king is in check?
- Only if the move removes the check. The engine filters out every move that leaves your own king attacked.
- What promotion choices are available?
- A pawn on the last rank can become a queen, rook, bishop, or knight.
- Can I castle through check?
- No. The king cannot castle while in check, through an attacked square, or onto an attacked square.
- When can I capture en passant?
- Only on the very next move after an adjacent enemy pawn makes a two-square advance.
- Which draws does this chess engine recognize?
- It recognizes stalemate, the fifty-move count, insufficient material as implemented, and threefold repetition tracked by the session.
Practice the rules on the board
Before each move, check every attack on your king, then compare the legal moves rather than trusting a tempting capture.