Formal Specification
Libyan Secret Code Deduction Card Game — Formal Specification
Libya · guessing-hidden · Confidence: medium
← Back to game pageImplementation Suitability
Suitability: engine-readyFidelity: directGap-fills: 1
# Al-Shefra — AI-optimized specification
## General idea
A real-time card drafting and partner-signaling game. Two teams of 2 agents draft cards from a central pool to assemble 4-of-a-kind. When assembled, an agent transmits a subtle signal to their partner. If the partner calls "Shefra", the team scores; if the opposing team intercepts and calls "Ghadra", the interceptors score double points.
## Formal model
- **Abstraction taken:** Fast-paced simultaneous drafting is modeled in discrete draft rounds. Non-verbal signals are formalized as noisy binary channels with observable signal probabilities `P_signal_leak`.
- **Player/agent count:** 4 agents across 2 teams (Team 0: {0, 2}, Team 1: {1, 3}).
- **Turn model:** Synchronized drafting ticks followed by declaration checks.
## Formal rules
R1. Setup: 40-card deck with ranks `1..10` (4 cards per rank). Each agent starts with 4 random cards. Center pool starts with 4 face-up cards. Team scores `Score_0 = 0`, `Score_1 = 0`.
R2. Drafting Tick:
- Each agent selects an exchange action `swap_card(hand_idx, pool_idx)`.
- Collisions on pool cards are resolved via priority random draw.
- When pool is stale, 4 fresh cards are dealt from deck.
R3. Goal State & Signal Emission:
- If agent `i` holds 4 cards of identical rank (`FourOfAKind == true`), agent executes `emit_signal()`.
- Teammate observes signal with probability `P_partner = 0.90`.
- Each opponent observes the signal leak with probability `P_leak = 0.35`.
R4. Declarations & Resolution:
- Teammate Action: `call_shefra()`. If holding player has 4-of-a-kind, team earns `+1 point`. If not, team loses `1 point`.
- Opponent Action: `call_ghadra(suspected_player)`. If suspected player has 4-of-a-kind, intercepting team earns `+2 points`. If false accusation, interceptor loses `1 point`.
R5. Win Condition: Points accumulate across rounds. First team to reach `TargetScore = 5` points wins.
## Edge cases
- Tie at the end condition: [gap-fill] If both teams reach 5 points simultaneously, play continues until one team leads by >= 1 point.
- A player with no legal move: Not applicable; card swap or pass actions are always valid.
- Repetition / cycles: Bounded strictly by positive point threshold and finite card counts.
- Simultaneous claims on the same resource or position: Pool swap collisions are resolved via uniform tie-breaking.
- Player elimination mid-round; turn order repair: All 4 agents remain active throughout.
- Resource exhaustion: Monotonically increasing score toward 5.
- Termination guarantee: Enforced by positive point accumulation.
## State representation
- Persistent state: `scores: Array[2][int]`, `deck: List[Card]`, `hands: Array[4][List[Card]]`, `pool: List[Card]`.
- Ephemeral state: `active_signals: Array[4][bool]`.
- Observability: Private hands; public central pool; noisy observation of teammate/opponent signal emissions.
## Action space
- `swap_card(hand_idx, pool_idx)`: Exchange a card.
- `emit_signal()`: Transmit code to partner.
- `call_shefra()`: Partner declaration.
- `call_ghadra(target_agent)`: Opponent interception.
## Playability notes
- Single-player-vs-AI: Highly engaging multi-agent hidden communication game.
- Group games (n>4): Extends to 6 players (3 teams of 2).
- Physical-skill games: Peripheral vision and poker faces abstracted into Bayesian detection probabilities.
- What is lost: The hilarity of sudden exaggerated winks and comedic table slams.
## Implementation hints
Discrete card state machine with signal propagation channels. First milestone: implement 4-card drafting and set validation before adding noisy signal detection and call triggers.
Download as JSON
Download the full game corpus entry for this game as structured JSON.
Download JSONCite this page
Libyan Secret Code Deduction Card Game (Libya). (n.d.). Games of Countries. https://gamesofcountries.com/games/ly-libya/al-shefra
@misc{gamesofcountries-ly-libya-al-shefra,
title = {Libyan Secret Code Deduction Card Game (Libya)},
year = {n.d.},
publisher = {Games of Countries},
url = {https://gamesofcountries.com/games/ly-libya/al-shefra}
}