Skip to main content
Formal Specification

Five in a Row (Tic-Tac-Toe on Squared Paper) — Formal Specification

Czechia · board-abstract · Confidence: low

← Back to game page

Implementation Suitability

Suitability: engine-readyFidelity: directGap-fills: 3
# Piškvorky — AI-optimized specification ## General idea A perfect-information, zero-sum abstract strategy game played on a bounded 2D square grid. Two players take strictly alternating turns placing their unique symbol (X and O) on unoccupied intersections/cells. The objective is to achieve an unbroken contiguous orthogonal or diagonal alignment of exactly 5 symbols before the opponent does. ## Formal model - **Abstraction taken:** None required (`fidelity_class: direct`). Traditional rules already constitute a discrete formal board game. - **Player/agent count:** 2 players (P1=X,P2=O). - **Turn model:** Strictly sequential alternating turns. P1 moves first. ## Formal rules R1. Board: A discrete 2D grid B={(r,c)|1≤r≤N,1≤c≤N} where N=15 in standard tournament play (or N=20 in large grid format). Each cell B[r,c]∈{EMPTY,X,O}. All cells are initialized to EMPTY. R2. On turn t, active player Pactive selects one cell (r,c)∈B satisfying B[r,c]==EMPTY. R3. The chosen cell is updated: B[r,c]←Symbol(Pactive). Placed symbols cannot be modified, removed, or relocated. R4. Victory Check: After placing a symbol at (r,c), the engine checks all 4 line directions passing through (r,c) (Horizontal, Vertical, Main Diagonal, Anti-Diagonal). - If there exists a contiguous sequence of ≥5 identical symbols of Pactive, Pactive wins immediately, and the game terminates. R5. [gap-fill] Overline Rule: In standard freestyle Czech rules (*volné piškvorky*), a sequence of ≥5 (including 6, 7, etc.) is a valid win. R6. Draw Condition: If all N×N cells are filled (B[r,c]≠EMPTY∀r,c) without either player forming a 5-in-a-row, the game terminates in a draw. R7. [gap-fill] Move Timer: In competitive agent play, an agent must submit an action within Tmove=5.0 seconds. If the timer expires without a move, the active player forfeits by timeout. R8. [gap-fill] Opening Protocol: In competitive matches, Swap2 opening protocol is applied to eliminate first-player theoretical winning advantage: P1 places 3 stones; P2 chooses to play White, play Black, or place 2 more stones and let P1 choose color. ## Edge cases - Tie at the end condition: The game terminates in a draw if and only if all N×N grid cells are filled with no winning line achieved. - A player with no legal move: If all cells are filled, R6 triggers a draw immediately; otherwise, there exists at least one legal EMPTY cell. - Repetition / cycles: Impossible by construction; each turn monotonically strictly reduces the count of EMPTY cells from N2 down toward 0. - Simultaneous claims on the same resource or position: Turns are strictly alternating and sequential; cell legality requires B[r,c]==EMPTY. - Player elimination mid-round: Not applicable; 2-player zero-sum game ending on first win, draw, or forfeit. - Resource exhaustion: Monotonically bounded by the N×N grid capacity. - Termination guarantee: Trivially guaranteed since the game lasts at most N2 moves (at most 225 moves on a 15×15 board). ## State representation - Persistent state: Grid dimension N (default 15), active opening variant (Freestyle / Swap2). - Per-turn ephemeral state: Board matrix B∈{0,1,2}N×N, active player index ∈{1,2}, move history list [(r1,c1),(r2,c2),…], move count t∈[1,N2]. - Observable information: Full information game. Both players have complete, instantaneous visibility of the entire board state and move history. ## Action space - `place(r, c)`: Place symbol at coordinate (r,c), where 1≤r,c≤N, with precondition B[r,c]==EMPTY. ## Playability notes - Single-player-vs-AI: Fully natural and standard. Minimax with alpha-beta pruning, threat-space search (VCF / VCT algorithms), or Monte Carlo Tree Search (MCTS) provide superhuman benchmark AI. - Group games (n>4): Not applicable; strictly a 2-player abstract game. Multi-player formats run as standard Swiss or double-elimination tournament brackets. - Physical-skill games: Purely cognitive/combinatorial abstract game; zero physical skill abstraction needed. - What is lost: The tactile experience of drawing crosses and circles in blue and red ink in the margins of a paper notebook. ## Implementation hints Branching factor starts at N2=225 on move 1 and decreases by 1 each turn. Strategic branching can be pruned dramatically by evaluating only candidate moves adjacent (within Chebyshev distance 2) to existing stones. Efficient line evaluation using bitboards or incremental direction array counters yields millions of nodes per second in alpha-beta engines. First milestone: implement 15×15 board state, legal move validation, incremental 5-in-a-row victory detection, and basic greedy heuristic AI.

Download as JSON

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

Download JSON
Cite this page

Piškvorky (Czechia). (n.d.). Games of Countries. https://gamesofcountries.com/games/cz-czechia/piskvorky

@misc{gamesofcountries-cz-czechia-piskvorky,
  title = {Piškvorky (Czechia)},
  year = {n.d.},
  publisher = {Games of Countries},
  url = {https://gamesofcountries.com/games/cz-czechia/piskvorky}
}