Skip to main content
Formal Specification

Mandarin Square Capturing / Mandarin Board Game — Formal Specification

Vietnam · board-abstract · Confidence: low

← Back to game page

Implementation Suitability

Suitability: engine-readyFidelity: directGap-fills: 4
# Ô ăn quan — AI-optimized specification ## General idea Ô ăn quan is Vietnam's iconic two-player mancala board game played on a 12-cell circuit comprising ten citizen squares and two semi-circular "mandarin castles." Players scoop pebbles from their own territory and sow them sequentially around the perimeter, executing continuous multi-lap sowing and cascading captures over vacant-adjacent cells. The game tests long-range forward calculation, arithmetic distribution, and piece starvation management. ## Formal model - **Abstraction taken:** None required; the traditional game is already a fully discrete, deterministic, perfect-information combinatorial board game. - **Player/agent count:** 2 agents (Player 1 and Player 2). - **Turn model:** Strictly alternating sequential turns. ## Formal rules R1. Board and Setup: - Board consists of 12 cells arranged in a closed circuit: - Player 1 citizen cells: c1,c2,c3,c4,c5. - Mandarin Castle East: Q1 (index 6). - Player 2 citizen cells: c6,c7,c8,c9,c10 (indices 7–11). - Mandarin Castle West: Q2 (index 0). - Setup: 5 common stones in each citizen cell (50 total); 1 large mandarin stone in Q1 and Q2 each. - [gap-fill] Mandarin valuation: Each large mandarin stone equals 10 points; each common stone equals 1 point (total points in play = 70). - Scores (captured pools) initialized at S1=0,S2=0. R2. Turn Initiation and Starvation Rule: - On player i's turn, player checks their 5 citizen cells. - If all 5 cells on player i's side are empty (count=0): - [gap-fill] Starvation Refill / Debt Rule: Player i must pay 5 stones from their captured pool Si, placing 1 stone into each of their 5 citizen cells (Si←Si−5). If Si<5, player i borrows (5−Si) stones from player j, creating a debt ledger entry Debti←Debti+(5−Si) to be deducted at end scoring. If both players have insufficient stones, the game ends immediately (R6). - Player i selects any non-empty citizen cell c on their side and a direction d∈{CLOCKWISE,COUNTER_CLOCKWISE}. R3. Continuous Sowing Mechanics: - Player scoops all stones from selected cell c (leaving c with 0 stones) and holds them in hand H. - Player deposits stones one by one into consecutive adjacent cells along direction d. - [gap-fill] Sowing into Mandarin Castles: Sowing deposits stones into mandarin castles (Q1,Q2) identically to citizen cells. R4. Turn Continuation and Capture Cascade: - Let clast be the cell where the final stone of hand H was dropped. - Let cnext=NextCell(clast,d) and cafter=NextCell(cnext,d). - **Case A (Continue Sowing):** If cnext is a citizen cell and contains ≥1 stones: - Player scoops all stones from cnext into H and resumes sowing along direction d. - **Case B (Capture):** If cnext is EMPTY (count=0) and cafter contains ≥1 stones: - Player captures all stones in cafter and adds them to their score Si. cafter becomes 0. - **Cascade Check:** If NextCell(cafter,d) is EMPTY and NextCell(NextCell(cafter,d),d) contains stones, the player captures those stones as well; this cascade repeats indefinitely until the condition fails. Turn ends. - **Case C (Stalemate / Chững):** If cnext is EMPTY and cafter is also EMPTY (two consecutive empty cells), or if cnext is a Mandarin Castle under non-continuation rules: turn ends immediately with zero captures. R5. Game End Condition: - The game terminates as soon as both Mandarin Castles (Q1 and Q2) are completely empty of all stones. - Upon termination, any remaining common stones in citizen cells c1..c5 are awarded to Player 1 (S1←S1+∑), and stones in c6..c10 are awarded to Player 2 (S2←S2+∑). R6. [gap-fill] Move Limit Loop Breaker: - If 100 consecutive turns occur without any piece capture, the game terminates immediately and remaining board pieces are swept to their respective sides. R7. Victory Determination: - Final score: Finali=Si−Debti+Debtj. - The player with the higher Finali wins; equal scores constitute a draw. ## Edge cases - Tie at the end condition: Fully defined in R7; equal final scores produce a draw. - A player with no legal move: Handled by R2 starvation rule; if all citizen cells are empty, player must refill via captured pool or loan before moving. - Repetition / cycles: Bounded by R6 (100-turn no-capture termination rule). - Simultaneous claims on the same resource or position: Not applicable; turns are strictly sequential. - Player elimination mid-round; turn order repair: Not applicable; standard 2-player game. - Resource exhaustion: Total stones are strictly conserved (50 common + 2 mandarins = 70 points); stones move from board to player captured pools. - Termination guarantee: why the game provably ends: Mandarin stones cannot be replenished once captured; clearing both castles ends the game (R5), backed by the R6 100-turn no-capture hard ceiling. ## State representation - Persistent state: - `board`: array of 12 integers representing stone counts in cells [0..11] (where 0 and 6 are castles). - `mandarin_present`: array of 2 booleans tracking whether Q1,Q2 hold their large mandarin pieces. - `score_1`, `score_2`: non-negative integers. - `debt_1`, `debt_2`: non-negative integers. - `active_player`: enum `{PLAYER_1, PLAYER_2}`. - `turns_since_capture`: integer ∈[0,100]. - Per-round ephemeral state: - `hand_stones`: integer count of stones currently held during sowing. - `current_cell`: integer index in [0,11]. - Observable information: - Complete, perfect information observed by both agents at all times. ## Action space - `sow(cell_index, direction)`: cell_index ∈FriendlyCitizenCells, direction ∈{CW,CCW}. Validated against board[cell_index]>0. ## Playability notes - Single-player-vs-AI: Fully natural; perfect-information game easily solved with Minimax, Alpha-Beta pruning, or MCTS engines. - Group games (n>4): Not applicable; traditionally a 2-player game. Regional 3–4 player variants use triangular/square boards with dedicated castles. - Physical-skill games: Not applicable; pure mathematical strategy and distribution. - What is lost in the adaptation: The rhythmic tactile clatter of polished river pebbles dropped one-by-one into dirt hollows. ## Implementation hints - Represent the 12-cell board as a circular array modulo 12. - Ensure the capture cascade (R4 Case B) is implemented with an iterative `while` loop checking alternating empty and occupied cells. - Suggested first milestone: Implement the continuous sowing and cascade capture engine, validating against documented manual sample games.

Download as JSON

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

Download JSON
Cite this page

Mandarin Square Capturing / Mandarin Board Game (Vietnam). (n.d.). Games of Countries. https://gamesofcountries.com/games/vn-vietnam/o-an-quan

@misc{gamesofcountries-vn-vietnam-o-an-quan,
  title = {Mandarin Square Capturing / Mandarin Board Game (Vietnam)},
  year = {n.d.},
  publisher = {Games of Countries},
  url = {https://gamesofcountries.com/games/vn-vietnam/o-an-quan}
}