How block hashes become chess moves

A complete walkthrough of the hash-to-move algorithm — from raw block data to piece on the board.

Step 1 — Anatomy of a block hash

A Bitcoin block hash is a 64-character hexadecimal string. It always begins with a run of zeros — this is required by proof-of-work difficulty and tells us nothing random. Everything from the first non-zero character onward is genuine cryptographic randomness.

00000000000000000003f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9ab
0…
Leading zeros — structural (proof-of-work). Stripped.
f1a2
Chars 1–2 after strip → select the piece to move
b3c4
Chars 3–4 after strip → select the destination square
Remaining chars — fallback if move is illegal
Important: A 0 appearing after the leading zeros is genuine random data with a 1/16 probability — it is not discarded. The strip only removes the deterministic leading zeros, not any zero that follows.

Step 2 — Selecting which piece moves

Take the first two significant hex characters and convert them to a decimal number (0–255). Use modulo to map that into the list of legal moves for the active team. This gives a legal-move index.

2a
Convert chars 1–2 to decimal
Example: f1 → hex F1 → decimal 241
2b
Get all legal moves for the active team
The engine generates every valid move (respecting check, pins, etc.). Say there are 28 legal moves at this position.
2c
Pick the piece via modulo
241 mod 28 = 17 → legal move #17. That move's from-square is now the selected piece's location. All legal moves for that piece are collected.

Step 3 — Selecting the destination square

Take the next two significant characters (positions 3–4) and use the same modulo approach to pick from the selected piece's legal destination squares.

3a
Convert chars 3–4 to decimal
Example: b3 → hex B3 → decimal 179
3b
Pick destination via modulo
If the selected piece has 5 legal destination squares: 179 mod 5 = 4 → destination square #4 (0-indexed). The move is made.

Piece reference

Both teams use all six standard chess piece types. Bitcoin plays orange pieces (white side), Ethereum plays silver pieces (black side).

Piece Bitcoin (orange) Ethereum (silver) Moves like Value
King One square any direction
Queen Any distance, any direction 9
Rook Any distance, straight lines 5
Bishop Any distance, diagonals only 3
Knight L-shape, jumps over pieces 3
Pawn Forward 1–2, captures diagonally 1

Step 4 — Fallback for illegal moves

Since the hash determines moves purely by arithmetic, occasionally the derived move would be illegal — for example, moving into check. The engine handles this gracefully:

4a
Illegal move detected
All legal moves are pre-filtered for legality (check, pins, etc.) before the hash selects from them, so by construction the selected move is always legal. Illegality cannot arise from the selection step itself.
4b
Null result from hash
If the hash is too short after stripping to produce a valid index (extremely unlikely with real 64-char hashes), that block is skipped and the next block from the same chain is fetched.
4c
Checkmate / stalemate
If the active team has zero legal moves, the game ends — checkmate if in check, stalemate (draw) if not. No block is fetched.

Worked example — Bitcoin's move

Let's trace a real move from a Bitcoin block hash.

0000000000000000000a3f72c1bd4e5f6a7b8c9d0e1f2a3b4c5
Strip leading zeros → significant portion starts at 3a7f2c1b…
Chars 1–2: a3 → decimal 163. Say there are 31 legal moves → 163 mod 31 = 8 → legal move #8. That move originates from e2 (a pawn).
Collect all legal moves for the pawn on e2. It can go to e3 or e4 — 2 options.
Chars 3–4: f7 → decimal 247. 247 mod 2 = 1 → destination #1 = e4.
Result: pawn advances e2 → e4. ✓ Legal. Move made.
Board position after e2 → e4

Who goes first?

Before the first move, a "deciding block" is fetched from Bitcoin. The last significant hex digit (rightmost non-zero character) determines who plays first:

Last digit value Parity Goes first
1, 3, 5, 7, 9, b, d, f Odd Bitcoin ♔ (orange)
0, 2, 4, 6, 8, a, c, e Even Ethereum ♚ (silver)

Replicability and verification

Every game is permanently reproducible. Block hashes are immutable on-chain. Starting a game at BTC block 840,000 today or in 10 years produces the exact same sequence of moves. Each move log entry links directly to the block on its chain explorer so anyone can independently re-derive the move.

To replay a game: note the BTC and ETH starting block numbers displayed after game start, then use Start at block mode with those same numbers.


← home  ·  play →  ·  Made with ♥ by crrdlx