Codemojex · C2.1
Room as template and mode.
A room is a template and a container. When the first player joins a waiting room, start_game/3 mints a GAM, resolves four policies from the room’s type and golden marker, snapshots everything onto the game, and starts the timer. The mode is not a class — it is four values a pure function returns.
Grounding — Codemojex.Rooms.create_room/3 · policies_for/2 · formation/3 · schemas/room.ex.
policies_for/2 return its four columnsThe template
create_room/3create_room/3 mints a ROM and stores the props a game inherits, each with a default:
type—"classic", the engine discriminator.duration_ms—35 * 3_600 * 1000, the timer length.seed_pool—0, diamonds seeded into the prize pool.guess_fee1·freefalse·clip_cost1.payout_split—[40, 25, 15, 12, 8], the sealed-split rank weights.cell_count—nil(the full keyboard) or an integer (a reduced golden subset).golden—false, the Golden Room tournament marker.
A room holds status: :waiting and at most one active game. The changeset guards golden ⇒ not free (validate_buy_in_not_free, R11): a real-money buy-in room cannot also be free, because a buy-in spends keys and a free room only clips — the two currency rails never cross.
The four policies
policies_for/2The mode is a pure function of the type and the golden marker. Three clauses cover the three configurations; the returned map is snapshotted onto the game, so a game stays self-describing for settlement and replay. Read the middle column: scoring is "linear" in every clause — the linear law is a constant the function returns, not a claim the course makes.
# type "golden" → blind/sealed (the commit-reveal mode), any marker defp policies_for("golden", _golden), do: %{feedback: "none", scoring: "linear", settlement: "sealed", economy: "winner_take_all"} # type "classic", golden → the live top-K tournament (cm.5 R6) defp policies_for(_classic, true), do: %{feedback: "score", scoring: "linear", settlement: "live_split", economy: "proportional"} # type "classic", ordinary → live winner-take-all defp policies_for(_classic, _ordinary), do: %{feedback: "score", scoring: "linear", settlement: "live", economy: "winner_take_all"}
The two goldens
rooms.exThe word “golden” names two things that share no mechanism. One is a type; the other is a marker on the classic type. create_room/3 notes it in place: a Golden Room is type: "classic" (it fans out live); the blind mode is reached only by an explicit type: "golden".
The blind type and the tournament marker meet again in C4, where sealed, live, and live_split each pay a different way.
References
sources · relatedSources
- Mastermind — the board gamethe code space and feedback function every mode configures
- Commitment schemes — commit and revealthe binding the blind type’s sealed settlement rests on
Related
- C2 — Rooms, Modes, and the Secretthe chapter hub
- C4 — Scoring and Settlementwhere sealed, live, and live_split each pay
- C1 — The Game as Branded SystemsROM and GAM as branded keys