Codemojex · C4.1 · a dive of Scoring and Settlement
Distance and points.
A guess is six emojis; a secret is six distinct emojis in positions 0..5. Each guessed emoji that exists in the secret earns points by how far it sits from its home — points = 100 − 20·d for distance d, zero for an emoji absent from the code. That is the whole scoring law: linear only, no tiers, no bonus.
Grounding — echo/apps/codemojex/lib/codemojex/scoring.ex (points/1, distance/2, status/1, scale/0) · the scoring story feature.
points(0) = 100 − 20×0 = 100, status EXACT. The emoji sits in its home position — the maximum a single position earns.The per-position law
scoring.exCodemojex.Scoring is pure — no process, no bus. The scale is one arithmetic clause and a small table of status words. A distance of 5, an emoji as far from home as the six-cell board allows, earns 0 — the same points as an emoji absent from the code. What separates them is the status word, MAX versus MISS, not the points.
def points(:miss), do: 0
def points(d) when is_integer(d) and d >= 0 and d <= 5, do: 100 - 20 * d
def points(_), do: 0
def distance(guess_pos, secret_pos), do: abs(guess_pos - secret_pos)
def status(:miss), do: "MISS"
def status(0), do: "EXACT"
def status(1), do: "ADJACENT"
def status(d) when d in [2, 3], do: "NEAR"
def status(4), do: "FAR"
def status(5), do: "MAX"
def scale, do: for(d <- 0..5, do: {d, points(d), status(d)}) # {0,100,EXACT} .. {5,0,MAX}
Over d = 0..5 the scale is 100, 80, 60, 40, 20, 0. There is no tier ladder and no first-mover bonus: points/1 is the sole score a position can earn, and it is a fixed function of distance.
Distance is symmetric
distance/2Distance is the absolute gap: abs(guess_pos − secret_pos). A guess two cells to the left of an emoji’s home scores exactly what a guess two cells to the right scores — the sign of the miss does not matter, only how far. Below, the emoji’s home is pinned at position 3; move the guess across the board and watch the distance and points fall symmetrically.
distance(0, 3) = abs(0 − 3) = 3, so points(3) = 40, status NEAR. Position 0 is three cells from home.The status words come straight from status/1: 0 is EXACT, 1 ADJACENT, 2 and 3 NEAR, 4 FAR, 5 MAX, and an absent emoji MISS. They are a label for the rules table only — the points, not the word, are what sum to the total.
Purity is load-bearing
the scoring contractBecause distance/2 is abs and points/1 is a fixed arithmetic clause, scoring is a pure function of the secret and the guess. There is no process and no state on the scoring path — the score worker calls Scoring.score/2 once a guess arrives, and nothing it touches can change the answer.
That purity is what makes at-least-once bus delivery harmless. The scoring worker can be handed the same guess twice — a lease expired, a re-delivery — and the second scoring is identical to the first. The scoring story pins it directly: the same secret and guess always score identically. A re-delivered guess re-scores to the same number, so the paid-for attempt is scored once in effect, even across a failure.
The distance math is one code path shared by every game type — classic, blind, or the Golden Room tournament. The type branches what the view exposes per guess and how settlement pays; it never branches the arithmetic. One linear scoring function sits behind the policy switch.
Next — C4.2 sums the six positions into the guess total out of 600 and folds a player’s best into the board.
References
sources · relatedSources
- Mastermind — the board gamethe guess-against-a-hidden-code loop the distance score sits in
- The feedback function and minimax code-breakingthe deductive structure the linear distance scoring approximates
- A Mastermind code-space analysisthe code-space mathematics behind the engine
Related
- C4.2 — The total out of 600the six positions summed
- C2 — Rooms, Modes, and the Secretthe secret the distance is measured against
- C3 — Guesses on Fair Laneshow the guess reaches the scorer