Appendix C — Notation, Rules, and File Formats
Chess has two languages. One is spoken at the board: algebraic notation on a scoresheet, a hand that touches a
piece, a flag that falls. The other is spoken by software: FEN strings, PGN files with comments in braces, an
engine answering bestmove d7d6. This book moves between them constantly, and most of the bugs we met while
writing it lived at the border — a castling move typed with zeros, an evaluation read from the wrong side's
point of view, a clock reading that already included the increment.
This appendix is the reference for both languages. The first half covers the file formats — SAN, FEN, PGN,
UCI and EPD — with every edge case checked in python-chess (appendices/code/c01_notation.py; its full output
is in c01_notation.out.txt). The second half covers the rules that end games: what the FIDE Laws of Chess say
about draws, time and touching pieces, and how Lichess and Chess.com implement the same ideas in software —
with the book's data showing how often each ending actually happens.
♟️ Improver Track: C.1 (reading SAN) and C.6–C.8 (the rules that decide your games) are the parts you will use at the board.
💻 Developer Track: C.2–C.5 are the formats your code reads and writes; the pitfalls there are the ones that silently corrupt a database study.
C.1 Standard Algebraic Notation (SAN)
The basics
Files are lettered a–h from White's left, ranks numbered 1–8 from White's side, so every square has a name
(e4, f7). A move is written as the piece letter — K king, Q queen, R rook, B bishop, N knight;
no letter for a pawn — followed by the destination square: Nf3, e4. A capture inserts x: Bxf7, and a pawn
capture names the file the pawn came from: exd5. Move numbers count full moves: 12.Nf5 is White's twelfth
move, 12...Nf6 Black's reply. The book writes moves in plain text in prose and with English piece letters
throughout.
| Element | Notation | Example |
|---|---|---|
| Piece move | letter + square | Nf3, Qd1 |
| Pawn move | square only | e4, d5 |
| Capture | x before the square; pawn captures name the departure file |
Bxf7, exd5 |
| Castling | O-O (kingside), O-O-O (queenside) — capital letter O |
O-O |
| Promotion | = + piece |
e8=Q, axb8=N |
| En passant | written as an ordinary pawn capture to the destination square | exd6 |
| Check / mate | + / # appended |
Bxf7+, Qh4# |
| Disambiguation | add the departure file, rank, or both, when two pieces of the same kind can reach the square | Rad1, N5d4, Qh4e1 |
Disambiguation, promotions, castling and en passant in practice
b = chess.Board("4k3/8/8/1N6/8/1N6/8/4K3 w - - 0 1")
print("knights on b3/b5 both reach d4:", sorted(b.san(m) for m in b.legal_moves if m.to_square == chess.D4))
b = chess.Board("4k3/8/8/8/8/5N2/8/1N2K2N w - - 0 1")
print("three knights reach d2 / g3:", sorted(b.san(m) for m in b.legal_moves if m.to_square in (chess.D2, chess.G3)))
b = chess.Board("1n2k3/P7/8/8/8/8/8/4K3 w - - 0 1")
print("promotions:", sorted(b.san(m) for m in b.legal_moves if m.promotion))
b = chess.Board("4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 2")
print("en passant available:", [b.san(m) for m in b.legal_moves if b.is_en_passant(m)])
knights on b3/b5 both reach d4: ['N3d4', 'N5d4']
three knights reach d2 / g3: ['Kd2', 'Nbd2', 'Nfd2', 'Ng3']
promotions: ['a8=B', 'a8=N', 'a8=Q', 'a8=R', 'axb8=B', 'axb8=N', 'axb8=Q+', 'axb8=R+']
en passant available: ['exd6']
The rule for disambiguation is "as little as necessary": when two knights on the same file can reach d4,
the rank tells them apart (N3d4, N5d4); otherwise the file is used (Nbd2, Nfd2). Only the knight on
f3 reaches g3, so Ng3 needs nothing extra. Underpromotion is written explicitly (a8=N), and the check
symbol belongs to the move that gives check — capturing on b8 and promoting to a queen or rook checks the
king on e8, so those two moves carry +.
What software accepts
python-chess writes strict SAN but reads generously — useful when you parse hand-typed game scores, dangerous if you assume every file it accepts is clean:
parse_san('Ng1f3') accepted -> Nf3
parse_san('N1f3') accepted -> Nf3
parse_san('0-0') rejected: IllegalMoveError
parse_san('e2e4') accepted -> e4
parse_san('Nf3+') accepted -> Nf3
Over-specified moves (Ng1f3), moves in UCI form (e2e4) and even a wrong + on a non-checking move are
accepted and normalised. Castling typed with the digit zero (0-0) is rejected — and that is exactly why 22
broadcast games failed to replay when the book's feature table was built (Appendix B, B.9). If you parse PGN
from tournament relays, normalise 0-0 and 0-0-0 to the letter O first.
Annotation symbols and NAGs
| Symbol | Meaning | PGN NAG |
|---|---|---|
! |
good move | $1 |
? |
mistake | $2 |
!! |
brilliant move | $3 |
?? |
blunder | $4 |
!? |
interesting / speculative move | $5 |
?! |
dubious move | $6 |
A NAG (Numeric Annotation Glyph) is how PGN stores these marks: $1`…`$6 for the move marks above, and
higher numbers for position assessments. In this book the symbols are used sparingly and always justified in
words. Lichess adds ?!, ? and ?? automatically to the moves of analysed games, using the same 5/10/15
win-% thresholds as the book (Appendix D); the toolkit's parse_movetext strips
those suffixes so the SAN can be replayed.
Other notations you will meet
- Long algebraic writes both squares:
Ng1-f3,e2-e4,Bf1xb5. Some older books and many correspondence records use it. - UCI move notation (C.4) is long algebraic without piece letters or punctuation:
g1f3,e7e8qfor a promotion,e1g1for White's kingside castling in standard chess. - Descriptive notation (
P-K4,N-KB3) named files after the pieces that start on them and counted ranks from each player's own side. It dominated English-language books until the 1970s–80s; Sam's Chernev and Fine books in the Thursday Night Chess Club use it. FIDE recognises only algebraic notation for scoresheets. - Figurine algebraic replaces the letters by piece symbols (♘f3) so that a book can be read in any language.
C.2 FEN — Forsyth–Edwards Notation
A FEN describes one position in six fields separated by spaces. Here is the Najdorf Sicilian after 5...a6:
Najdorf after 5...a6: rnbqkb1r/1p2pppp/p2p1n2/8/3NP3/2N5/PPP2PPP/R1BQKB1R w KQkq - 0 6
placement rnbqkb1r/1p2pppp/p2p1n2/8/3NP3/2N5/PPP2PPP/R1BQKB1R
side w
castling KQkq
en passant -
halfmove clock 0
fullmove 6
| Field | Rule |
|---|---|
| 1. Piece placement | rank 8 first, down to rank 1; within a rank, files a → h. KQRBNP White, kqrbnp Black; a digit 1–8 counts consecutive empty squares; ranks separated by / |
| 2. Active colour | w or b |
| 3. Castling availability | any of KQkq, or -. It records rights (king and rook unmoved), not whether castling is legal now — a king in check still has its rights |
| 4. En-passant target | the square behind a pawn that has just advanced two squares, or - (see the convention below) |
| 5. Half-move clock | plies since the last capture or pawn move — the counter behind the 50- and 75-move rules (C.6) |
| 6. Full-move number | starts at 1 and increases after each Black move |
The en-passant convention. The original FEN standard writes the target square after every double pawn step. Many programs — python-chess by default, and Stockfish — write it only when an en-passant capture is actually legal:
after 1.e4 python-chess writes ep field: - | with en_passant='fen': e3
Both are valid; they matter when you compare FENs as text. Two FENs of the same position can differ in this
field, so compare board.board_fen() (placement only) or the first four fields, as the book's engine cache does.
EPD and the four-field key. The first four fields alone identify a position for most purposes (C.5). The half-move and full-move counters affect only the 50/75-move rules and the move numbers — which is why an engine cache keyed on four fields cannot tell a position at move 7 from the same position at move 9, and why an engine given only a FEN cannot see a repetition coming. (Given the moves that led to the position, Stockfish does score repetitions inside its search as draws — Appendix B, B.11, explains how that interacts with the book's cache.)
Chess960. Castling rights in Chess960 cannot always be written KQkq, because the rooks may start on any
file; programs use the file letters of the castling rooks instead (X-FEN / Shredder-FEN variants). python-chess
handles both when a board is created with chess960=True
(Chapter 37).
C.3 PGN — Portable Game Notation
PGN is a plain-text format with two parts: a header of tag pairs, then the move text.
Tags
The Seven Tag Roster must appear, in this order, in every PGN game: Event, Site, Date (YYYY.MM.DD,
with ?? for unknown parts), Round, White, Black, Result (1-0, 0-1, 1/2-1/2, or * for an
unfinished or unknown result). Everything else is optional. The tags this book reads, and where they appear:
| Tag | Lichess games | Broadcast games | PGN Mentor | Chess.com | Notes |
|---|---|---|---|---|---|
WhiteElo, BlackElo |
Lichess Glicko-2 | FIDE (sometimes national) | historical Elo, when known | Chess.com Glicko | never mix pools |
TimeControl |
180+2 (seconds) |
organiser's text: 90+30 (minutes), 5400+30 (seconds), 90'+30'', or missing |
rare | 180, 180+2 |
Appendix B, B.5 |
ECO, Opening |
Lichess's classifier | Lichess's classifier | from the source | ECO plus an opening-page URL in ECOUrl |
|
Termination |
Normal, Time forfeit, … |
rare | rare | text such as "won by resignation" | C.8 |
UTCDate, UTCTime |
yes | often | no | yes | |
Variant |
Standard only in our sample | Chess960, … |
no | for variants | |
SetUp, FEN |
no | rare | none in our table | for set-up games | a non-standard start position |
Move text, comments and variations
After the tags comes the move text: move numbers (1., and 1... when a Black move starts a fragment), SAN
moves, and:
- comments in braces
{ like this }(or after a;to the end of a line); - variations in parentheses
( 1... e5 2.Nf3 ), which may nest; - NAGs
$1` … `$255; - the result token at the end, which must match the
Resulttag.
Writing a small game with python-chess shows all three:
pgn = chess.pgn.Game()
pgn.headers["Event"] = "Appendix C example"
pgn.headers["White"] = "White"
pgn.headers["Black"] = "Black"
n = pgn.add_variation(chess.Move.from_uci("e2e4"))
n.comment = "[%eval 0.32] [%clk 0:05:00]"
n = n.add_variation(chess.Move.from_uci("c7c5"))
n.nags.add(chess.pgn.NAG_SPECULATIVE_MOVE)
n.parent.add_variation(chess.Move.from_uci("e7e5")).comment = "the main alternative"
pgn.headers["Result"] = "*"
print(str(pgn))
[Event "Appendix C example"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "White"]
[Black "Black"]
[Result "*"]
1. e4 { [%eval 0.32] [%clk 0:05:00] } 1... c5 $5 ( 1... e5 { the main alternative } ) *
Embedded commands: [%eval], [%clk], [%emt]
Lichess, Chess.com and many broadcast tools put machine-readable data inside comments as [%command value].
Three matter here:
| Command | Meaning | Format | Point of view |
|---|---|---|---|
[%eval 0.18], [%eval #-3] |
engine evaluation of the position after the move | pawns with two decimals, or #N for mate in N |
White's (positive = good for White; #-3 = Black mates in three) |
[%clk 0:09:54] |
the mover's remaining clock after the move | h:mm:ss, Chess.com adds tenths (0:02:59.9) |
the player who just moved |
[%emt 0:00:12] |
elapsed move time | h:mm:ss |
the player who just moved |
Here is the start of a real Lichess rapid game from the book's sample — an anonymous pair of players, a 600+2 tournament game in the Stafford Gambit, which Lichess's server analysed:
headers we keep: {'event': 'Rated Rapid tournament https://lichess.org/tournament/KO0t3g9Y', 'time_control': '600+2', 'eco': 'C42', 'opening': "Petrov's Defense: Stafford Gambit", 'result': '0-1', 'termination': 'Normal'}
start of movetext: 1. e4 { [%eval 0.18] [%clk 0:10:00] } 1... e5 { [%eval 0.22] [%clk 0:10:00] } 2. Nf3 { [%eval 0.18] [%clk 0:10:00] } 2... Nf6 { [%eval 0.34] [%clk 0:0
ply san eval_cp mate clock_s
1 e4 18 None 600.0
2 e5 22 None 600.0
3 Nf3 18 None 600.0
4 Nf6 34 None 594.0
5 Nxe5 29 None 599.0
6 Nc6 147 None 593.0
python-chess node.eval(): PovScore(Cp(-18), BLACK) | .white(): +18 | node.clock(): 600.0 | comment kept: '[%eval 0.18] [%clk 0:10:00]'
Read the clock column carefully. Each player's first move shows the full ten minutes — Lichess does not run the
clock for the first move of each side. On ply 4 Black has 594 s after spending six seconds. On ply 5 White shows
599 s: White spent three seconds and received the two-second increment, which is added after the move. A
"time spent" calculation therefore has to be previous clock − current clock + increment, and the first move
of each side has to be skipped — the rules the book's clock chapter uses
(Chapter 13). The same effect is
why the broadcast table's inferred base time usually includes the first increment (Appendix B, B.5).
Read the evaluation column too: after 3...Nc6 — the gambit move that offers a pawn — the evaluation jumps from +0.29 to +1.47 for White. That is the Stafford Gambit in one number; Chapter 23 shows why club players still score well with it despite the engine's verdict.
⚠️ Common pitfall: the point of view of an evaluation.
[%eval]is from White's side. python-chess'snode.eval()returns aPovScorerelative to the side to move after the move — Black, here — which prints asCp(-18); call.white()to get the White-POV +18. A UCI engine'sinfo score(C.4) is from the side to move. The toolkit converts everything to White's view before it stores or prints a number.⚠️ Common pitfall: a PGN
Dateis what someone typed. In the broadcast table the earliestDateis 2025.05.07 although the files are relays from November 2025 onwards, and some games carry????.??.??.
Reading PGN in Python
chess.pgn.read_game(stream) reads one game at a time from any text stream and returns None at the end
(Appendix A, A.5–A.6). For millions of games the toolkit's
chessdata.iter_pgn_text(lines) splits PGN into (headers, movetext) without building python-chess objects,
and chessdata.parse_movetext extracts SAN, evaluations and clocks with a regular expression — both much faster
when you do not need legal-move checking.
C.4 UCI — how programs talk to engines
The Universal Chess Interface is a line-based text protocol between a graphical interface (or your Python
script) and an engine. python-chess hides it behind engine.analyse(...), but it is worth seeing once. This is
a real conversation with the book's Stockfish 19, sent by c01_notation.py (>> = sent to the engine, << =
the engine's reply; the long lists of options and search lines are abbreviated, everything else is verbatim):
>> uci
<< Stockfish 19 by the Stockfish developers (see AUTHORS file)
<< ... 19 'option' lines ...
<< uciok
>> setoption name Threads value 1
>> isready
<< readyok
>> ucinewgame
>> position startpos moves e2e4 c7c5 g1f3
>> go depth 12
<< info depth 1 seldepth 3 multipv 1 score cp -20 nodes 23 nps 11500 hashfull 0 tbhits 0 time 2 pv b8c6
<< ... (12 'info depth' lines) ...
<< info depth 12 seldepth 16 multipv 1 score cp -27 nodes 28265 nps 247938 hashfull 11 tbhits 0 time 114 pv d7d6 f1b5 c8d7 b5d7 b8d7 e1g1 e7e6 f1e1
<< bestmove d7d6 ponder f1b5
>> quit
| Command (sent) | Purpose |
|---|---|
uci |
start; the engine names itself, lists its options and ends with uciok |
setoption name <Name> value <v> |
e.g. Threads, Hash (MB), MultiPV, UCI_Chess960, SyzygyPath |
isready |
wait until the engine has finished processing; it answers readyok |
ucinewgame |
the next position is from a different game (clears the hash table in Stockfish) |
position startpos moves ... / position fen <FEN> moves ... |
set the position; moves are in UCI notation |
go depth N / go movetime ms / go nodes N / go infinite / go wtime .. btime .. winc .. binc .. |
search with a limit |
stop |
end an infinite search; the engine replies bestmove |
quit |
exit |
| Reply | Meaning |
|---|---|
info depth 12 seldepth 16 |
nominal search depth; deepest line examined (extensions) |
score cp -27 / score mate 5 |
evaluation from the side to move's view, centipawns or mate in N moves |
multipv 1 |
which line (with MultiPV > 1 the engine reports several) |
nodes, nps, time |
positions searched, nodes per second, milliseconds |
hashfull |
per-mille fill of the hash table |
tbhits |
tablebase probes that hit |
pv d7d6 f1b5 ... |
the principal variation |
bestmove d7d6 ponder f1b5 |
the chosen move, and the reply it expects |
After 1.e4 c5 2.Nf3 it is Black to move, so score cp -27 means Black is 0.27 worse — +0.27 from White's
point of view at depth 12, with 2...d6 as the engine's choice. This side-to-move convention is the single most
common source of sign errors in engine scripts; python-chess's info["score"].white() and the toolkit's cp
field both convert to White's view for you.
Two more points. The depth is not the length of the principal variation — the line above has eight moves at depth 12 and the search examined lines to depth 16. And MultiPV searches several best lines at once: the book's cache shows that single-line and multi-line searches of the same position at the same depth can differ by a few tenths of a pawn, so a quoted ranking states "multipv N" (Appendix B, B.14).
C.5 EPD — Extended Position Description
EPD is FEN without the two move counters, followed by optional opcodes — named fields that turn a position into a test item. It is the format of engine test suites ("find the best move in these 300 positions").
b = chess.Board("r1bqkb1r/pppp1ppp/2n2n2/4p2Q/2B1P3/8/PPPP1PPP/RNB1K1NR w KQkq - 4 4")
epd = b.epd(bm=b.parse_san("Qxf7#"), id="scholar's mate")
print("EPD with opcodes:", epd)
b3 = chess.Board()
ops = b3.set_epd(epd)
EPD with opcodes: r1bqkb1r/pppp1ppp/2n2n2/4p2Q/2B1P3/8/PPPP1PPP/RNB1K1NR w KQkq - bm Qxf7#; id "scholar's mate";
parsed back - ops: {'bm': ['Qxf7#'], 'id': "scholar's mate"} | clocks reset: 0 1
| Opcode | Meaning |
|---|---|
bm |
best move(s), in SAN |
am |
avoid move(s) |
id |
an identifier for the test position |
c0 … c9 |
comments |
ce |
centipawn evaluation |
dm |
direct mate in N |
hmvc, fmvn |
half-move clock and full-move number, when you need them |
Because EPD drops the counters, set_epd resets them (half-move clock 0, move 1). The book's exercise positions
are stored as FENs instead, so that the 50-move counter of an endgame position is never lost.
C.6 The FIDE Laws of Chess — the essentials
Over-the-board games under FIDE are played under the FIDE Laws of Chess, published in the FIDE Handbook. What follows summarises the parts that matter most for practical play and for interpreting the book's OTB data. It is a summary, not the Laws: the wording below is ours, the Laws are revised from time to time (the most recent edition we checked took effect on 1 January 2023; a later revision may exist when you read this), and tournaments add their own regulations. Check the current FIDE Handbook for the exact text before you rely on a detail in a dispute.
How pieces move — the three special moves
- Castling is a king move of two squares towards a rook, with the rook jumping over to the square the king crossed. It is not allowed if the king or that rook has already moved, if a piece stands between them, if the king is in check, or if the king would cross or land on an attacked square. (The rook may pass over an attacked square — on the queenside, b1 can be attacked.)
- En passant: a pawn that advances two squares and lands beside an enemy pawn can be captured by that pawn as if it had moved only one square — but only on the very next move.
- Promotion: a pawn reaching the last rank must be exchanged for a queen, rook, bishop or knight of the same colour, chosen freely, as part of the same move.
Ending the game
| Outcome | What the Laws provide (summary) |
|---|---|
| Checkmate | the game is won by the player who mates |
| Resignation | the game is lost by the player who resigns |
| Stalemate | the side to move has no legal move and is not in check: a draw |
| Dead position | no sequence of legal moves can lead to checkmate for either side (e.g. king against king, or king and bishop against king): the game is drawn immediately |
| Agreement | a draw may be agreed; under the Laws an offer is made after making your move on the board and before pressing the clock. Many events restrict agreements before a set move number |
| Threefold repetition | a draw on a correct claim by the player to move, when the same position has appeared, or is about to appear after the move the player declares, at least three times — "same position" meaning same side to move, same pieces on the same squares, and the same possible moves, including castling and en-passant rights |
| 50-move rule | a draw on a correct claim when each player has made at least 50 consecutive moves (or is about to complete them) without a pawn move or a capture |
| Fivefold repetition | the game is drawn automatically when the same position has appeared at least five times (introduced in 2014; the precise wording on how the appearances are counted is in the Laws) |
| 75-move rule | drawn automatically after at least 75 consecutive moves by each player without a pawn move or a capture — unless the last move delivered mate |
| Flag fall | a player who has not completed the prescribed moves in the allotted time loses — but the game is drawn if the opponent could not checkmate by any possible series of legal moves |
Note the asymmetry of the last line. It is not enough that the opponent cannot force mate; the game is lost on time if any legal sequence, however cooperative, ends in mate. If you flag with a lone king while your opponent has king and knight, the game is drawn: king and knight cannot mate a bare king in any sequence. Give yourself one extra pawn and the verdict flips — now a mate by the knight exists in some sequence (your own pawn, or a piece it promotes to, can take your king's flight square), so a flag fall loses.
At the board
| Topic | Summary of the Laws |
|---|---|
| Touch-move | a player who deliberately touches one of their own pieces must move it (if it can legally move); deliberately touching an opponent's piece obliges a capture of it if possible. To adjust a piece without obligation you first say "I adjust" (or "j'adoube") |
| Completing a move | once a piece is released on a square it cannot be moved elsewhere; the move is complete when it is made and the player presses the clock (castling and promotion have their own details) |
| Illegal moves | in standard play, the first completed illegal move is corrected and the opponent receives extra time (two minutes); a second illegal move by the same player loses. Rapid and blitz have their own provisions in the appendices of the Laws — check the current text |
| Recording | in standard play each player records the moves in algebraic notation; a player with less than five minutes left in a period, without an increment of at least 30 seconds a move, need not record until the period ends |
| Electronic devices | phones and other electronic devices are forbidden in the playing venue unless the event's rules allow them switched off and stored; a breach can lose the game |
| The arbiter | applies the Laws, supervises the clocks, and can penalise; in many situations (repetition, 50 moves) a player must claim — the arbiter does not stop the game unprompted except for the automatic rules |
Time controls and speed classes
FIDE classifies a game by the time a player would use for 60 moves: base time plus 60 times the increment. At least 60 minutes is standard (classical); more than 10 and less than 60 minutes is rapid; 10 minutes or less is blitz. The book's broadcast table uses exactly these classes (Appendix B). Online platforms use a different formula — base plus 40 times the increment, with their own cut-offs (C.7) — so a "rapid" online game and a "rapid" FIDE game are not the same thing.
🔄 Check your understanding 1. White has king and knight; Black has a lone king. White's flag falls. Result? 2. White has king and knight; Black has king and a pawn on h5. White's flag falls. Result? 3. A position appears for the third time, but you are not on the move. Can you claim?
Answer
- Black cannot mate by any series of legal moves (a lone king), so the game is drawn.
- White loses on time if Black can mate by some legal sequence. Black's h-pawn can promote, and a queen can mate, so such a sequence exists: White loses. (python-chess reports this as "can still mate" in C.8.)
- Under the Laws the claim is made by the player whose turn it is — either because the position has just appeared (your opponent's move created it, so you are on the move) or because your intended move will create it. So the player on the move claims; in your case, wait for your turn.
C.7 Online rules: the same ideas, enforced by software
Online platforms implement the Laws' ideas, but a program, not an arbiter, applies them. The differences that matter for interpreting online data:
| Topic | Over the board (FIDE Laws) | Online (Lichess, Chess.com) |
|---|---|---|
| Illegal moves | possible; penalised (C.6) | impossible — the interface only accepts legal moves |
| Touch-move | applies | does not exist; premoves (a move entered before the opponent has moved) are allowed and executed instantly |
| Threefold repetition, 50-move rule | draws only on a claim | enforced by the software — automatically or through a one-click claim, depending on platform and settings (at the time of writing Lichess, for example, has a player preference for when a threefold claim is made automatically) |
| Fivefold, 75-move, dead position | automatic | automatic |
| Insufficient material | dead position = draw | declared automatically when neither side has mating material |
| Flag fall vs insufficient material | draw only if the opponent could not mate by any legal sequence | a draw when the opponent lacks the material to mate, by the platform's own rule — similar to, but not always identical with, the FIDE wording |
| Time | analogue/digital clocks with optional increment or delay | server clock; Lichess does not start a player's clock before that player's first move; increments added after each move; "berserk" in Lichess arenas halves your clock (and drops the increment) in exchange for an extra tournament point if you win |
| Abandonment / disconnection | rare; arbiter decides | a player who leaves can lose by abandonment after a time-out; Lichess records Abandoned |
| Rule enforcement | arbiter, on a claim | the server; fair-play teams for cheating |
| Speed classes | FIDE: base + 60 × increment | Lichess: base + 40 × increment (ultrabullet < 29 s, bullet < 179 s, blitz < 479 s, rapid < 1499 s, classical ≥ 1500 s); Chess.com has its own time classes |
Platform rules change, and both sites document theirs in help pages. Where this book quotes a platform rule it describes the behaviour visible in the data, which you can check below.
C.8 How games actually end — in the data and in python-chess
The rules in python-chess
python-chess implements the rules exactly, which makes it a convenient referee for constructed positions:
b = chess.Board()
shuffle = ["Nf3", "Nf6", "Ng1", "Ng8"]
for i in range(16):
b.push_san(shuffle[i % 4])
# record can_claim_threefold_repetition(), is_repetition(3), is_fivefold_repetition()
knight shuffle from the start: threefold claimable after ply 7, fivefold (automatic) after ply 16
is_game_over() at fivefold: True | outcome: Outcome(termination=<Termination.FIVEFOLD_REPETITION: 5>, winner=None)
halfmove clock 99: can_claim_fifty_moves: True
after one more quiet move (clock 100): True | is_seventyfive_moves: False
clock 150: is_seventyfive_moves: True | outcome: Outcome(termination=<Termination.SEVENTYFIVE_MOVES: 4>, winner=None)
K vs K is_insufficient_material=True White can still mate=False Black can still mate=False
K+N vs K is_insufficient_material=True White can still mate=False Black can still mate=False
K+B vs K is_insufficient_material=True White can still mate=False Black can still mate=False
K+N+N vs K is_insufficient_material=False White can still mate=True Black can still mate=False
K+N vs K+P is_insufficient_material=False White can still mate=True Black can still mate=True
K+R vs K is_insufficient_material=False White can still mate=True Black can still mate=False
Qf7 here: stalemate = True
Four details are worth reading slowly.
- The claim comes one move early. Two knights shuffling out and back reproduce the starting position after plies 4 and 8. After ply 7 Black, to move, can already claim: the intended move 4...Ng8 will produce the third occurrence — just as the Laws allow a claim for a move "about to be made". The position actually occurs a third time at ply 8 and a fifth time at ply 16, when the game ends automatically.
- Counting the 50 moves. The half-move clock counts plies, so the 50-move claim needs a clock of 100. At 99 the claim is already possible, because the next quiet move would complete the 50 moves; at 150 the 75-move rule ends the game.
- "Insufficient material" is two different questions.
is_insufficient_material()asks whether neither side can ever mate — the dead-position draw (K vs K, K+N vs K, K+B vs K).has_insufficient_material(color)asks whether one side could mate by any sequence — the question for a flag fall. Two knights cannot force mate, but a mate exists in some sequence, so K+N+N vs K is not a dead position. With a black pawn on the board, even the lone knight can take part in a mate (C.6), so both sides "can still mate". - Stalemate is the trap in a won ending. With king and queen against a cornered king, 1.Qf7 takes the last
square: stalemate, a draw. The same check (
is_stalemate()) is how the book's ending statistics separate stalemates from other draws.
What the data says
The Lichess Termination tag against the result, for the human games of the sample (bots and unfinished games
excluded):
result 0-1 1-0 1/2-1/2
termination
Abandoned 5399 4572 0
Insufficient material 0 0 612
Normal 1219847 1339486 121214
Rules infraction 43 53 0
Time forfeit 624950 635775 26702
time-forfeit games: 1287427 | of which draws: 26702 (2.07%)
So 32.4% of human Lichess games end on time (1,287,427 of 3,978,653), and 26,702 of those time forfeits — 2.07% —
are draws: the flag fell, but the opponent did not have the material to win. A separate Insufficient material
termination (612 games) covers games drawn the moment mating material ran out.
Normal hides the most interesting part. Replaying the drawn and decisive games and weighting the one-in-eight
sample back to the population, the book's data snapshot gives these shares among Lichess games that ended
Normal (611,965 games with move text, weighted to 2,678,435):
Ending (Normal termination, Lichess, weighted) |
Share |
|---|---|
| resignation (no mate on the board) | 59.57% |
| checkmate | 35.89% |
| draw by threefold (or more) repetition | 2.23% |
| draw by stalemate | 1.00% |
| draw by insufficient material | 0.94% |
| draw by agreement / other | 0.34% |
| draw by the 50-move rule | 0.02% |
Among the draws alone, repetition is about half (49.3%), stalemate 22.1% and insufficient material 20.7%; agreements are only 7.5%, and the 50-move rule 0.5%.
Over the board the picture is reversed. In 359,184 human OTB broadcast games with move text, 13.3% ended in
checkmate on the board, 62.9% were decisive without mate (resignation, loss on time or adjudication — the relays
rarely record which; only 3.6% of games carry a Termination tag), and 23.8% were drawn. Of the OTB draws, 83.0%
were agreements or other non-mechanical draws and 11.7% repetitions. The checkmate share collapses with strength:
66.9% of OTB games between players averaging under FIDE 1200 end in mate on the board, 2.2% at 2400+, where the
loser resigns long before.
Lichess (Normal endings) |
OTB broadcast (all) | |
|---|---|---|
| Checkmate on the board | 35.89% | 13.34% |
| Resignation / other decisive | 59.57% | 62.88% |
| Draw by agreement / other | 0.34% | 19.73% |
| Draw by repetition | 2.23% | 2.79% |
| Draw by stalemate | 1.00% | 0.29% |
| Draw by insufficient material | 0.94% | 0.87% |
| Draw by the 50-move rule | 0.02% | 0.10% |
Online, a draw has to happen on the board — a repetition, a stalemate, bare kings — because few players agree draws in a three-minute game; over the board, most draws are agreed. That difference is one reason OTB draw rates are so much higher, and one reason why statistics such as "score" mean slightly different things in the two pools (Chapter 36 on online play; Chapter 27 on tournament practice).
📋 Try it — Endgame technique. Set up White Kf1, Nf3; Black Kh3 and a pawn on h4, Black to move (
8/8/8/8/7p/5N1k/8/5K2 b - - 0 1). Use python-chess to answer: is it a dead position? If White's flag falls here, who wins under the FIDE flag rule — and if Black's flag falls?
Answer
chess.Board("8/8/8/8/7p/5N1k/8/5K2 b - - 0 1")is a valid position, andis_insufficient_material()is False, so it is not a dead position. For a flag fall by White, the question is whether Black could mate by any legal sequence —not b.has_insufficient_material(chess.BLACK)is True (the pawn can become a queen), so White would lose on time. If Black flagged, the question is whether White could mate: knight and king against king and pawn — a mate exists in principle (the pawn can block its own king), so Black would lose too. Mating material is about what is possible, not what is likely.
C.9 Quick reference
| Format | One-line summary | python-chess |
|---|---|---|
| SAN | Nf3, exd5, O-O, e8=Q+, Rad1 |
board.san(m), board.parse_san(s), board.push_san(s) |
| UCI move | g1f3, e7e8q, e1g1 |
m.uci(), chess.Move.from_uci(s) |
| FEN | 6 fields: placement, side, castling, en passant, half-move clock, full-move number | board.fen(), chess.Board(fen) |
| EPD | 4 FEN fields + opcodes (bm, am, id) |
board.epd(**ops), board.set_epd(s) |
| PGN | tags + move text with {comments}, (variations), $NAGs, result |
chess.pgn.read_game(f), str(game) |
[%eval] |
after the move, White's view, pawns or #N |
node.eval().white(), chessdata.parse_movetext |
[%clk] |
mover's remaining time after the move | node.clock() |
| UCI protocol | uci → isready → position → go → bestmove |
chess.engine.SimpleEngine.popen_uci(path) |
| Draw checks | threefold/fivefold, 50/75 moves, stalemate, dead position | can_claim_threefold_repetition(), is_fivefold_repetition(), can_claim_fifty_moves(), is_seventyfive_moves(), is_stalemate(), is_insufficient_material(), has_insufficient_material(color) |