Codemojex · dive C0.1
The game and the family — the feedback function.
A game hides a secret of six emoji drawn from a themed set; a player submits a
six-code sequence and the game reports how close it was. That loop places Codemojex in the
Mastermind family, whose defining element is the feedback function — what a guess reveals
about the secret — over a code space of positions and symbols. The three modes fork precisely
there: classic returns a per-guess score, the blind golden type returns nothing until the
reveal, and a Golden Room is a live tournament on the classic base.
Pick a position of the guess below — the readout compares its code to the secret’s code at that position. the report shows what the game returns.
XXYY — column then row, two
digits each): p0, p3, p5 hold the secret’s code; p1 and p2 carry each other’s; p4’s code is not in the secret.
Source: Codemojex.EmojiSet · Codemojex.Guesses.submit/3.p0 — guess 0100 · secret 0100. The same code at the same position — this position holds. The one report a classic guess returns rises with every position that holds.
A secret of six, a guess of six
game.ex · emoji_set.exThe play is a code space: six positions, each holding one code from the game’s keyboard. The secret and every guess live in that space, so one validation and one comparison cover the whole family.
Every game snapshots a keyboard when its first player joins: the room’s
emoji set — the full keyboard, or a fresh random subset when the room sets cell_count — becomes the
game’s cell_codes. A code is XXYY — column then row, two digits each — addressing one
cell of the sprite sheet (Codemojex.EmojiSet). The code space of the play is those codes over six positions.
The secret is drawn from the same snapshot:
EmojiSet.secret_from(cell_codes) takes six distinct codes from the game’s keyboard
(@code_length 6), and Codemojex.Rooms mints the game as a branded GAM around it.
The keyboard the player taps and the secret the player chases index the same cells — no guess can name a symbol the
secret could not contain.
A guess is exactly six codes, enforced at the function head —
Codemojex.Guesses.submit(game, player, emojis) when length(emojis) == 6 — and every code must be one of
the game’s cell_codes. Anything that is not a valid six-element guess falls to the catch-all
submit/3 clause and answers {:error, :bad_guess}. The acceptance catalog pins the accepted
path: a guess submitted on the lane is scored and reaches the leaderboard (rooms-and-games.stories.md).
Grounding — lib/codemojex/game.ex (Codemojex.Guesses.submit/3: the
when length(emojis) == 6 guard, the {:error, :bad_guess} fall-through) ·
lib/codemojex/emoji_set.ex (secret_from/1, @code_length 6, the XXYY
code shape) · stories/rooms-and-games.stories.md.
The feedback function
Codemojex.ScoreWorkerWhat a guess reveals about the secret is the defining element of the family — fix the code space and the feedback function, and the game is fixed.
The Mastermind board game set the loop in the early 1970s: a codemaker hides a code, a codebreaker probes it, and every guess is answered by a report. The family that grew around it varies the number of positions, the symbol alphabet, and — the defining element — the feedback function: what a guess reveals. The board game’s pegs are one choice of feedback; a numeric score is another; silence until the end is a third.
In Codemojex, one authority computes the report.
Codemojex.ScoreWorker — “the scoring consumer — the authority” — drains the guess
queue and scores every guess with Scoring.score(secret, emojis), writing the guess as a branded
GES with its points, keyed to the PLR whose lane carried it. The host that accepted the guess
never scores; the consumer does.
The six position comparisons fold into one report per guess. For a classic
game the worker publishes it as a scored event, and the report is thin — a name and a percentage, not
the positions that matched nor the codes that slipped. The distance-to-points law behind the number
(100 − 20·d per position, summing to 600) is C4’s
ground; this dive stays with what a guess reveals, and to whom.
The report is also stable. The same secret and guess always score identically
— a re-delivered guess is safe (scoring.stories.md) — so the feedback function is a pure function
of the pair, which is what lets a queue-fed consumer be the single authority over it.
Grounding — Codemojex.ScoreWorker in lib/codemojex/game.ex (the
authority; Scoring.score(secret, emojis); the classic scored publish) ·
stories/scoring.stories.md (six scenarios; the purity law).
One family, three feedback policies
rooms.ex · policies_for/2The three modes are one engine under three policy sets, and the feedback policy is where the family forks.
The fork is a pure lookup: Codemojex.Rooms.policies_for/2 maps
the game’s type — plus the tournament marker — to its four policies, snapshotted onto the GAM
at start. The feedback values state the family membership in one word each: feedback: "score" for
type:"classic", ordinary room and Golden-Room tournament alike; feedback: "none" for the blind
type:"golden".
"score" a scored event follows every guess; under "none" the return lane stays
empty until the close’s one revealed event. Source: Codemojex.Rooms.policies_for/2.feedback: "score" — the classic policy, worn by the ordinary room and the Golden-Room tournament alike. The worker scores the guess, writes the GES, and publishes a scored event — every guess returns a report while the game runs.
The blind contract is exact. A golden game “stores the guess but emits
NO per-guess feedback (the blind contract): the score is sealed until reveal”
(Codemojex.ScoreWorker). The score exists server-side from the moment the worker runs; no scored
push fires in-flight, and the player’s own history withholds points (golden-blind.stories.md). At close
the sealed pass emits one revealed event — the now-exposed secret, the final board, the payouts —
“the first and only results a blind client receives”.
A Golden Room is deliberately not a fourth feedback shape. It is a live
tournament on the classic base — type:"classic" with golden:true — so its feedback
stays "score" and the contest plays in the open; what forks there is settlement and economy, C4’s and
C5’s ground. Feedback is policy, not code: a new mode is a new row of values over the same six-position play.
Grounding — lib/codemojex/rooms.ex (policies_for/2; the one
revealed event at the sealed close) · stories/golden-blind.stories.md.
References
sources · relatedSources
- Mastermind — the board gamethe guess-against-a-hidden-code loop Codemojex plays with emoji.
- arXiv 1607.04597 — the feedback function and minimax code-breakingthe deductive structure the family’s play sits in.
Related
- C0 — Overviewthe chapter hub this dive extends.
- BCS B7 — Codemojexthis game taught inside the BCS course.
- BCS — the architecture lawthe identity and systems discipline the game is built to.