jonnify·codemojex /codemojex/rooms-and-modes/room-as-template-and-mode

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.

The policy resolver — pick a mode; watch policies_for/2 return its four columns
policies_for(type, golden) → %{feedback, scoring, settlement, economy} feedback score scoring linear · the invariant — every mode settlement live economy winner_take_all
classic (ordinary) → feedback score, settlement live, economy winner_take_all. A perfect crack or the timer closes it and the top scorer takes the pool. scoring is linear.
§1

The template

create_room/3

create_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_fee 1 · free false · clip_cost 1.
  • 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.

§2

The four policies

policies_for/2

The 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.

rooms.ex · policies_for/2 source
# 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"}
§3

The two goldens

rooms.ex

The 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".

Same word, two mechanisms — select each to see what sets it apart
the word “golden” → two configurations type: "golden" feedback none · settlement sealed type: "classic" + golden: true feedback score · settlement live_split
the blind golden type → reached only by an explicit type: "golden". It withholds per-guess feedback (none) and settles once over a sealed batch (sealed); the secret is disclosed at close so any player can check it.

The blind type and the tournament marker meet again in C4, where sealed, live, and live_split each pay a different way.

§4

References

sources · related

Sources

Related