Formal Specification
Mandarin Square Capturing / Mandarin Board Game — Formal Specification
Vietnam · board-abstract · Confidence: low
← Back to game pageImplementation 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: .
- Mandarin Castle East: (index 6).
- Player 2 citizen cells: (indices 7–11).
- Mandarin Castle West: (index 0).
- Setup: 5 common stones in each citizen cell (50 total); 1 large mandarin stone in and 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 .
R2. Turn Initiation and Starvation Rule:
- On player 's turn, player checks their 5 citizen cells.
- If all 5 cells on player 's side are empty ():
- [gap-fill] Starvation Refill / Debt Rule: Player must pay 5 stones from their captured pool , placing 1 stone into each of their 5 citizen cells (). If , player borrows stones from player , creating a debt ledger entry to be deducted at end scoring. If both players have insufficient stones, the game ends immediately (R6).
- Player selects any non-empty citizen cell on their side and a direction .
R3. Continuous Sowing Mechanics:
- Player scoops all stones from selected cell (leaving with 0 stones) and holds them in hand .
- Player deposits stones one by one into consecutive adjacent cells along direction .
- [gap-fill] Sowing into Mandarin Castles: Sowing deposits stones into mandarin castles () identically to citizen cells.
R4. Turn Continuation and Capture Cascade:
- Let be the cell where the final stone of hand was dropped.
- Let and .
- **Case A (Continue Sowing):** If is a citizen cell and contains stones:
- Player scoops all stones from into and resumes sowing along direction .
- **Case B (Capture):** If is EMPTY () and contains stones:
- Player captures all stones in and adds them to their score . becomes 0.
- **Cascade Check:** If is EMPTY and 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 is EMPTY and is also EMPTY (two consecutive empty cells), or if 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 ( and ) are completely empty of all stones.
- Upon termination, any remaining common stones in citizen cells are awarded to Player 1 (), and stones in are awarded to Player 2 ().
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: .
- The player with the higher 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 (where 0 and 6 are castles).
- `mandarin_present`: array of 2 booleans tracking whether 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 .
- Per-round ephemeral state:
- `hand_stones`: integer count of stones currently held during sowing.
- `current_cell`: integer index in .
- Observable information:
- Complete, perfect information observed by both agents at all times.
## Action space
- `sow(cell_index, direction)`: cell_index , direction . Validated against .
## 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 JSONCite 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}
}