Skip to main content
Formal Specification

King's Table — Formal Specification

Iceland · board-abstract · Confidence: low

← Back to game page

Implementation Suitability

Suitability: engine-readyFidelity: directGap-fills: 5
# Hnefatafl — AI-optimized specification ## General idea An asymmetric two-player abstract strategy board game simulating a king under siege. One player commands a central King and 12 loyal defenders attempting to escape to any of four corner refuge squares, while the opposing player commands 24 attackers deployed along the perimeter attempting to surround and capture the monarch. The game is fully deterministic with perfect information and orthogonal rook-like movement. ## Formal model - **Abstraction taken:** None — the traditional rules already form a complete discrete system on an 11x11 orthogonal grid. Formalization only codifies capture anvils and loop-breaking termination. - **Player/agent count:** 2 players (Player 1: Attackers with 24 pieces; Player 2: Defenders with 12 pieces plus 1 King). - **Turn model:** Strictly alternating sequential turns. ## Formal rules R1. Setup: Board is an 11x11 square grid with 121 squares. The central square (f6) is the throne (*konungsstóll*). The four corner squares (a1, a11, k1, k11) are refuges (*borgir*). The King starts on the central throne. 12 defenders occupy the adjacent cross positions around the throne (d6, e5, e6, e7, f4, f5, f7, f8, g5, g6, g7, h6). 24 attackers occupy perimeter edge formations in four groups of 6 (top: d11, e11, f11, g11, h11, f10; bottom: d1, e1, f1, g1, h1, f2; left: a4, a5, a6, a7, a8, b6; right: k4, k5, k6, k7, k8, j6). R2. Turn order: Attackers move first. Players alternate single-piece moves. R3. Legal movement: Any piece (attacker, defender, or King) moves orthogonally (horizontally or vertically) across any number of contiguous unoccupied squares (identical to the rook in modern chess). Pieces cannot jump over or occupy squares containing other pieces. R4. Restricted squares: Only the King may land on or occupy the central throne or the four corner refuge squares. Regular pieces (attackers and defenders) may pass through the empty central throne square [gap-fill] if unoccupied, but cannot stop on it. R5. Custodial capture: A regular piece (attacker or defender) is captured and removed from the board when the active player moves a piece such that the opposing piece becomes flanked on two opposite orthogonal sides by opposing pieces, or flanked between an opposing piece and an empty corner refuge square or the empty throne square [gap-fill]. Captures only trigger for the active mover's turn; safely moving a piece between two opposing pieces does not result in capture. Multiple captures along different axes in a single move are resolved simultaneously. R6. King capture: The King is captured and removed when surrounded on all four orthogonal sides by attacking pieces, or on three orthogonal sides if the fourth side is the central throne square (*konungsstóll*). R7. Win conditions: - Defenders win immediately if the King reaches any of the four corner refuge squares (*borgir*). - Attackers win immediately if they capture the King. - If a player on their turn has no legal moves available, that player loses immediately [gap-fill]. R8. Draw condition: [gap-fill] A threefold repetition of the identical board position with the same player to move, or 50 consecutive moves without a capture, constitutes an immediate draw. ## Edge cases - Tie at the end condition: Not applicable — win conditions are asymmetric and mutually exclusive (King escape vs. King capture); simultaneous trigger is impossible under alternating turns. - A player with no legal move: Addressed in R7; a player immobilized with zero legal moves immediately loses the game. - Repetition / cycles: Bounded by R8; [gap-fill] threefold repetition rule and 50-move non-capture rule prevent infinite positional cycling. - Simultaneous claims on the same resource or position: Not applicable — turns are strictly sequential and each board square holds at most one piece. - Player elimination mid-round; turn order repair: Not applicable — exactly two players; captured pieces are removed from the board but player roles persist until terminal state. - Resource exhaustion: Pieces are finite (24 attackers, 12 defenders, 1 King) and monotonically non-increasing via non-reversible captures; board space is fixed at 121 squares. - Termination guarantee: Guaranteed by the finite state space combined with the 50-move non-capture and threefold-repetition draw rules (R8). ## State representation - Persistent state: - `board`: 11x11 array where each cell is `{EMPTY, KING, DEFENDER, ATTACKER}`. - `turn`: `{ATTACKERS, DEFENDERS}`. - `move_count_without_capture`: integer counter reset on any capture. - `position_history`: multiset of hashed board states for repetition detection. - Per-turn ephemeral state: - `selected_piece`: coordinate `(x, y)`. - `destination`: coordinate `(x', y')`. - `captured_pieces`: list of coordinates removed during custodial resolution. - Observable information: - Complete information; entire board state, move history, and turn counter are fully observable by both agents. ## Action space - `move(from_pos, to_pos)`: - Preconditions: 1. `turn` matches piece owner at `from_pos`. 2. `from_pos` and `to_pos` share identical row or column (orthogonal path). 3. All intervening squares between `from_pos` and `to_pos` are `EMPTY` (or empty throne passed through per R4). 4. `to_pos` is `EMPTY`. 5. If piece is not `KING`, `to_pos` is not a corner refuge or the central throne. ## Playability notes - Single-player-vs-AI: Natural — standard adversarial minimax/MCTS game tree search applies directly. - Group games (n>4): Not applicable — strictly a 1v1 asymmetric duel. - Physical-skill games: Not applicable — pure discrete abstract strategy. - What is lost in the adaptation: None; the discrete board geometry and saga-attested capture rules are preserved with 100% fidelity. ## Implementation hints - Board state can be encoded efficiently using bitboards (four 128-bit masks: attackers, defenders, king, special squares). - Branching factor averages 20–40 legal moves per turn in early/mid game. - Suggested first milestone: implement board setup, orthogonal move validation, custodial capture check against corners/throne, and corner escape detection.

Download as JSON

Download the full game corpus entry for this game as structured JSON.

Download JSON
Cite this page

Hnefatafl (Iceland). (n.d.). Games of Countries. https://gamesofcountries.com/games/is-iceland/hnefatafl

@misc{gamesofcountries-is-iceland-hnefatafl,
  title = {Hnefatafl (Iceland)},
  year = {n.d.},
  publisher = {Games of Countries},
  url = {https://gamesofcountries.com/games/is-iceland/hnefatafl}
}