FA-86116 / Game economy crafting balance / Open access
Magic find loot roll: Magic find adds flat weight · case 01
Magic find overwhelms tiny weights and barely moves large ones.
ROOT CAUSE
Magic find is added to the weight instead of scaling it.
VERIFIED REPAIR
Restore `w * (100 + magic_find) // 100` at the boost arithmetic step.
Unsuccessful approach: Integer-dividing magic find by 100 first discards partial boosts.
Case contract
table = [[item, rarity, weight], ...]. Non-common weights become floor(w*(100+mf)/100) (mf may be negative). With total boosted weight T (None if 0), target = floor(roll*T/10000) for roll 0..9999; return the first item whose cumulative boosted weight exceeds target.
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(table, roll, magic_find):
weights = []
for item, rarity, w in table:
if rarity != 'common':
w = w + magic_find
weights.append(w)
total = sum(weights)
if total == 0:
return None
target = roll * total // 10000
acc = 0
for (item, rarity, w0), w in zip(table, weights):
acc += w
if target < acc:
return item
return None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1',
[[['i0', 'rare', 2], ['i1', 'legendary', 5], ['i2', 'legendary', 2], ['i3', 'legendary', 5]], 0, -50],
'i0'),
('regression boost arithmetic #2',
[[['i0', 'legendary', 10],
['i1', 'rare', 50],
['i2', 'legendary', 0],
['i3', 'common', 2],
['i4', 'common', 55]],
0,
-50],
'i0'),
('partial repair boundary #1', [[['i0', 'rare', 50], ['i1', 'common', 0]], 1029, -22], 'i0'),
('regression boost arithmetic #3', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1',
[[['i0', 'legendary', 10],
['i1', 'rare', 50],
['i2', 'legendary', 0],
['i3', 'common', 2],
['i4', 'common', 55]],
0,
-50],
'i0'),
('fault site boost arithmetic #1', [[['i0', 'rare', 0], ['i1', 'rare', 1]], 494, 100], 'i1'),
('partial repair boundary #1', [[['i0', 'rare', 50], ['i1', 'common', 0]], 1029, -22], 'i0'),
('regression boost arithmetic #2', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('fault site boost arithmetic #1', [[['i0', 'legendary', 0], ['i1', 'common', 5]], 1, 250], 'i1'),
('fault site boost arithmetic #2', [[['i0', 'legendary', 0]], 0, 100], None),
('regression boost arithmetic #1',
[[['i0', 'rare', 10], ['i1', 'rare', 50], ['i2', 'rare', 5], ['i3', 'common', 10]], 5000, -50],
'i1'),
('regression boost arithmetic #2', [[['i0', 'legendary', 0], ['i1', 'legendary', 10]], 0, -26], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('regression boost arithmetic #2',
[[['i0', 'rare', 10], ['i1', 'rare', 50], ['i2', 'rare', 5], ['i3', 'common', 10]], 5000, -50],
'i1'),
('regression boost arithmetic #3', [[['i0', 'rare', 2]], 5000, -50], 'i0'),
('regression boost arithmetic #4',
[[['i0', 'common', 0], ['i1', 'legendary', 10], ['i2', 'legendary', 50]], 2138, -50],
'i2'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'common', 50], ['i2', 'legendary', 50]], 793, -50], 'i0')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1', [[['i0', 'legendary', 0], ['i1', 'legendary', 10]], 0, -26], 'i1'),
('fault site boost arithmetic #1',
[[['i0', 'rare', 50], ['i1', 'rare', 10], ['i2', 'common', 50], ['i3', 'rare', 0], ['i4', 'common', 56]],
5000,
250],
'i0'),
('regression boost arithmetic #2',
[[['i0', 'legendary', 5], ['i1', 'rare', 0], ['i2', 'common', 10], ['i3', 'rare', 1]], 1, -50],
'i0'),
('partial repair boundary #1',
[[['i0', 'legendary', 50], ['i1', 'legendary', 83], ['i2', 'common', 78], ['i3', 'common', 95]],
5000,
-50],
'i2'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'rare', 1], ['i1', 'common', 10], ['i2', 'legendary', 93]], 0, 100], 'i0')]]
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 |
|---|---|---|---|
| curse lowers rare #1 | None | rock | Failed |
| regression boost arithmetic #1 | None | i0 | Failed |
| regression boost arithmetic #2 | None | i0 | Failed |
| partial repair boundary #1 | i0 | i0 | Passed |
| regression boost arithmetic #3 | None | i1 | Failed |
| legendary boosted #1 | crown | crown | Passed |
| zero weight entry skipped #1 | c | c | Passed |
| control #1 | i1 | i1 | Passed |
SHA-256 / 2abc12cfaf0379efe5e159bf51951e059ecf87a0b56a469308907ff4093aa488
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(table, roll, magic_find):
weights = []
for item, rarity, w in table:
if rarity != 'common':
w = w * (1 + magic_find // 100)
weights.append(w)
total = sum(weights)
if total == 0:
return None
target = roll * total // 10000
acc = 0
for (item, rarity, w0), w in zip(table, weights):
acc += w
if target < acc:
return item
return None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1',
[[['i0', 'rare', 2], ['i1', 'legendary', 5], ['i2', 'legendary', 2], ['i3', 'legendary', 5]], 0, -50],
'i0'),
('regression boost arithmetic #2',
[[['i0', 'legendary', 10],
['i1', 'rare', 50],
['i2', 'legendary', 0],
['i3', 'common', 2],
['i4', 'common', 55]],
0,
-50],
'i0'),
('partial repair boundary #1', [[['i0', 'rare', 50], ['i1', 'common', 0]], 1029, -22], 'i0'),
('regression boost arithmetic #3', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1',
[[['i0', 'legendary', 10],
['i1', 'rare', 50],
['i2', 'legendary', 0],
['i3', 'common', 2],
['i4', 'common', 55]],
0,
-50],
'i0'),
('fault site boost arithmetic #1', [[['i0', 'rare', 0], ['i1', 'rare', 1]], 494, 100], 'i1'),
('partial repair boundary #1', [[['i0', 'rare', 50], ['i1', 'common', 0]], 1029, -22], 'i0'),
('regression boost arithmetic #2', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('fault site boost arithmetic #1', [[['i0', 'legendary', 0], ['i1', 'common', 5]], 1, 250], 'i1'),
('fault site boost arithmetic #2', [[['i0', 'legendary', 0]], 0, 100], None),
('regression boost arithmetic #1',
[[['i0', 'rare', 10], ['i1', 'rare', 50], ['i2', 'rare', 5], ['i3', 'common', 10]], 5000, -50],
'i1'),
('regression boost arithmetic #2', [[['i0', 'legendary', 0], ['i1', 'legendary', 10]], 0, -26], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('regression boost arithmetic #2',
[[['i0', 'rare', 10], ['i1', 'rare', 50], ['i2', 'rare', 5], ['i3', 'common', 10]], 5000, -50],
'i1'),
('regression boost arithmetic #3', [[['i0', 'rare', 2]], 5000, -50], 'i0'),
('regression boost arithmetic #4',
[[['i0', 'common', 0], ['i1', 'legendary', 10], ['i2', 'legendary', 50]], 2138, -50],
'i2'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'common', 50], ['i2', 'legendary', 50]], 793, -50], 'i0')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1', [[['i0', 'legendary', 0], ['i1', 'legendary', 10]], 0, -26], 'i1'),
('fault site boost arithmetic #1',
[[['i0', 'rare', 50], ['i1', 'rare', 10], ['i2', 'common', 50], ['i3', 'rare', 0], ['i4', 'common', 56]],
5000,
250],
'i0'),
('regression boost arithmetic #2',
[[['i0', 'legendary', 5], ['i1', 'rare', 0], ['i2', 'common', 10], ['i3', 'rare', 1]], 1, -50],
'i0'),
('partial repair boundary #1',
[[['i0', 'legendary', 50], ['i1', 'legendary', 83], ['i2', 'common', 78], ['i3', 'common', 95]],
5000,
-50],
'i2'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'rare', 1], ['i1', 'common', 10], ['i2', 'legendary', 93]], 0, 100], 'i0')]]
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 |
|---|---|---|---|
| curse lowers rare #1 | rock | rock | Passed |
| regression boost arithmetic #1 | None | i0 | Failed |
| regression boost arithmetic #2 | i3 | i0 | Failed |
| partial repair boundary #1 | None | i0 | Failed |
| regression boost arithmetic #3 | None | i1 | Failed |
| legendary boosted #1 | crown | crown | Passed |
| zero weight entry skipped #1 | c | c | Passed |
| control #1 | i1 | i1 | Passed |
SHA-256 / 18ebaea1d340a6f9e0fd43d08a5a0bde8b4bf10f9133141e836ca9bc53073006
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(table, roll, magic_find):
weights = []
for item, rarity, w in table:
if rarity != 'common':
w = w * (100 + magic_find) // 100
weights.append(w)
total = sum(weights)
if total == 0:
return None
target = roll * total // 10000
acc = 0
for (item, rarity, w0), w in zip(table, weights):
acc += w
if target < acc:
return item
return None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1',
[[['i0', 'rare', 2], ['i1', 'legendary', 5], ['i2', 'legendary', 2], ['i3', 'legendary', 5]], 0, -50],
'i0'),
('regression boost arithmetic #2',
[[['i0', 'legendary', 10],
['i1', 'rare', 50],
['i2', 'legendary', 0],
['i3', 'common', 2],
['i4', 'common', 55]],
0,
-50],
'i0'),
('partial repair boundary #1', [[['i0', 'rare', 50], ['i1', 'common', 0]], 1029, -22], 'i0'),
('regression boost arithmetic #3', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1',
[[['i0', 'legendary', 10],
['i1', 'rare', 50],
['i2', 'legendary', 0],
['i3', 'common', 2],
['i4', 'common', 55]],
0,
-50],
'i0'),
('fault site boost arithmetic #1', [[['i0', 'rare', 0], ['i1', 'rare', 1]], 494, 100], 'i1'),
('partial repair boundary #1', [[['i0', 'rare', 50], ['i1', 'common', 0]], 1029, -22], 'i0'),
('regression boost arithmetic #2', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('fault site boost arithmetic #1', [[['i0', 'legendary', 0], ['i1', 'common', 5]], 1, 250], 'i1'),
('fault site boost arithmetic #2', [[['i0', 'legendary', 0]], 0, 100], None),
('regression boost arithmetic #1',
[[['i0', 'rare', 10], ['i1', 'rare', 50], ['i2', 'rare', 5], ['i3', 'common', 10]], 5000, -50],
'i1'),
('regression boost arithmetic #2', [[['i0', 'legendary', 0], ['i1', 'legendary', 10]], 0, -26], 'i1'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'rare', 50]], 9999, 50], 'i1')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1', [[['i0', 'rare', 1], ['i1', 'rare', 2]], 1, -50], 'i1'),
('regression boost arithmetic #2',
[[['i0', 'rare', 10], ['i1', 'rare', 50], ['i2', 'rare', 5], ['i3', 'common', 10]], 5000, -50],
'i1'),
('regression boost arithmetic #3', [[['i0', 'rare', 2]], 5000, -50], 'i0'),
('regression boost arithmetic #4',
[[['i0', 'common', 0], ['i1', 'legendary', 10], ['i2', 'legendary', 50]], 2138, -50],
'i2'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'common', 10], ['i1', 'common', 50], ['i2', 'legendary', 50]], 793, -50], 'i0')],
[('curse lowers rare #1', [[['gem', 'rare', 10], ['rock', 'common', 10]], 4000, -50], 'rock'),
('regression boost arithmetic #1', [[['i0', 'legendary', 0], ['i1', 'legendary', 10]], 0, -26], 'i1'),
('fault site boost arithmetic #1',
[[['i0', 'rare', 50], ['i1', 'rare', 10], ['i2', 'common', 50], ['i3', 'rare', 0], ['i4', 'common', 56]],
5000,
250],
'i0'),
('regression boost arithmetic #2',
[[['i0', 'legendary', 5], ['i1', 'rare', 0], ['i2', 'common', 10], ['i3', 'rare', 1]], 1, -50],
'i0'),
('partial repair boundary #1',
[[['i0', 'legendary', 50], ['i1', 'legendary', 83], ['i2', 'common', 78], ['i3', 'common', 95]],
5000,
-50],
'i2'),
('legendary boosted #1', [[['sword', 'common', 90], ['crown', 'legendary', 10]], 9500, 100], 'crown'),
('zero weight entry skipped #1',
[[['a', 'common', 1], ['b', 'rare', 0], ['c', 'common', 1]], 5000, 0],
'c'),
('control #1', [[['i0', 'rare', 1], ['i1', 'common', 10], ['i2', 'legendary', 93]], 0, 100], 'i0')]]
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 |
|---|---|---|---|
| curse lowers rare #1 | rock | rock | Passed |
| regression boost arithmetic #1 | i0 | i0 | Passed |
| regression boost arithmetic #2 | i0 | i0 | Passed |
| partial repair boundary #1 | i0 | i0 | Passed |
| regression boost arithmetic #3 | i1 | i1 | Passed |
| legendary boosted #1 | crown | crown | Passed |
| zero weight entry skipped #1 | c | c | Passed |
| control #1 | i1 | i1 | Passed |
SHA-256 / c785b204b3b49dce88c8417cb5a1cf53ba2badee4b611ce231677a7afcb4f434
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.682880+00:00.
Case digest / 75394d754e11d1b0254595a35248f5f2faa8682d4b726e26821033ebf00d3045