FAILURE MAP
← Case archive

FA-86201 / Game economy crafting balance / Open access

Gem combining cascade: An exact triple does not combine · case 01

Exactly three gems stay uncombined.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The availability test requires more than three gems.

VERIFIED REPAIR

Restore `min(g[t] // 3, (budget - gold) // price)` at the triple availability step.

Unsuccessful approach: Reading the original counts ignores gems produced by the cascade.

Case contract

gems[t] = count of tier t gems for t = 0..max_tier. Tiers are processed upward: three tier t gems make one tier t+1 gem at a cost of (t+1)*10 gold each, limited by the remaining gold budget; newly made gems can cascade into the next tier. Max-tier gems never combine. Returns [counts, gold_spent].

Why this case matters

Game economies leak or destroy currency when one crafting or pricing rule is off by one boundary, rounding stage or state update; the defect is observable in exact integer outcomes.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(gems, max_tier, budget):
    g = list(gems)
    gold = 0
    for t in range(max_tier):
        price = (t + 1) * 10
        made = min(g[t] // 3 if g[t] > 3 else 0, (budget - gold) // price)
        g[t] -= made * 3
        g[t + 1] += made
        gold += made * price
    return [g, gold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 9, 8, 3], 3, 60], [[0, 4, 10, 3], 50]),
  ('regression triple availability #1', [[4, 2, 0, 3, 6], 4, 201], [[1, 0, 1, 0, 7], 70]),
  ('partial repair boundary #1', [[9, 3, 2], 2, 1000], [[0, 0, 4], 70]),
  ('partial repair boundary #2', [[9, 8, 2, 9], 3, 277], [[0, 2, 2, 10], 120]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('regression triple availability #1', [[4, 2, 0, 3, 6], 4, 201], [[1, 0, 1, 0, 7], 70]),
  ('fault site triple availability #1', [[3, 8, 0], 2, 29], [[0, 9, 0], 10]),
  ('partial repair boundary #1', [[9, 8, 2, 9], 3, 277], [[0, 2, 2, 10], 120]),
  ('partial repair boundary #2', [[8, 2, 0], 2, 83], [[2, 1, 1], 40]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 3], 1, 30], [[0, 4], 10]),
  ('fault site triple availability #2', [[3, 8], 1, 60], [[0, 9], 10]),
  ('partial repair boundary #1', [[8, 2, 0], 2, 83], [[2, 1, 1], 40]),
  ('partial repair boundary #2', [[4, 3, 14, 8, 20], 4, 1000], [[1, 1, 0, 1, 24], 340]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 4, 4, 3], 3, 273], [[0, 2, 2, 4], 60]),
  ('fault site triple availability #2', [[3, 8, 9, 13], 3, 60], [[0, 3, 11, 13], 50]),
  ('partial repair boundary #1', [[8, 4, 4], 2, 153], [[2, 0, 6], 60]),
  ('regression triple availability #1', [[9, 0, 2], 2, 199], [[0, 0, 3], 50]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[27, 2, 2], 2, 60], [[9, 8, 2], 60])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[2, 3, 9], 2, 30], [[2, 0, 10], 20]),
  ('fault site triple availability #2', [[2, 0, 3, 3, 8], 4, 1000], [[2, 0, 0, 1, 9], 70]),
  ('partial repair boundary #1', [[0, 9, 9, 8], 3, 1000], [[0, 0, 0, 12], 180]),
  ('regression triple availability #1', [[3, 8, 3, 12], 3, 1000], [[0, 0, 0, 14], 130]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[9, 28, 24], 2, 10], [[6, 29, 24], 10])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
two level cascade #1[[0, 3, 0], 30][[0, 0, 1], 50]Failed
fault site triple availability #1[[3, 0, 11, 3], 60][[0, 4, 10, 3], 50]Failed
regression triple availability #1[[1, 3, 0, 3, 6], 10][[1, 0, 1, 0, 7], 70]Failed
partial repair boundary #1[[0, 0, 4], 70][[0, 0, 4], 70]Passed
partial repair boundary #2[[0, 2, 2, 10], 120][[0, 2, 2, 10], 120]Passed
budget stops second tier #1[[0, 4, 0], 30][[0, 4, 0], 30]Passed
max tier untouched #1[[0, 6], 0][[0, 6], 0]Passed
control #1[[1, 5, 3, 3, 9], 10][[1, 5, 3, 3, 9], 10]Passed

SHA-256 / 1afc42366d024d3441112fa3f869a5db6fe3f4dbc60bd86cc284fe3cfafcde8c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(gems, max_tier, budget):
    g = list(gems)
    gold = 0
    for t in range(max_tier):
        price = (t + 1) * 10
        made = min(gems[t] // 3, (budget - gold) // price)
        g[t] -= made * 3
        g[t + 1] += made
        gold += made * price
    return [g, gold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 9, 8, 3], 3, 60], [[0, 4, 10, 3], 50]),
  ('regression triple availability #1', [[4, 2, 0, 3, 6], 4, 201], [[1, 0, 1, 0, 7], 70]),
  ('partial repair boundary #1', [[9, 3, 2], 2, 1000], [[0, 0, 4], 70]),
  ('partial repair boundary #2', [[9, 8, 2, 9], 3, 277], [[0, 2, 2, 10], 120]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('regression triple availability #1', [[4, 2, 0, 3, 6], 4, 201], [[1, 0, 1, 0, 7], 70]),
  ('fault site triple availability #1', [[3, 8, 0], 2, 29], [[0, 9, 0], 10]),
  ('partial repair boundary #1', [[9, 8, 2, 9], 3, 277], [[0, 2, 2, 10], 120]),
  ('partial repair boundary #2', [[8, 2, 0], 2, 83], [[2, 1, 1], 40]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 3], 1, 30], [[0, 4], 10]),
  ('fault site triple availability #2', [[3, 8], 1, 60], [[0, 9], 10]),
  ('partial repair boundary #1', [[8, 2, 0], 2, 83], [[2, 1, 1], 40]),
  ('partial repair boundary #2', [[4, 3, 14, 8, 20], 4, 1000], [[1, 1, 0, 1, 24], 340]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 4, 4, 3], 3, 273], [[0, 2, 2, 4], 60]),
  ('fault site triple availability #2', [[3, 8, 9, 13], 3, 60], [[0, 3, 11, 13], 50]),
  ('partial repair boundary #1', [[8, 4, 4], 2, 153], [[2, 0, 6], 60]),
  ('regression triple availability #1', [[9, 0, 2], 2, 199], [[0, 0, 3], 50]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[27, 2, 2], 2, 60], [[9, 8, 2], 60])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[2, 3, 9], 2, 30], [[2, 0, 10], 20]),
  ('fault site triple availability #2', [[2, 0, 3, 3, 8], 4, 1000], [[2, 0, 0, 1, 9], 70]),
  ('partial repair boundary #1', [[0, 9, 9, 8], 3, 1000], [[0, 0, 0, 12], 180]),
  ('regression triple availability #1', [[3, 8, 3, 12], 3, 1000], [[0, 0, 0, 14], 130]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[9, 28, 24], 2, 10], [[6, 29, 24], 10])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
two level cascade #1[[0, 3, 0], 30][[0, 0, 1], 50]Failed
fault site triple availability #1[[0, 4, 10, 3], 50][[0, 4, 10, 3], 50]Passed
regression triple availability #1[[1, 3, 0, 0, 7], 50][[1, 0, 1, 0, 7], 70]Failed
partial repair boundary #1[[0, 3, 3], 50][[0, 0, 4], 70]Failed
partial repair boundary #2[[0, 5, 4, 9], 70][[0, 2, 2, 10], 120]Failed
budget stops second tier #1[[0, 4, 0], 30][[0, 4, 0], 30]Passed
max tier untouched #1[[0, 6], 0][[0, 6], 0]Passed
control #1[[1, 5, 3, 3, 9], 10][[1, 5, 3, 3, 9], 10]Passed

SHA-256 / 6e7e41542f7250d72c6f2c8030198629712398af07cd4b605fc65836778e6b1c

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(gems, max_tier, budget):
    g = list(gems)
    gold = 0
    for t in range(max_tier):
        price = (t + 1) * 10
        made = min(g[t] // 3, (budget - gold) // price)
        g[t] -= made * 3
        g[t + 1] += made
        gold += made * price
    return [g, gold]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 9, 8, 3], 3, 60], [[0, 4, 10, 3], 50]),
  ('regression triple availability #1', [[4, 2, 0, 3, 6], 4, 201], [[1, 0, 1, 0, 7], 70]),
  ('partial repair boundary #1', [[9, 3, 2], 2, 1000], [[0, 0, 4], 70]),
  ('partial repair boundary #2', [[9, 8, 2, 9], 3, 277], [[0, 2, 2, 10], 120]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('regression triple availability #1', [[4, 2, 0, 3, 6], 4, 201], [[1, 0, 1, 0, 7], 70]),
  ('fault site triple availability #1', [[3, 8, 0], 2, 29], [[0, 9, 0], 10]),
  ('partial repair boundary #1', [[9, 8, 2, 9], 3, 277], [[0, 2, 2, 10], 120]),
  ('partial repair boundary #2', [[8, 2, 0], 2, 83], [[2, 1, 1], 40]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 3], 1, 30], [[0, 4], 10]),
  ('fault site triple availability #2', [[3, 8], 1, 60], [[0, 9], 10]),
  ('partial repair boundary #1', [[8, 2, 0], 2, 83], [[2, 1, 1], 40]),
  ('partial repair boundary #2', [[4, 3, 14, 8, 20], 4, 1000], [[1, 1, 0, 1, 24], 340]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[4, 4, 3, 3, 9], 4, 29], [[1, 5, 3, 3, 9], 10])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[3, 4, 4, 3], 3, 273], [[0, 2, 2, 4], 60]),
  ('fault site triple availability #2', [[3, 8, 9, 13], 3, 60], [[0, 3, 11, 13], 50]),
  ('partial repair boundary #1', [[8, 4, 4], 2, 153], [[2, 0, 6], 60]),
  ('regression triple availability #1', [[9, 0, 2], 2, 199], [[0, 0, 3], 50]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[27, 2, 2], 2, 60], [[9, 8, 2], 60])],
 [('two level cascade #1', [[9, 0, 0], 2, 1000], [[0, 0, 1], 50]),
  ('fault site triple availability #1', [[2, 3, 9], 2, 30], [[2, 0, 10], 20]),
  ('fault site triple availability #2', [[2, 0, 3, 3, 8], 4, 1000], [[2, 0, 0, 1, 9], 70]),
  ('partial repair boundary #1', [[0, 9, 9, 8], 3, 1000], [[0, 0, 0, 12], 180]),
  ('regression triple availability #1', [[3, 8, 3, 12], 3, 1000], [[0, 0, 0, 14], 130]),
  ('budget stops second tier #1', [[9, 1, 0], 2, 30], [[0, 4, 0], 30]),
  ('max tier untouched #1', [[0, 6], 1, 1000], [[0, 6], 0]),
  ('control #1', [[9, 28, 24], 2, 10], [[6, 29, 24], 10])]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
two level cascade #1[[0, 0, 1], 50][[0, 0, 1], 50]Passed
fault site triple availability #1[[0, 4, 10, 3], 50][[0, 4, 10, 3], 50]Passed
regression triple availability #1[[1, 0, 1, 0, 7], 70][[1, 0, 1, 0, 7], 70]Passed
partial repair boundary #1[[0, 0, 4], 70][[0, 0, 4], 70]Passed
partial repair boundary #2[[0, 2, 2, 10], 120][[0, 2, 2, 10], 120]Passed
budget stops second tier #1[[0, 4, 0], 30][[0, 4, 0], 30]Passed
max tier untouched #1[[0, 6], 0][[0, 6], 0]Passed
control #1[[1, 5, 3, 3, 9], 10][[1, 5, 3, 3, 9], 10]Passed

SHA-256 / 66e9f529649aafa926956234ce601d2009f382fca8cad2d4b2326fb71d213ac0

Verification & scope

Deterministic toy contract stipulated for this model; integer or exact arithmetic only, not a reproduction of any specific game engine. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:50:47.418766+00:00.

Case digest / 63f7059f023fb192adbe79e9c0099e9723516d7a14d430c696417e74bef3cda1