Add President and Golf

Two more games on the existing framework — no changes were needed to the
lobby, networking, settings or update layers, which is what the shared
GameRules/GameAi contract was for.

President
- Threes low, twos high. Lead any number of one rank; follow with the
  same count of a higher rank, or pass. When everyone has passed the
  pile comes down and the last player to play leads again.
- Toggles: player count, rounds, twos clear the pile, four of a kind
  bombs, and the between-round card exchange.
- Plays are offered as whole sets rather than by selecting cards. A set
  is the unit of the game, so choosing from the legal sets is both
  easier to operate and impossible to get wrong.

Golf
- 4, 6 or 9 card grids. Draw from stock or discard, then either swap the
  card in or — only if it came off the stock — throw it and turn one of
  your own over. A card taken from the discard pile has to be used.
- Matching columns cancel to nothing; on the 3x3 board rows do too, but
  not on the shallower grids where three cards are not a line.
- Face-down cards are hidden from everyone including their owner, which
  is the point of the game: viewFor masks them with a fixed placeholder
  so the real card never reaches the device that has not turned it over.

Both engines are pure Kotlin and unit tested — 71 tests now, covering
ranking, legal moves, pile and hole resolution, scoring, redaction, wire
round-trips, and full random and AI playthroughs. The Golf test also
checks the AI actually beats random play rather than merely being legal.

Also widened the setup screen's option chips to wrap: the reveal-count
row carries up to ten, and a chip off the edge of the screen is a
setting that cannot be changed — the same failure as the Euchre Pass
button.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015qjfMiPUDshdKEUa6vxqzN
This commit is contained in:
Claude
2026-08-06 03:25:09 +00:00
parent b49bfc0fe6
commit 532c3ea48a
17 changed files with 2590 additions and 8 deletions
+68
View File
@@ -0,0 +1,68 @@
# Golf — implemented rules
This is the ruleset the engine enforces. Anything marked **toggle** is in the
game setup screen. Lowest score wins, as on a golf course.
## Table
- 2 to 6 players — **toggle**.
- Each player gets a grid of face-down cards — **toggle**:
| Cards | Layout |
| --- | --- |
| 4 | 2 rows of 2 |
| 6 | 2 rows of 3 |
| 9 | 3 rows of 3 |
- **Seen at the start — *toggle*.** How many of your own cards you may look at
before play begins; two by default. They are the leftmost cards of the top
row, so everyone starts with the same shape of knowledge.
- One card is turned up to start the discard pile; the rest is the stock.
- Six players on the 9-card board needs more cards than a deck holds, so two
decks are shuffled together whenever the deal would exceed 24 cards.
## A turn
**Draw** one card, from either the stock or the top of the discard pile.
Then **place** it, in one of two ways:
- **Swap it in.** Put it into any grid slot, face up, and throw out whatever was
there. That slot is now face up for the rest of the hole.
- **Throw it away and turn one of your own over.** Only available for a card
taken from the *stock* — a card picked up off the discard pile has to be used.
## Ending a hole
The first player to have their whole grid face up closes the hole, and everyone
else gets exactly one more turn. Then every card is turned up and scored.
If the stock runs out it is refilled by shuffling the discard pile, keeping its
top card in play. If there is nothing left to recycle, the hole ends there.
## Scoring
| Card | Value |
| --- | --- |
| King | 0 |
| Ace | 1 |
| Two | −2 |
| Jack, Queen | 10 |
| 3 to 10 | face value |
**A column of matching ranks cancels to nothing.** That is the whole tactical
point: a pair of jacks in a column costs nothing instead of twenty.
On the 3×3 board, matching **rows** cancel as well. On the shallower boards they
do not — a "row" of three unrelated cards is not a line in a two-row grid.
Scores accumulate over the holes — **toggle** for 3, 6 or 9 — and the lowest
total wins.
## Known simplifications
- **No jokers.** Some house rules add them as −5 or wild. Adding a joker means
adding a rank to the shared card model, which every other game would then have
to account for, so it is left out rather than bolted on.
- No knocking, and no separate penalty for a failed knock.
- Nothing is peeked at mid-hole; the only way to learn a card is to turn it over.
+69
View File
@@ -0,0 +1,69 @@
# President — implemented rules
Also called Scum, Landlord, and a good deal worse. This is the ruleset the
engine enforces. Anything marked **toggle** is in the game setup screen.
## Table
- 3 to 7 players — **toggle**. Everyone plays for themselves.
- The whole 52-card deck is dealt out round-robin, so hands differ by at most
one card. There is no kitty and nothing is held back.
## Ranking
Threes are low and twos are high:
```
3 4 5 6 7 8 9 10 J Q K A 2
```
Suits are irrelevant. A card only ever competes on rank.
## Play
The player holding the lowest card leads the first round; afterwards the
previous round's Scum leads.
- **Leading.** Play any number of cards of the same rank — a single, a pair, a
triple, four of a kind. That count sets the size of the set for this pile.
- **Following.** Play the same number of cards, all of one rank, of a strictly
higher rank. Or pass.
- Passing does not put you out of the round, only out of this pile.
- When everyone still holding cards has passed, the pile is taken down and
whoever played last leads a fresh one.
**Twos clear the pile — *toggle*, on by default.** A set of twos beats anything
regardless of rank, takes the pile down, and the player who threw it leads
again.
**Four of a kind bombs — *toggle*, off by default.** Four matching cards beat
anything, whatever is on the pile, and clear it the same way.
## Going out
Shed your last card and you are out, taking the next free finishing position:
President first, then Vice President, down through the Citizens to Vice Scum and
Scum. The round ends when only one player still holds cards — they are the Scum.
Going out on a pile-clearing set does not let you lead the next pile; the lead
passes to the next player still in.
## Scoring
Finishing position scores `playerCount - 1 - position`, so in a four-hand game
the President takes 3, the Vice President 2, Vice Scum 1 and the Scum nothing.
Highest total after the last round wins — **toggle** for 3, 5 or 7 rounds.
## Card exchange — *toggle*, on by default
Between rounds the Scum hands their two best cards to the President, and the
President hands two of their worst back.
**Simplification:** the President's return is automatic — their two lowest
cards. The fuller rule lets the President choose which two to give back, which
would need a phase of its own; that is not implemented.
## Known simplifications
- No eights-stop, no revolution, no jokers, no suit-based tie-breaks.
- The exchange is always two cards, rather than scaling with position.