FAILURE MAP
← Case archive

FA-86551 / Procedural level generation constraints / Open access

Encounter difficulty budget: Milestone floors add almost nothing · case 01

Every fifth floor is barely harder than the one before.

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

ROOT CAUSE

The milestone bonus is added without its x10 scale.

VERIFIED REPAIR

Restore `10 + 5 * depth + depth // 5 * 10` at the milestone bonus step.

Unsuccessful approach: Multiplying the base budget by milestones explodes deep floors.

Case contract

budget = 10 + 5*depth + 10*(depth//5). roster [name, cost, min_depth] with cost >= 1. Repeatedly pick the most expensive unlocked (min_depth <= depth) affordable enemy with fewer than 3 copies already picked, ties broken by name; stop when none qualifies. Returns {picks, left}.

Why this case matters

Procedural generators silently emit unplayable or unfair levels when a single constraint check uses the wrong boundary, axis, neighborhood or update order; the defect is visible in exact generated geometry.

1 / The failure

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

N = 1
observations = []
def solve(depth, roster):
    budget = 10 + 5 * depth + depth // 5
    counts = {}
    picks = []
    while True:
        best = None
        for name, cost, need in roster:
            if need > depth or cost > budget or counts.get(name, 0) >= 3:
                continue
            if best is None or cost > best[1] or (cost == best[1] and name < best[0]):
                best = (name, cost)
        if best is None:
            break
        picks.append(best[0])
        counts[best[0]] = counts.get(best[0], 0) + 1
        budget -= best[1]
    return {'picks': picks, 'left': budget}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [10, [['imp', 2, 10], ['ogre', 5, 10], ['rat', 1, 3], ['bat', 2, 0], ['orc', 5, 3], ['wyrm', 24, 10]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat'], 'left': 0}),
  ('regression milestone bonus #2', [15, [['ogre', 5, 1]]], {'picks': ['ogre', 'ogre', 'ogre'], 'left': 100}),
  ('regression milestone bonus #3',
   [5, [['orc', 10, 1], ['imp', 5, 10]]],
   {'picks': ['orc', 'orc', 'orc'], 'left': 15}),
  ('regression milestone bonus #4',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1', [15, [['ogre', 5, 1]]], {'picks': ['ogre', 'ogre', 'ogre'], 'left': 100}),
  ('regression milestone bonus #2',
   [5, [['orc', 10, 1], ['imp', 5, 10]]],
   {'picks': ['orc', 'orc', 'orc'], 'left': 15}),
  ('regression milestone bonus #3',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4',
   [9, [['rat', 7, 0], ['ogre', 1, 0]]],
   {'picks': ['rat', 'rat', 'rat', 'ogre', 'ogre', 'ogre'], 'left': 41}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2',
   [9, [['rat', 7, 0], ['ogre', 1, 0]]],
   {'picks': ['rat', 'rat', 'rat', 'ogre', 'ogre', 'ogre'], 'left': 41}),
  ('regression milestone bonus #3',
   [10, [['imp', 15, 10], ['ogre', 5, 1], ['orc', 5, 5], ['rat', 5, 0], ['wyrm', 10, 1]]],
   {'picks': ['imp', 'imp', 'imp', 'wyrm', 'wyrm', 'wyrm', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4',
   [9, [['bat', 26, 5], ['rat', 11, 10], ['ogre', 5, 0], ['imp', 5, 0]]],
   {'picks': ['bat', 'bat', 'imp', 'imp'], 'left': 3}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [10, [['imp', 15, 10], ['ogre', 5, 1], ['orc', 5, 5], ['rat', 5, 0], ['wyrm', 10, 1]]],
   {'picks': ['imp', 'imp', 'imp', 'wyrm', 'wyrm', 'wyrm', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2',
   [9, [['bat', 26, 5], ['rat', 11, 10], ['ogre', 5, 0], ['imp', 5, 0]]],
   {'picks': ['bat', 'bat', 'imp', 'imp'], 'left': 3}),
  ('regression milestone bonus #3',
   [14, [['orc', 30, 1], ['bat', 15, 5], ['ogre', 5, 0], ['rat', 5, 5]]],
   {'picks': ['orc', 'orc', 'orc', 'ogre', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4', [20, [['orc', 2, 5]]], {'picks': ['orc', 'orc', 'orc'], 'left': 144}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1', [1, [['orc', 5, 3], ['bat', 8, 1], ['wyrm', 8, 0]]], {'picks': ['bat'], 'left': 7})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [14, [['orc', 30, 1], ['bat', 15, 5], ['ogre', 5, 0], ['rat', 5, 5]]],
   {'picks': ['orc', 'orc', 'orc', 'ogre', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2', [20, [['orc', 2, 5]]], {'picks': ['orc', 'orc', 'orc'], 'left': 144}),
  ('regression milestone bonus #3',
   [20, [['orc', 5, 5], ['rat', 10, 0], ['ogre', 9, 1], ['imp', 5, 1], ['bat', 5, 3], ['wyrm', 1, 0]]],
   {'picks': ['rat',
              'rat',
              'rat',
              'ogre',
              'ogre',
              'ogre',
              'bat',
              'bat',
              'bat',
              'imp',
              'imp',
              'imp',
              'orc',
              'orc',
              'orc',
              'wyrm',
              'wyrm',
              'wyrm'],
    'left': 45}),
  ('regression milestone bonus #4',
   [9, [['imp', 25, 3], ['bat', 5, 5]]],
   {'picks': ['imp', 'imp', 'bat', 'bat', 'bat'], 'left': 0}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [4, [['rat', 5, 5], ['ogre', 5, 0], ['wyrm', 5, 1], ['imp', 5, 3]]],
   {'picks': ['imp', 'imp', 'imp', 'ogre', 'ogre', 'ogre'], 'left': 0})]]
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
milestone depth bonus #1{'left': 21, 'picks': ['orc', 'orc', 'orc']}{'left': 30, 'picks': ['orc', 'orc', 'orc']}Failed
regression milestone bonus #1{'left': 0, 'picks': ['wyrm', 'wyrm', 'ogre', 'ogre', 'bat', 'bat']}{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat']}Failed
regression milestone bonus #2{'left': 73, 'picks': ['ogre', 'ogre', 'ogre']}{'left': 100, 'picks': ['ogre', 'ogre', 'ogre']}Failed
regression milestone bonus #3{'left': 6, 'picks': ['orc', 'orc', 'orc']}{'left': 15, 'picks': ['orc', 'orc', 'orc']}Failed
regression milestone bonus #4{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'imp', 'imp', 'imp']}{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre']}Failed
unlock at depth #1{'left': 2, 'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat']}{'left': 2, 'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat']}Passed
equal cost tie #1{'left': 0, 'picks': ['imp', 'imp']}{'left': 0, 'picks': ['imp', 'imp']}Passed
control #1{'left': 2, 'picks': ['imp', 'orc', 'orc', 'orc']}{'left': 2, 'picks': ['imp', 'orc', 'orc', 'orc']}Passed

SHA-256 / cd3e9a099fe0d819de27aeb249585ff83021a0e243eb85ad3c108f6454c6322d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(depth, roster):
    budget = (10 + 5 * depth) * (1 + depth // 5)
    counts = {}
    picks = []
    while True:
        best = None
        for name, cost, need in roster:
            if need > depth or cost > budget or counts.get(name, 0) >= 3:
                continue
            if best is None or cost > best[1] or (cost == best[1] and name < best[0]):
                best = (name, cost)
        if best is None:
            break
        picks.append(best[0])
        counts[best[0]] = counts.get(best[0], 0) + 1
        budget -= best[1]
    return {'picks': picks, 'left': budget}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [10, [['imp', 2, 10], ['ogre', 5, 10], ['rat', 1, 3], ['bat', 2, 0], ['orc', 5, 3], ['wyrm', 24, 10]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat'], 'left': 0}),
  ('regression milestone bonus #2', [15, [['ogre', 5, 1]]], {'picks': ['ogre', 'ogre', 'ogre'], 'left': 100}),
  ('regression milestone bonus #3',
   [5, [['orc', 10, 1], ['imp', 5, 10]]],
   {'picks': ['orc', 'orc', 'orc'], 'left': 15}),
  ('regression milestone bonus #4',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1', [15, [['ogre', 5, 1]]], {'picks': ['ogre', 'ogre', 'ogre'], 'left': 100}),
  ('regression milestone bonus #2',
   [5, [['orc', 10, 1], ['imp', 5, 10]]],
   {'picks': ['orc', 'orc', 'orc'], 'left': 15}),
  ('regression milestone bonus #3',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4',
   [9, [['rat', 7, 0], ['ogre', 1, 0]]],
   {'picks': ['rat', 'rat', 'rat', 'ogre', 'ogre', 'ogre'], 'left': 41}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2',
   [9, [['rat', 7, 0], ['ogre', 1, 0]]],
   {'picks': ['rat', 'rat', 'rat', 'ogre', 'ogre', 'ogre'], 'left': 41}),
  ('regression milestone bonus #3',
   [10, [['imp', 15, 10], ['ogre', 5, 1], ['orc', 5, 5], ['rat', 5, 0], ['wyrm', 10, 1]]],
   {'picks': ['imp', 'imp', 'imp', 'wyrm', 'wyrm', 'wyrm', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4',
   [9, [['bat', 26, 5], ['rat', 11, 10], ['ogre', 5, 0], ['imp', 5, 0]]],
   {'picks': ['bat', 'bat', 'imp', 'imp'], 'left': 3}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [10, [['imp', 15, 10], ['ogre', 5, 1], ['orc', 5, 5], ['rat', 5, 0], ['wyrm', 10, 1]]],
   {'picks': ['imp', 'imp', 'imp', 'wyrm', 'wyrm', 'wyrm', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2',
   [9, [['bat', 26, 5], ['rat', 11, 10], ['ogre', 5, 0], ['imp', 5, 0]]],
   {'picks': ['bat', 'bat', 'imp', 'imp'], 'left': 3}),
  ('regression milestone bonus #3',
   [14, [['orc', 30, 1], ['bat', 15, 5], ['ogre', 5, 0], ['rat', 5, 5]]],
   {'picks': ['orc', 'orc', 'orc', 'ogre', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4', [20, [['orc', 2, 5]]], {'picks': ['orc', 'orc', 'orc'], 'left': 144}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1', [1, [['orc', 5, 3], ['bat', 8, 1], ['wyrm', 8, 0]]], {'picks': ['bat'], 'left': 7})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [14, [['orc', 30, 1], ['bat', 15, 5], ['ogre', 5, 0], ['rat', 5, 5]]],
   {'picks': ['orc', 'orc', 'orc', 'ogre', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2', [20, [['orc', 2, 5]]], {'picks': ['orc', 'orc', 'orc'], 'left': 144}),
  ('regression milestone bonus #3',
   [20, [['orc', 5, 5], ['rat', 10, 0], ['ogre', 9, 1], ['imp', 5, 1], ['bat', 5, 3], ['wyrm', 1, 0]]],
   {'picks': ['rat',
              'rat',
              'rat',
              'ogre',
              'ogre',
              'ogre',
              'bat',
              'bat',
              'bat',
              'imp',
              'imp',
              'imp',
              'orc',
              'orc',
              'orc',
              'wyrm',
              'wyrm',
              'wyrm'],
    'left': 45}),
  ('regression milestone bonus #4',
   [9, [['imp', 25, 3], ['bat', 5, 5]]],
   {'picks': ['imp', 'imp', 'bat', 'bat', 'bat'], 'left': 0}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [4, [['rat', 5, 5], ['ogre', 5, 0], ['wyrm', 5, 1], ['imp', 5, 3]]],
   {'picks': ['imp', 'imp', 'imp', 'ogre', 'ogre', 'ogre'], 'left': 0})]]
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
milestone depth bonus #1{'left': 55, 'picks': ['orc', 'orc', 'orc']}{'left': 30, 'picks': ['orc', 'orc', 'orc']}Failed
regression milestone bonus #1{'left': 63, 'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'ogre', 'ogre', 'orc', 'orc', 'orc', 'bat', 'bat', 'bat', 'imp', 'imp', 'imp', 'rat', 'rat', 'rat']}{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat']}Failed
regression milestone bonus #2{'left': 325, 'picks': ['ogre', 'ogre', 'ogre']}{'left': 100, 'picks': ['ogre', 'ogre', 'ogre']}Failed
regression milestone bonus #3{'left': 40, 'picks': ['orc', 'orc', 'orc']}{'left': 15, 'picks': ['orc', 'orc', 'orc']}Failed
regression milestone bonus #4{'left': 4, 'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'bat', 'bat', 'imp', 'imp', 'imp', 'ogre', 'ogre', 'ogre', 'rat', 'rat', 'rat']}{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre']}Failed
unlock at depth #1{'left': 2, 'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat']}{'left': 2, 'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat']}Passed
equal cost tie #1{'left': 0, 'picks': ['imp', 'imp']}{'left': 0, 'picks': ['imp', 'imp']}Passed
control #1{'left': 2, 'picks': ['imp', 'orc', 'orc', 'orc']}{'left': 2, 'picks': ['imp', 'orc', 'orc', 'orc']}Passed

SHA-256 / ce13838d9f1ec42ae3dd8f49675730254fc58fc405d2051b1a25c86c900dc75f

3 / The verified repair

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

N = 1
observations = []
def solve(depth, roster):
    budget = 10 + 5 * depth + depth // 5 * 10
    counts = {}
    picks = []
    while True:
        best = None
        for name, cost, need in roster:
            if need > depth or cost > budget or counts.get(name, 0) >= 3:
                continue
            if best is None or cost > best[1] or (cost == best[1] and name < best[0]):
                best = (name, cost)
        if best is None:
            break
        picks.append(best[0])
        counts[best[0]] = counts.get(best[0], 0) + 1
        budget -= best[1]
    return {'picks': picks, 'left': budget}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [10, [['imp', 2, 10], ['ogre', 5, 10], ['rat', 1, 3], ['bat', 2, 0], ['orc', 5, 3], ['wyrm', 24, 10]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat'], 'left': 0}),
  ('regression milestone bonus #2', [15, [['ogre', 5, 1]]], {'picks': ['ogre', 'ogre', 'ogre'], 'left': 100}),
  ('regression milestone bonus #3',
   [5, [['orc', 10, 1], ['imp', 5, 10]]],
   {'picks': ['orc', 'orc', 'orc'], 'left': 15}),
  ('regression milestone bonus #4',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1', [15, [['ogre', 5, 1]]], {'picks': ['ogre', 'ogre', 'ogre'], 'left': 100}),
  ('regression milestone bonus #2',
   [5, [['orc', 10, 1], ['imp', 5, 10]]],
   {'picks': ['orc', 'orc', 'orc'], 'left': 15}),
  ('regression milestone bonus #3',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4',
   [9, [['rat', 7, 0], ['ogre', 1, 0]]],
   {'picks': ['rat', 'rat', 'rat', 'ogre', 'ogre', 'ogre'], 'left': 41}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [5, [['bat', 8, 1], ['orc', 15, 10], ['wyrm', 10, 1], ['ogre', 1, 3], ['rat', 1, 3], ['imp', 2, 0]]],
   {'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2',
   [9, [['rat', 7, 0], ['ogre', 1, 0]]],
   {'picks': ['rat', 'rat', 'rat', 'ogre', 'ogre', 'ogre'], 'left': 41}),
  ('regression milestone bonus #3',
   [10, [['imp', 15, 10], ['ogre', 5, 1], ['orc', 5, 5], ['rat', 5, 0], ['wyrm', 10, 1]]],
   {'picks': ['imp', 'imp', 'imp', 'wyrm', 'wyrm', 'wyrm', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4',
   [9, [['bat', 26, 5], ['rat', 11, 10], ['ogre', 5, 0], ['imp', 5, 0]]],
   {'picks': ['bat', 'bat', 'imp', 'imp'], 'left': 3}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [1, [['imp', 10, 1], ['bat', 10, 10], ['orc', 1, 0]]],
   {'picks': ['imp', 'orc', 'orc', 'orc'], 'left': 2})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [10, [['imp', 15, 10], ['ogre', 5, 1], ['orc', 5, 5], ['rat', 5, 0], ['wyrm', 10, 1]]],
   {'picks': ['imp', 'imp', 'imp', 'wyrm', 'wyrm', 'wyrm', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2',
   [9, [['bat', 26, 5], ['rat', 11, 10], ['ogre', 5, 0], ['imp', 5, 0]]],
   {'picks': ['bat', 'bat', 'imp', 'imp'], 'left': 3}),
  ('regression milestone bonus #3',
   [14, [['orc', 30, 1], ['bat', 15, 5], ['ogre', 5, 0], ['rat', 5, 5]]],
   {'picks': ['orc', 'orc', 'orc', 'ogre', 'ogre'], 'left': 0}),
  ('regression milestone bonus #4', [20, [['orc', 2, 5]]], {'picks': ['orc', 'orc', 'orc'], 'left': 144}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1', [1, [['orc', 5, 3], ['bat', 8, 1], ['wyrm', 8, 0]]], {'picks': ['bat'], 'left': 7})],
 [('milestone depth bonus #1', [5, [['orc', 5, 0]]], {'picks': ['orc', 'orc', 'orc'], 'left': 30}),
  ('regression milestone bonus #1',
   [14, [['orc', 30, 1], ['bat', 15, 5], ['ogre', 5, 0], ['rat', 5, 5]]],
   {'picks': ['orc', 'orc', 'orc', 'ogre', 'ogre'], 'left': 0}),
  ('regression milestone bonus #2', [20, [['orc', 2, 5]]], {'picks': ['orc', 'orc', 'orc'], 'left': 144}),
  ('regression milestone bonus #3',
   [20, [['orc', 5, 5], ['rat', 10, 0], ['ogre', 9, 1], ['imp', 5, 1], ['bat', 5, 3], ['wyrm', 1, 0]]],
   {'picks': ['rat',
              'rat',
              'rat',
              'ogre',
              'ogre',
              'ogre',
              'bat',
              'bat',
              'bat',
              'imp',
              'imp',
              'imp',
              'orc',
              'orc',
              'orc',
              'wyrm',
              'wyrm',
              'wyrm'],
    'left': 45}),
  ('regression milestone bonus #4',
   [9, [['imp', 25, 3], ['bat', 5, 5]]],
   {'picks': ['imp', 'imp', 'bat', 'bat', 'bat'], 'left': 0}),
  ('unlock at depth #1',
   [3, [['ogre', 10, 3], ['rat', 1, 0]]],
   {'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat'], 'left': 2}),
  ('equal cost tie #1', [0, [['orc', 5, 0], ['imp', 5, 0]]], {'picks': ['imp', 'imp'], 'left': 0}),
  ('control #1',
   [4, [['rat', 5, 5], ['ogre', 5, 0], ['wyrm', 5, 1], ['imp', 5, 3]]],
   {'picks': ['imp', 'imp', 'imp', 'ogre', 'ogre', 'ogre'], 'left': 0})]]
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
milestone depth bonus #1{'left': 30, 'picks': ['orc', 'orc', 'orc']}{'left': 30, 'picks': ['orc', 'orc', 'orc']}Passed
regression milestone bonus #1{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat']}{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'ogre', 'bat', 'rat']}Passed
regression milestone bonus #2{'left': 100, 'picks': ['ogre', 'ogre', 'ogre']}{'left': 100, 'picks': ['ogre', 'ogre', 'ogre']}Passed
regression milestone bonus #3{'left': 15, 'picks': ['orc', 'orc', 'orc']}{'left': 15, 'picks': ['orc', 'orc', 'orc']}Passed
regression milestone bonus #4{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre']}{'left': 0, 'picks': ['wyrm', 'wyrm', 'wyrm', 'bat', 'imp', 'imp', 'imp', 'ogre']}Passed
unlock at depth #1{'left': 2, 'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat']}{'left': 2, 'picks': ['ogre', 'ogre', 'rat', 'rat', 'rat']}Passed
equal cost tie #1{'left': 0, 'picks': ['imp', 'imp']}{'left': 0, 'picks': ['imp', 'imp']}Passed
control #1{'left': 2, 'picks': ['imp', 'orc', 'orc', 'orc']}{'left': 2, 'picks': ['imp', 'orc', 'orc', 'orc']}Passed

SHA-256 / adba2be2c226594de6a8d95290fe2fc053961d22b2d72e656e7ef9910213f8e7

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:50.606570+00:00.

Case digest / af800500968b4a6681e7f74cfd2a81cc72b24fd0595d8d9ab583378c9a58461a