FAILURE MAP
← Case archive

FA-86256 / Game economy crafting balance / Open access

Daily market rebalance: Price spikes are uncapped · case 01

A single sell-out day multiplies the price.

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

ROOT CAUSE

The daily rise percentage has no 20% cap.

VERIFIED REPAIR

Restore `min(20, (sold - target) * 100 // target)` at the rise cap step.

Unsuccessful approach: Measuring excess against sales understates moderate rises.

Case contract

If target <= 0 the price is only clamped to [floor, ceiling]. If sold > target: pct = min(20, floor((sold-target)*100/target)), step = floor(price*pct/100) but at least 1 when pct > 0, new = price + step. If sold < target: pct = min(15, floor((target-sold)*100/target)), new = price - floor(price*pct/100). Otherwise unchanged. Result clamped to [floor, ceiling].

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(price, sold, target, floor, ceiling):
    if target <= 0:
        return min(max(price, floor), ceiling)
    if sold > target:
        pct = (sold - target) * 100 // target
        step = price * pct // 100
        if pct > 0:
            step = max(step, 1)
        new = price + step
    elif sold < target:
        pct = min(15, (target - sold) * 100 // target)
        new = price - price * pct // 100
    else:
        new = price
    return min(max(new, floor), ceiling)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site rise cap #1', [99, 1188, 396, 6, 782], 118),
  ('fault site rise cap #2', [50, 15, 5, 43, 185], 60),
  ('partial repair boundary #1', [50, 11, 10, 38, 410], 55),
  ('partial repair boundary #2', [99, 42, 40, 39, 750], 103),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [9, 0, 1, 47, 499], 47)],
 [('fault site rise cap #1', [99, 267, 89, 48, 886], 118),
  ('fault site rise cap #2', [99, 3, 1, 22, 530], 118),
  ('partial repair boundary #1', [1000, 6, 5, 49, 1369], 1200),
  ('partial repair boundary #2', [99, 11, 10, 44, 1070], 108),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('control #1', [9, 0, 1, 47, 499], 47),
  ('control #2', [1000, 0, 0, 7, 47], 47)],
 [('fault site rise cap #1', [1000, 75, 40, 44, 1496], 1200),
  ('fault site rise cap #2', [328, 7, 5, 6, 879], 393),
  ('partial repair boundary #1', [50, 11, 10, 1, 1404], 55),
  ('partial repair boundary #2', [99, 6, 5, 12, 1409], 118),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [1000, 0, 0, 7, 47], 47),
  ('control #2', [736, 68, 66, 28, 100], 100)],
 [('fault site rise cap #1', [99, 3, 1, 49, 695], 118),
  ('fault site rise cap #2', [50, 1524, 508, 24, 1269], 60),
  ('partial repair boundary #1', [1000, 11, 10, 18, 1162], 1100),
  ('partial repair boundary #2', [50, 100, 87, 39, 122], 57),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('control #1', [3, 75, 76, 12, 1170], 12),
  ('control #2', [1000, 5, 5, 37, 1007], 1000)],
 [('fault site rise cap #1', [99, 210, 70, 40, 1422], 118),
  ('fault site rise cap #2', [99, 191, 5, 22, 1290], 118),
  ('partial repair boundary #1', [99, 6, 5, 33, 381], 118),
  ('partial repair boundary #2', [620, 11, 10, 41, 806], 682),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('control #1', [99, 5, 5, 44, 212], 99),
  ('control #2', [99, -1, 0, 37, 260], 99)]]
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
fault site rise cap #1297118Failed
fault site rise cap #215060Failed
partial repair boundary #15555Passed
partial repair boundary #2103103Passed
no target listed #11010Passed
cheap item rises one #144Passed
crash capped at 15 #1850850Passed
control #14747Passed

SHA-256 / 22759f5c8d57adb239bdbf014200380a7dee813e3991c44b9f1bfcdd340d3187

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(price, sold, target, floor, ceiling):
    if target <= 0:
        return min(max(price, floor), ceiling)
    if sold > target:
        pct = min(20, (sold - target) * 100 // sold)
        step = price * pct // 100
        if pct > 0:
            step = max(step, 1)
        new = price + step
    elif sold < target:
        pct = min(15, (target - sold) * 100 // target)
        new = price - price * pct // 100
    else:
        new = price
    return min(max(new, floor), ceiling)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site rise cap #1', [99, 1188, 396, 6, 782], 118),
  ('fault site rise cap #2', [50, 15, 5, 43, 185], 60),
  ('partial repair boundary #1', [50, 11, 10, 38, 410], 55),
  ('partial repair boundary #2', [99, 42, 40, 39, 750], 103),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [9, 0, 1, 47, 499], 47)],
 [('fault site rise cap #1', [99, 267, 89, 48, 886], 118),
  ('fault site rise cap #2', [99, 3, 1, 22, 530], 118),
  ('partial repair boundary #1', [1000, 6, 5, 49, 1369], 1200),
  ('partial repair boundary #2', [99, 11, 10, 44, 1070], 108),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('control #1', [9, 0, 1, 47, 499], 47),
  ('control #2', [1000, 0, 0, 7, 47], 47)],
 [('fault site rise cap #1', [1000, 75, 40, 44, 1496], 1200),
  ('fault site rise cap #2', [328, 7, 5, 6, 879], 393),
  ('partial repair boundary #1', [50, 11, 10, 1, 1404], 55),
  ('partial repair boundary #2', [99, 6, 5, 12, 1409], 118),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [1000, 0, 0, 7, 47], 47),
  ('control #2', [736, 68, 66, 28, 100], 100)],
 [('fault site rise cap #1', [99, 3, 1, 49, 695], 118),
  ('fault site rise cap #2', [50, 1524, 508, 24, 1269], 60),
  ('partial repair boundary #1', [1000, 11, 10, 18, 1162], 1100),
  ('partial repair boundary #2', [50, 100, 87, 39, 122], 57),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('control #1', [3, 75, 76, 12, 1170], 12),
  ('control #2', [1000, 5, 5, 37, 1007], 1000)],
 [('fault site rise cap #1', [99, 210, 70, 40, 1422], 118),
  ('fault site rise cap #2', [99, 191, 5, 22, 1290], 118),
  ('partial repair boundary #1', [99, 6, 5, 33, 381], 118),
  ('partial repair boundary #2', [620, 11, 10, 41, 806], 682),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('control #1', [99, 5, 5, 44, 212], 99),
  ('control #2', [99, -1, 0, 37, 260], 99)]]
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
fault site rise cap #1118118Passed
fault site rise cap #26060Passed
partial repair boundary #15455Failed
partial repair boundary #2102103Failed
no target listed #11010Passed
cheap item rises one #144Passed
crash capped at 15 #1850850Passed
control #14747Passed

SHA-256 / d636b51c08f9a19cff388868ac718e4618e0202aab6ff048b1114b04953f6775

3 / The verified repair

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

N = 1
observations = []
def solve(price, sold, target, floor, ceiling):
    if target <= 0:
        return min(max(price, floor), ceiling)
    if sold > target:
        pct = min(20, (sold - target) * 100 // target)
        step = price * pct // 100
        if pct > 0:
            step = max(step, 1)
        new = price + step
    elif sold < target:
        pct = min(15, (target - sold) * 100 // target)
        new = price - price * pct // 100
    else:
        new = price
    return min(max(new, floor), ceiling)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site rise cap #1', [99, 1188, 396, 6, 782], 118),
  ('fault site rise cap #2', [50, 15, 5, 43, 185], 60),
  ('partial repair boundary #1', [50, 11, 10, 38, 410], 55),
  ('partial repair boundary #2', [99, 42, 40, 39, 750], 103),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [9, 0, 1, 47, 499], 47)],
 [('fault site rise cap #1', [99, 267, 89, 48, 886], 118),
  ('fault site rise cap #2', [99, 3, 1, 22, 530], 118),
  ('partial repair boundary #1', [1000, 6, 5, 49, 1369], 1200),
  ('partial repair boundary #2', [99, 11, 10, 44, 1070], 108),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('control #1', [9, 0, 1, 47, 499], 47),
  ('control #2', [1000, 0, 0, 7, 47], 47)],
 [('fault site rise cap #1', [1000, 75, 40, 44, 1496], 1200),
  ('fault site rise cap #2', [328, 7, 5, 6, 879], 393),
  ('partial repair boundary #1', [50, 11, 10, 1, 1404], 55),
  ('partial repair boundary #2', [99, 6, 5, 12, 1409], 118),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [1000, 0, 0, 7, 47], 47),
  ('control #2', [736, 68, 66, 28, 100], 100)],
 [('fault site rise cap #1', [99, 3, 1, 49, 695], 118),
  ('fault site rise cap #2', [50, 1524, 508, 24, 1269], 60),
  ('partial repair boundary #1', [1000, 11, 10, 18, 1162], 1100),
  ('partial repair boundary #2', [50, 100, 87, 39, 122], 57),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('control #1', [3, 75, 76, 12, 1170], 12),
  ('control #2', [1000, 5, 5, 37, 1007], 1000)],
 [('fault site rise cap #1', [99, 210, 70, 40, 1422], 118),
  ('fault site rise cap #2', [99, 191, 5, 22, 1290], 118),
  ('partial repair boundary #1', [99, 6, 5, 33, 381], 118),
  ('partial repair boundary #2', [620, 11, 10, 41, 806], 682),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('control #1', [99, 5, 5, 44, 212], 99),
  ('control #2', [99, -1, 0, 37, 260], 99)]]
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
fault site rise cap #1118118Passed
fault site rise cap #26060Passed
partial repair boundary #15555Passed
partial repair boundary #2103103Passed
no target listed #11010Passed
cheap item rises one #144Passed
crash capped at 15 #1850850Passed
control #14747Passed

SHA-256 / 8825de56cbd400a34459ff50c63ab24d4838dd35bac42d70966282d891bb4e88

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

Case digest / 7c5a90d11b38d3f6ada99ede4daab44b5c980ffcb381a55da9ef1d5aa69b018f