Formal Specification
Taiwanese Four Color Cards (Yao-gu) — Formal Specification
Taiwan · card · Confidence: low
← Back to game pageImplementation Suitability
Suitability: engine-readyFidelity: directGap-fills: 2
# Si-se-pai — AI-optimized specification
## General idea
A traditional 4-player imperfect-information rummy card game played with a 112-card deck consisting of Chinese Chess pieces printed across four colors (Yellow, Red, Green, White). Players draw, discard, and claim revealed cards via priority interrupts (*Phoe* / triplet or *Chia* / sequence) to assemble complete hands of 21 melded cards and declare victory (*Chhut-hù*).
## Formal model
- **Abstraction taken:** None required for the game logic; fully discrete deck composition, turn structure, meld matching rules, and claim priorities.
- **Player/agent count:** 4 players (indexed ; Player 0 is initial Dealer).
- **Turn model:** Sequential counter-clockwise turn progression, interruptible by out-of-turn claims on discarded/revealed cards (*Phoe* overrides *Chia*).
## Formal rules
R1. **Deck Architecture:**
- 112 cards total: 7 ranks 4 colors 4 identical copies.
- Ranks: `General` (將/帥), `Advisor` (士/仕), `Elephant` (象/相), `Chariot` (車/俥), `Horse` (馬/傌), `Cannon` (砲/包), `Soldier` (卒/兵).
- Colors: `Yellow` (黃), `Red` (紅), `Green` (綠), `White` (白).
R2. **Deal & Stock:**
- Dealer (Player 0) is dealt 21 cards; Players 1, 2, and 3 are dealt 20 cards each.
- The remaining 31 cards form the face-down `draw_pile`.
R3. **Legal Meld Definitions:**
A valid hand consists of 21 cards partitioned into legal meld groups:
1. `Single General`: 1 General of any color.
2. `General Pair`: 2 identical Generals of the same color.
3. `Command Trio` (*Sam-kong*): General + Advisor + Elephant of the exact same color.
4. `War Trio` (*Chhia-bé-pâu*): Chariot + Horse + Cannon of the exact same color.
5. `Same-Color Soldier Set`: 3 or 4 Soldier cards of the identical color.
6. `Four-Color Soldier Set`: Exactly 1 Soldier of each of the 4 colors (Yellow, Red, Green, White).
7. `Triplet` (*Phoe*): 3 identical cards of the same rank and color.
8. `Quartet` (*Khai-kòng*): 4 identical cards of the same rank and color.
R4. **Turn Flow & Discard:**
- Dealer starts with 21 cards and must discard 1 card face-up to `discard_pile`.
- On standard turns, active player draws the top card from `draw_pile` and reveals it face-up to the table.
R5. **Claim Priorities on Revealed / Discarded Cards:**
When a card is exposed, players may claim it in the following strict priority order:
1. **Winning Claim (*Hù* / 胡):** Any player who completes a 21-card legal meld using the exposed card claims it immediately and wins.
2. **Triplet / Quartet Claim (*Phoe* / 碰 or *Kòng* / 槓):** Any player holding a matching pair (or triplet) in hand may claim the card out of turn to expose the meld.
3. **Sequence Claim (*Chia* / 吃):** Only the player immediately next in turn order (counter-clockwise) may claim the card to complete a Command Trio or War Trio.
4. If no claims are made, the active drawing player takes the card into hand and makes a discard, passing the turn.
R6. **Scoring (*Hù-sò͘*):**
- A winning hand must achieve a minimum threshold (default *hù* points).
- Concealed melds score double exposed melds.
- Quartets and General sets provide bonus multipliers.
R7. [gap-fill] **Stock Exhaustion / Draw Game:**
If the `draw_pile` reaches 0 cards without any player completing a winning 21-card hand, the round is declared a scoreless draw (*Lâu-kio̍k* / 流局), and the dealership rotates counter-clockwise.
R8. [gap-fill] **Penalty for False Meld / Illegal Claim:**
A player who erroneously claims *Hù* without a valid 21-card combination incurs an immediate foul penalty paying 20 *hù* points to each opponent.
## Edge cases
- **Tie at the end condition:** If two players simultaneously declare *Hù* on the same discarded card, priority is awarded to the player closest in turn order counter-clockwise from the discarder (*Single Winner Rule*).
- **A player with no legal move:** On their turn, an agent always has the legal action to discard 1 card from hand.
- **Repetition / cycles:** Cycles are impossible because cards are drawn monotonically from the finite 31-card draw pile.
- **Simultaneous claims on the same resource or position:** Priority order is deterministically resolved: (R5).
- **Player elimination mid-round:** Not applicable (4-player round-based scoring with score chips).
- **Resource exhaustion:** `draw_pile` reaches 0 triggering deterministic draw (R7).
- **Termination guarantee:** Guaranteed by finite 112-card deck and strictly non-replenishable 31-card draw pile.
## State representation
- **Persistent state:**
- `player_scores`: array of 4 integers.
- `dealer_idx`: integer in .
- **Per-round state:**
- `hands`: array of 4 card multisets (private to each player).
- `exposed_melds`: array of 4 lists of revealed melds.
- `draw_pile`: ordered list of unrevealed cards (size ).
- `discard_pile`: list of exposed discarded cards.
- `active_player_idx`: integer in .
- `current_revealed_card`: optional card struct.
- **Observable information:** Imperfect information: players observe own hand, all exposed melds, all discards, and remaining stock count. Opponent hands and draw pile order are hidden.
## Action space
- `discard(card_id)`: Discard 1 card from hand (precondition: hand size ).
- `claim_hu()`: Claim current revealed card to declare victory.
- `claim_phoe(pair_card_ids)`: Claim revealed card to form exposed triplet.
- `claim_chia(meld_type, hand_card_ids)`: Claim revealed card to form exposed trio (in-turn next player only).
- `pass_claim()`: Decline to claim the current revealed card.
## Playability notes
- **Single-player-vs-AI:** Highly playable; an AI agent utilizes Information Set Monte Carlo Tree Search (ISMCTS) or Counterfactual Regret Minimization (CFR) to manage hand evaluation, tile probabilities, and discard safety.
- **Group games (n>4):** Strictly formalizes the standard 4-player game.
- **Physical-skill games:** Not applicable (pure discrete card game).
- **What is lost in the adaptation:** Physical snapping sound of stiff waxed cards on table mats and elder banter in Hokkien.
## Implementation hints
- Represent cards as compact 8-bit integers: `(color << 3) | rank`.
- Hand meld partitioning is an exact integer linear programming / dynamic programming problem on card counts.
- Suggested first milestone: Implement hand validator for legal 21-card melds and deck deal/draw loop.
Download as JSON
Download the full game corpus entry for this game as structured JSON.
Download JSONCite this page
Taiwanese Four Color Cards (Yao-gu) (Taiwan). (n.d.). Games of Countries. https://gamesofcountries.com/games/tw-taiwan/si-se-pai
@misc{gamesofcountries-tw-taiwan-si-se-pai,
title = {Taiwanese Four Color Cards (Yao-gu) (Taiwan)},
year = {n.d.},
publisher = {Games of Countries},
url = {https://gamesofcountries.com/games/tw-taiwan/si-se-pai}
}