# Rules of play

**Version:** v005 — Editable Move List

This document completely describes how to play this version of the game.
A reader with only this document and the interface can play a full game
against another player, and the two of them can determine who won.

## The game

Chess. Two players, White and Black, on an 8×8 board of alternating
light and dark squares. Each player begins with sixteen pieces arranged
on their two nearest ranks: eight pawns on the second rank; rook,
knight, bishop, queen, king, bishop, knight, rook on the first, with the
queen on her own color (White's queen on d1, Black's on d8).

White moves first. Players alternate, one move per turn. Passing is not
allowed.

## Objective

Checkmate the opposing king: attack it such that the opponent has no
legal move that removes the attack. Delivering checkmate wins the game
immediately.

## Piece movement

- **Pawn** (circle): moves one square straight forward to an empty
  square; from its starting square it may instead move two squares
  forward if both are empty. It captures diagonally forward one square.
  It never moves backward.
- **Knight** (L shape): moves in an "L" — two squares in one rank/file
  direction and one square perpendicular. It jumps over intervening
  pieces.
- **Bishop** (triangle): moves any number of empty squares diagonally.
- **Rook** (square): moves any number of empty squares along a rank or
  file.
- **Queen** (asterisk): moves any number of empty squares along a rank,
  file, or diagonal.
- **King** (cross): moves one square in any direction.

A piece captures by moving onto a square occupied by an enemy piece,
which is removed. No piece except the knight may pass through occupied
squares. You may never capture your own piece.

## Special moves

- **Castling:** the king moves two squares toward one of its rooks and
  that rook moves to the square the king crossed. Allowed only if
  neither the king nor that rook has moved, the squares between them are
  empty, the king is not in check, and the king does not cross or land
  on an attacked square.
- **En passant:** immediately after an enemy pawn advances two squares
  and lands beside your pawn, your pawn may capture it as if it had
  advanced only one. Available only on the very next move.
- **Promotion:** a pawn reaching the last rank becomes, at its owner's
  choice, a queen, rook, bishop, or knight. The interface presents the
  choice when it occurs.

## Check and legality

A king is **in check** when an enemy piece attacks its square. You may
never make a move that leaves your own king in check; the interface
enforces this by only permitting legal moves. If you are in check, every
legal move available to you resolves the check.

## How a game ends

The interface detects each of these conditions automatically and
announces the result in the status line. That announcement is the
authoritative verdict.

**Decisive results:**

- **Checkmate.** The player to move is in check and has no legal move.
  That player loses; the other player wins.

**Draws (neither player wins):**

- **Stalemate.** The player to move is not in check but has no legal
  move.
- **Fifty-move rule.** Fifty consecutive full moves pass with no capture
  and no pawn move.
- **Threefold repetition.** The same position, with the same player to
  move and the same castling and en-passant rights, occurs for the
  third time. Two positions share the same en-passant right only when a
  pawn can actually make the en-passant capture; a double pawn push that
  leaves no pawn able to answer it creates no distinct position.
- **Insufficient material.** Neither side retains enough material to
  ever deliver checkmate (for example, king against king, or king and
  one minor piece against king).

## Determining the winner

Play until the status line announces a result. "Checkmate — White wins"
or "Checkmate — Black wins" names the winner. "Stalemate" or "Draw"
means neither player has won. There is no interpretation involved in
this version: the verdict is computed from the rules above and displayed.

## The interface

Move by dragging a piece to a highlighted destination, or by clicking a
piece and then clicking a destination. Legal destinations are marked
when a piece is selected. **New game** starts over; **Undo** takes back
the most recent move by agreement of the players. The game is local:
both players share one screen and take turns with the same pointer.

**Forced moves:** When the player to move has exactly one legal move,
that move executes automatically after 800 ms. The move appears in the
move list identically to a player-input move. No announcement is
displayed. Because a whole game can consist of successive forced
positions, this may advance several moves in a row without any player
input, one step per 800 ms. Auto-execution never changes which move is
legal or how the game ends; it only removes the wait when there is no
choice to make. If **Undo** returns the game to a position where the
side to move still has only one legal move, that move executes again
after 800 ms.

**Editing the move list.** Each move entry in the move list is editable.
Click a move to edit it in place; press Enter or click away to commit,
or press Escape to abandon the edit. Committing an edit replays the whole
move list from the starting position and updates the board to the
position that results. In this version the move list is the primary
object and the board is a rendering of it: the list accepts any notation,
including moves that would be illegal in standard chess, and the board
renders whatever position results from applying the entries in sequence.
There is no validation, confirmation, or prompt. An entry that cannot be
interpreted — or one you have cleared — halts the replay: that entry and
every entry after it are struck through as unreachable, and the board
shows the last position actually reached. Editing is itself an action
available to either player.

Because an edited move list can describe a position no legal game could
reach, the status line's verdict on such a position is computed from the
resulting position mechanically and may not correspond to a legal chess
result. It is nonetheless always definite (see **Determining the
winner**). A game whose move list has been edited into an illegal
position is not saved across a page reload; reloading starts a fresh
game.
