Formal Specification
Rooster Game / Portuguese Three-in-a-Row — Formal Specification
Portugal · board-abstract · Confidence: low
← Back to game pageImplementation Suitability
Suitability: engine-readyFidelity: directGap-fills: 3
# Jogo do Galo — AI-optimized specification
## General idea
A deterministic two-player abstract strategy game played on a 3×3 grid (or 9-node graph with diagonal connections). The game proceeds in two phases: a placement phase where each player places 3 pieces, followed by a sliding movement phase along connected edges until one player aligns 3 pieces in a row.
## Formal model
- **Abstraction taken:** None; formal graph and state transitions match the traditional Portuguese *Galo de Mover* exactly.
- **Player/agent count:** 2 agents (Agent 0 = 'X', Agent 1 = 'O').
- **Turn model:** Strictly sequential, alternating turns.
## Formal rules
R1. Board Graph: `G = (V, E)` where `V = {0..8}` (representing a 3×3 matrix). Edges `E` include all horizontal, vertical, and diagonal connections passing through center node 4.
R2. Phase 1 (Drop Phase, Turns 1..6):
- On turn `t in {1..6}`, active agent places one piece of their symbol on any empty vertex `v in V`.
- If a 3-in-a-row is formed (a straight 3-node path in `G` belonging to the active agent), the active agent wins immediately and the game terminates.
R3. Phase 2 (Move Phase, Turns >= 7):
- Active agent selects one of their 3 pieces at node `u` and moves it to an adjacent empty node `v` such that `(u, v) in E` and `v` is empty.
- If this move forms a 3-in-a-row, the active agent wins immediately.
R4. Win condition: Forming an aligned triplet `{v1, v2, v3}` along any of the 8 winning lines:
- Rows: `{0,1,2}, {3,4,5}, {6,7,8}`
- Columns: `{0,3,6}, {1,4,7}, {2,5,8}`
- Diagonals: `{0,4,8}, {2,4,6}`
R5. Draw conditions:
- Threefold repetition of the complete board position [gap-fill].
- Total Phase 2 move limit reaches 30 half-moves without a win [gap-fill].
- A player on their turn has no legal adjacent move available (stalemate = draw).
## Edge cases
- Tie at the end condition: Evaluated explicitly under R5 (threefold repetition, 30-move limit, or stalemate).
- A player with no legal move: Handled as an immediate draw (stalemate) under R5.
- Repetition / cycles: Handled by the threefold repetition rule and the 30-move hard cap [gap-fill].
- Simultaneous claims on the same resource or position: Not applicable; turns are strictly sequential.
- Player elimination mid-round: Not applicable (2-player full game).
- Resource exhaustion (pieces, tokens, space, time): Move limit strictly guarantees finite execution.
- Termination guarantee: The 30-move cap in Phase 2 guarantees termination in at most 36 total half-moves.
## State representation
- Persistent state: `board: [int; 9]` (-1 = empty, 0 = Agent 0, 1 = Agent 1), `phase: int (1 or 2)`, `turn_count: int`, `history: List`.
- Per-turn ephemeral state: `active_agent: int (0 or 1)`, `legal_moves: List<(int, int)>`.
- Minimal observable information: Fully observable public state (perfect information).
## Action space
- Phase 1 Action: `place(node: int)` where `board[node] == -1`.
- Phase 2 Action: `move(from_node: int, to_node: int)` where `board[from_node] == active_agent`, `board[to_node] == -1`, and `(from_node, to_node) in E`.
## Playability notes
- Single-player-vs-AI: Engine-ready. Solvable via standard Minimax / Alpha-Beta with depth limit 36.
- Group games (n>4): Not applicable; strictly a 2-player abstract.
- Physical-skill games: Direct board logic; zero physical abstraction.
- What is lost in the adaptation: None; 100% formal fidelity to traditional *Galo de Mover*.
## Implementation hints
Extremely compact state. 9-element array representation. Suggested milestone 1: Implement board graph adjacency list, win checker for 8 winning lines, and Phase 1 to Phase 2 transition logic.
Download as JSON
Download the full game corpus entry for this game as structured JSON.
Download JSONCite this page
Jogo do Galo (Portugal). (n.d.). Games of Countries. https://gamesofcountries.com/games/pt-portugal/jogo-do-galo
@misc{gamesofcountries-pt-portugal-jogo-do-galo,
title = {Jogo do Galo (Portugal)},
year = {n.d.},
publisher = {Games of Countries},
url = {https://gamesofcountries.com/games/pt-portugal/jogo-do-galo}
}