FAILURE MAP
← Case archive

FA-86276 / Game economy crafting balance / Open access

Daily market rebalance: Untargeted items skip the band · case 01

Items without a sales target keep out-of-band prices.

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

ROOT CAUSE

The no-target path returns the raw price.

VERIFIED REPAIR

Restore `return min(max(price, floor), ceiling)` at the untargeted clamp step.

Unsuccessful approach: Applying only the ceiling leaves prices under the floor.

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 price
    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 = [[('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 0, 0, 7, 47], 47),
  ('fault site untargeted clamp #2', [1000, 0, 0, 22, 503], 503),
  ('regression untargeted clamp #1', [1, 71, 0, 40, 55], 40),
  ('regression untargeted clamp #2', [9, 1, 0, 18, 1291], 18),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 0, 0, 22, 503], 503),
  ('fault site untargeted clamp #2', [1817, 170, 0, 27, 1161], 1161),
  ('regression untargeted clamp #1', [9, 1, 0, 18, 1291], 18),
  ('regression untargeted clamp #2', [3, 0, 0, 46, 987], 46),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('regression untargeted clamp #1', [1, 71, 0, 40, 55], 40),
  ('regression untargeted clamp #2', [9, 1, 0, 18, 1291], 18),
  ('regression untargeted clamp #3', [1, 0, 0, 31, 1106], 31),
  ('regression untargeted clamp #4', [1, 2, 0, 50, 1234], 50),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 109, 0, 3, 331], 331),
  ('regression untargeted clamp #1', [3, 0, 0, 46, 987], 46),
  ('regression untargeted clamp #2', [1, 2, 0, 47, 1435], 47),
  ('regression untargeted clamp #3', [9, 0, 0, 22, 719], 22),
  ('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)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('regression untargeted clamp #1', [1, 0, 0, 31, 1106], 31),
  ('fault site untargeted clamp #1', [1000, 0, 0, 15, 739], 739),
  ('regression untargeted clamp #2', [1, 0, 0, 4, 964], 4),
  ('regression untargeted clamp #3', [1, 0, 0, 16, 930], 16),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [736, 68, 66, 28, 100], 100)]]
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
no target listed #1510Failed
fault site untargeted clamp #1100047Failed
fault site untargeted clamp #21000503Failed
regression untargeted clamp #1140Failed
regression untargeted clamp #2918Failed
cheap item rises one #144Passed
crash capped at 15 #1850850Passed
control #1118118Passed

SHA-256 / f125ff6a8d5c0b29b7cd5aa41330d282d3feff87d57c118df5328be8c7161e94

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(price, 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 = [[('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 0, 0, 7, 47], 47),
  ('fault site untargeted clamp #2', [1000, 0, 0, 22, 503], 503),
  ('regression untargeted clamp #1', [1, 71, 0, 40, 55], 40),
  ('regression untargeted clamp #2', [9, 1, 0, 18, 1291], 18),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 0, 0, 22, 503], 503),
  ('fault site untargeted clamp #2', [1817, 170, 0, 27, 1161], 1161),
  ('regression untargeted clamp #1', [9, 1, 0, 18, 1291], 18),
  ('regression untargeted clamp #2', [3, 0, 0, 46, 987], 46),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('regression untargeted clamp #1', [1, 71, 0, 40, 55], 40),
  ('regression untargeted clamp #2', [9, 1, 0, 18, 1291], 18),
  ('regression untargeted clamp #3', [1, 0, 0, 31, 1106], 31),
  ('regression untargeted clamp #4', [1, 2, 0, 50, 1234], 50),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 109, 0, 3, 331], 331),
  ('regression untargeted clamp #1', [3, 0, 0, 46, 987], 46),
  ('regression untargeted clamp #2', [1, 2, 0, 47, 1435], 47),
  ('regression untargeted clamp #3', [9, 0, 0, 22, 719], 22),
  ('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)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('regression untargeted clamp #1', [1, 0, 0, 31, 1106], 31),
  ('fault site untargeted clamp #1', [1000, 0, 0, 15, 739], 739),
  ('regression untargeted clamp #2', [1, 0, 0, 4, 964], 4),
  ('regression untargeted clamp #3', [1, 0, 0, 16, 930], 16),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [736, 68, 66, 28, 100], 100)]]
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
no target listed #1510Failed
fault site untargeted clamp #14747Passed
fault site untargeted clamp #2503503Passed
regression untargeted clamp #1140Failed
regression untargeted clamp #2918Failed
cheap item rises one #144Passed
crash capped at 15 #1850850Passed
control #1118118Passed

SHA-256 / d85f3caf6a1f7210923d80d1a1854569683e70a082efb34dd54e8804432a90e5

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 = [[('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 0, 0, 7, 47], 47),
  ('fault site untargeted clamp #2', [1000, 0, 0, 22, 503], 503),
  ('regression untargeted clamp #1', [1, 71, 0, 40, 55], 40),
  ('regression untargeted clamp #2', [9, 1, 0, 18, 1291], 18),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 0, 0, 22, 503], 503),
  ('fault site untargeted clamp #2', [1817, 170, 0, 27, 1161], 1161),
  ('regression untargeted clamp #1', [9, 1, 0, 18, 1291], 18),
  ('regression untargeted clamp #2', [3, 0, 0, 46, 987], 46),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('regression untargeted clamp #1', [1, 71, 0, 40, 55], 40),
  ('regression untargeted clamp #2', [9, 1, 0, 18, 1291], 18),
  ('regression untargeted clamp #3', [1, 0, 0, 31, 1106], 31),
  ('regression untargeted clamp #4', [1, 2, 0, 50, 1234], 50),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [99, 1188, 396, 6, 782], 118)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('fault site untargeted clamp #1', [1000, 109, 0, 3, 331], 331),
  ('regression untargeted clamp #1', [3, 0, 0, 46, 987], 46),
  ('regression untargeted clamp #2', [1, 2, 0, 47, 1435], 47),
  ('regression untargeted clamp #3', [9, 0, 0, 22, 719], 22),
  ('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)],
 [('no target listed #1', [5, 3, 0, 10, 50], 10),
  ('regression untargeted clamp #1', [1, 0, 0, 31, 1106], 31),
  ('fault site untargeted clamp #1', [1000, 0, 0, 15, 739], 739),
  ('regression untargeted clamp #2', [1, 0, 0, 4, 964], 4),
  ('regression untargeted clamp #3', [1, 0, 0, 16, 930], 16),
  ('cheap item rises one #1', [3, 13, 10, 1, 100], 4),
  ('crash capped at 15 #1', [1000, 0, 40, 1, 5000], 850),
  ('control #1', [736, 68, 66, 28, 100], 100)]]
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
no target listed #11010Passed
fault site untargeted clamp #14747Passed
fault site untargeted clamp #2503503Passed
regression untargeted clamp #14040Passed
regression untargeted clamp #21818Passed
cheap item rises one #144Passed
crash capped at 15 #1850850Passed
control #1118118Passed

SHA-256 / 797a2a5c4575c3efceede6ec8e6c2cc80724b81ef76278f5fdc6a07cb05aa1ed

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

Case digest / 82166af5e4667776bfd0712cc5d48209390f8acbde23e29bb0097ac4137d429f