FA-86091 / Game economy crafting balance / Open access
Stamina regeneration: Refills cannot exceed cap · case 01
Stamina potions used near full are wasted.
ROOT CAUSE
Refills are clamped to the regeneration cap instead of the overflow ceiling.
VERIFIED REPAIR
Restore `min(999, s + amount)` at the overflow ceiling step.
Unsuccessful approach: Clamping between cap and the ceiling refills a spend from overflow back up to cap.
Case contract
Stamina regenerates 1 per 300 s while below cap, anchored at last_tick. Events [time, amount] are applied in time order (then amount); before each event (and finally at now) regeneration catches up: if it reaches cap the value becomes cap and the anchor moves to the event time, otherwise the anchor advances by whole periods. While at or above cap the anchor follows the event time. Amounts may push stamina above cap up to 999; negative amounts are spends that are rejected if they would go below zero. Return [stamina, anchor].
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(stamina, cap, last_tick, now, refills):
events = sorted(refills) + [[now, 0]]
t = last_tick
s = stamina
for at, amount in events:
if s < cap:
gained = (at - t) // 300
if s + gained >= cap:
s = cap
t = at
else:
s += gained
t += gained * 300
else:
t = at
if s + amount >= 0:
s = min(cap, s + amount)
return [s, t]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('regression overflow ceiling #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('fault site overflow ceiling #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),
('partial repair boundary #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),
('partial repair boundary #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 11, 224, 4427, []], [11, 4427])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),
('fault site overflow ceiling #2', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),
('regression overflow ceiling #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('partial repair boundary #1', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 11, 224, 4427, []], [11, 4427])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [4, 13, 569, 868, [[776, 10]]], [14, 868]),
('regression overflow ceiling #1', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [17, 18, 353, 353, []], [17, 353]),
('partial repair boundary #2', [0, 18, 176, 176, []], [0, 176]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [14, 15, 389, 2081, []], [15, 2081])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [0, 7, 587, 587, [[587, 8], [587, 9]]], [17, 587]),
('fault site overflow ceiling #2', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('regression overflow ceiling #1', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [8, 9, 913, 1212, [[1053, -9], [963, -6], [1014, -5]]], [2, 913]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 9, 303, 303, [[303, 9]]], [9, 303])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('regression overflow ceiling #1', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('fault site overflow ceiling #1', [12, 12, 443, 1043, [[843, 12]]], [24, 1043]),
('partial repair boundary #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),
('partial repair boundary #2', [0, 14, 147, 147, []], [0, 147]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [8, 8, 764, 764, [[764, 0]]], [8, 764])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| overflow potion persists #1 | [5, 1200] | [15, 1200] | Failed |
| spend from full restarts timer #1 | [8, 1000] | [8, 1000] | Passed |
| regression overflow ceiling #1 | [1, 1485] | [3, 1315] | Failed |
| fault site overflow ceiling #1 | [13, 1010] | [32, 1010] | Failed |
| partial repair boundary #1 | [0, 266] | [0, 266] | Passed |
| partial repair boundary #2 | [15, 1583] | [15, 1583] | Passed |
| exact refill to cap #1 | [5, 600] | [5, 600] | Passed |
| control #1 | [11, 4427] | [11, 4427] | Passed |
SHA-256 / 14784042d6a747cbbb041c841225c1d06a2236e924eac38a568e7e0b6a295c5f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(stamina, cap, last_tick, now, refills):
events = sorted(refills) + [[now, 0]]
t = last_tick
s = stamina
for at, amount in events:
if s < cap:
gained = (at - t) // 300
if s + gained >= cap:
s = cap
t = at
else:
s += gained
t += gained * 300
else:
t = at
if s + amount >= 0:
s = max(cap, min(999, s + amount))
return [s, t]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('regression overflow ceiling #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('fault site overflow ceiling #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),
('partial repair boundary #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),
('partial repair boundary #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 11, 224, 4427, []], [11, 4427])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),
('fault site overflow ceiling #2', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),
('regression overflow ceiling #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('partial repair boundary #1', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 11, 224, 4427, []], [11, 4427])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [4, 13, 569, 868, [[776, 10]]], [14, 868]),
('regression overflow ceiling #1', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [17, 18, 353, 353, []], [17, 353]),
('partial repair boundary #2', [0, 18, 176, 176, []], [0, 176]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [14, 15, 389, 2081, []], [15, 2081])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [0, 7, 587, 587, [[587, 8], [587, 9]]], [17, 587]),
('fault site overflow ceiling #2', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('regression overflow ceiling #1', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [8, 9, 913, 1212, [[1053, -9], [963, -6], [1014, -5]]], [2, 913]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 9, 303, 303, [[303, 9]]], [9, 303])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('regression overflow ceiling #1', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('fault site overflow ceiling #1', [12, 12, 443, 1043, [[843, 12]]], [24, 1043]),
('partial repair boundary #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),
('partial repair boundary #2', [0, 14, 147, 147, []], [0, 147]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [8, 8, 764, 764, [[764, 0]]], [8, 764])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| overflow potion persists #1 | [15, 1200] | [15, 1200] | Passed |
| spend from full restarts timer #1 | [10, 1000] | [8, 1000] | Failed |
| regression overflow ceiling #1 | [20, 1572] | [3, 1315] | Failed |
| fault site overflow ceiling #1 | [32, 1010] | [32, 1010] | Passed |
| partial repair boundary #1 | [9, 266] | [0, 266] | Failed |
| partial repair boundary #2 | [17, 1773] | [15, 1583] | Failed |
| exact refill to cap #1 | [5, 600] | [5, 600] | Passed |
| control #1 | [11, 4427] | [11, 4427] | Passed |
SHA-256 / b2e7f469689f20663f5d4d32d937a44af7d0902969d33e31167c409b31122cae
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(stamina, cap, last_tick, now, refills):
events = sorted(refills) + [[now, 0]]
t = last_tick
s = stamina
for at, amount in events:
if s < cap:
gained = (at - t) // 300
if s + gained >= cap:
s = cap
t = at
else:
s += gained
t += gained * 300
else:
t = at
if s + amount >= 0:
s = min(999, s + amount)
return [s, t]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('regression overflow ceiling #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('fault site overflow ceiling #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),
('partial repair boundary #1', [9, 9, 266, 266, [[266, -9], [266, -10]]], [0, 266]),
('partial repair boundary #2', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 11, 224, 4427, []], [11, 4427])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [12, 13, 710, 1010, [[793, 7], [721, 13]]], [32, 1010]),
('fault site overflow ceiling #2', [11, 12, 57, 163, [[92, 12], [139, 12]]], [35, 163]),
('regression overflow ceiling #1', [23, 20, 972, 1572, [[1185, -20], [1315, -20], [1066, 20]]], [3, 1315]),
('partial repair boundary #1', [16, 17, 83, 1773, [[154, -6]]], [15, 1583]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 11, 224, 4427, []], [11, 4427])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [4, 13, 569, 868, [[776, 10]]], [14, 868]),
('regression overflow ceiling #1', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [17, 18, 353, 353, []], [17, 353]),
('partial repair boundary #2', [0, 18, 176, 176, []], [0, 176]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [14, 15, 389, 2081, []], [15, 2081])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('fault site overflow ceiling #1', [0, 7, 587, 587, [[587, 8], [587, 9]]], [17, 587]),
('fault site overflow ceiling #2', [17, 17, 382, 982, [[483, 17], [862, -6], [923, 17]]], [45, 982]),
('regression overflow ceiling #1', [0, 15, 688, 1288, [[1231, 15], [743, 9], [808, 15]]], [39, 1288]),
('partial repair boundary #1', [8, 9, 913, 1212, [[1053, -9], [963, -6], [1014, -5]]], [2, 913]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [0, 9, 303, 303, [[303, 9]]], [9, 303])],
[('overflow potion persists #1', [5, 5, 0, 1200, [[100, 10]]], [15, 1200]),
('spend from full restarts timer #1', [10, 10, 0, 1000, [[400, -4]]], [8, 1000]),
('regression overflow ceiling #1', [4, 11, 767, 2462, [[2177, 7], [1959, -11], [1673, 11]]], [14, 2462]),
('fault site overflow ceiling #1', [12, 12, 443, 1043, [[843, 12]]], [24, 1043]),
('partial repair boundary #1', [17, 17, 907, 907, [[907, -12], [907, -17], [907, -17]]], [0, 907]),
('partial repair boundary #2', [0, 14, 147, 147, []], [0, 147]),
('exact refill to cap #1', [3, 5, 0, 600, []], [5, 600]),
('control #1', [8, 8, 764, 764, [[764, 0]]], [8, 764])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| overflow potion persists #1 | [15, 1200] | [15, 1200] | Passed |
| spend from full restarts timer #1 | [8, 1000] | [8, 1000] | Passed |
| regression overflow ceiling #1 | [3, 1315] | [3, 1315] | Passed |
| fault site overflow ceiling #1 | [32, 1010] | [32, 1010] | Passed |
| partial repair boundary #1 | [0, 266] | [0, 266] | Passed |
| partial repair boundary #2 | [15, 1583] | [15, 1583] | Passed |
| exact refill to cap #1 | [5, 600] | [5, 600] | Passed |
| control #1 | [11, 4427] | [11, 4427] | Passed |
SHA-256 / 4353d756bdfc5533076257122f7985aa228463cc3ff5abf7b443d543ed8d3d6b
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:46.336590+00:00.
Case digest / 705e797c6a7e522ac659903abffd37ddaf8f5c0d60f17eaf1a91ecdb38cdfd7a