jonnify·codemojex /codemojex/scoring-and-settlement

Codemojex · chapter C4

Scoring and settlement — linear only.

Distance is the absolute gap between a guessed position and the secret’s; each position earns 100 − 20·d, and the six positions sum to a total out of 600. No tiers, no bonus — the leaderboard ranks the raw best total. Scoring is a pure fold; settlement is a guarded fan-out — a strategy the game selects, closing exactly once behind one SET NX lock.

Grounding — echo/apps/codemojex/lib/codemojex: scoring.ex · economy.ex (top_k_split) · board.ex · game.ex (ScoreWorker, Settle) · rooms.ex · sweep.ex · design §Core flows / §The game as a state machine.

The chapter, end to end — select a stage
C4.1 · distance → points distance |i − j| points 100 − 20·d C4.2 · total → board Σ = /600 six positions board best-of ZSET C4.3 · SET NX → pay SET NX exactly once settle live|seal|split
C4.1 → Scoring.score/2 is pure. Each guessed emoji that exists in the secret earns 100 − 20·d for its distance d, zero for a miss — 100, 80, 60, 40, 20, 0 across distances 0..5. No process, no bus, no state.
§1

Two moves, one chapter

the shape of the work

Scoring is a pure fold. Codemojex.Scoring.score/2 maps a secret and a guess to a per-position breakdown and a total — no process, no bus, no state. The same secret and guess always yield the same number, which is exactly what makes at-least-once delivery harmless: a re-delivered guess re-scores identically. The distance math is one code path shared by every game type; the type branches feedback and settlement, never the arithmetic.

Settlement is a guarded fan-out. Closing a game takes an atomic SET cm:<game>:closed NX; only the caller that wins the lock runs the payout, and it runs one of three strategies chosen by the game’s snapshotted settlement policy — close_live (winner-take-all), close_sealed (reveal and top-K), or close_split (the Golden Room’s live top-K). Purity plus a one-shot lock stand in for a distributed transaction: a racing close, or a re-run, pays identically.

The reconcile: an earlier draft of this chapter described thirty tiers over twenty-point gaps — the first-mover bonus mechanic the engine removed. The design is now linear end to end: “there is no tier ladder and no first-mover bonus; the raw best total is the rank.”

§2

The three dives

hub + 3 dives

Grounding — read on the running code: Codemojex.Scoring (scoring.ex), Codemojex.Board (board.ex), Codemojex.Economy (economy.ex), Codemojex.ScoreWorker / Codemojex.Settle (game.ex), Codemojex.Rooms (rooms.ex), Codemojex.Sweep (sweep.ex), and the scoring · settlement · golden-blind · golden-tournament stories.

§3

References

sources · related

Sources

Related