FA-86706 / Procedural level generation constraints / Open access
Heightmap smoothing and biome classes: Map edges sink into the sea · case 01
Border cells are averaged as if missing neighbours were zero.
ROOT CAUSE
The window sum is always divided by nine.
VERIFIED REPAIR
Restore `v = total // cnt` at the edge normalisation step.
Unsuccessful approach: Counting the centre twice still biases edge cells.
Case contract
Each cell height becomes floor(mean) of the in-bounds cells in its 3x3 window (input values only). Class: '~' when v < sea, 's' beach when v < sea+2, 'g' when v < mountain, otherwise '^'. Returns strings per row.
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(heights, sea, mountain):
h = len(heights)
w = len(heights[0])
out = []
for r in range(h):
row = []
for c in range(w):
total = 0
cnt = 0
for rr in range(max(0, r - 1), min(h, r + 2)):
for cc in range(max(0, c - 1), min(w, c + 2)):
total += heights[rr][cc]
cnt += 1
v = total // 9
if v < sea:
row.append('~')
elif v < sea + 2:
row.append('s')
elif v < mountain:
row.append('g')
else:
row.append('^')
out.append(''.join(row))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('corner cell average #1', [[[9, 9], [9, 0]], 3, 8], ['gg', 'gg']),
('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1', [[[0, 9], [7, 2]], 2, 11], ['gg', 'gg']),
('regression edge normalisation #2', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #3', [[[9], [8]], 6, 6], ['^', '^']),
('control #1', [[[3], [4], [0]], 4, 10], ['~', '~', '~']),
('control #2', [[[9, 5, 6], [9, 0, 4]], 6, 10], ['~~~', '~~~'])],
[('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1', [[[0, 9], [7, 2]], 2, 11], ['gg', 'gg']),
('regression edge normalisation #2', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #3', [[[9], [8]], 6, 6], ['^', '^']),
('regression edge normalisation #4',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('control #1', [[[5, 3, 0, 8]], 6, 7], ['~~~~']),
('control #2', [[[4], [0]], 6, 11], ['~', '~'])],
[('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('beach band edge #1', [[[5]], 3, 9], ['g']),
('regression edge normalisation #1', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #2', [[[9], [8]], 6, 6], ['^', '^']),
('regression edge normalisation #3',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('regression edge normalisation #4', [[[6], [4], [8], [4], [8]], 5, 9], ['s', 's', 's', 's', 's']),
('control #1', [[[3, 2], [6, 0], [0, 5]], 4, 7], ['~~', '~~', '~~']),
('control #2', [[[3], [0]], 5, 10], ['~', '~'])],
[('corner cell average #1', [[[9, 9], [9, 0]], 3, 8], ['gg', 'gg']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('regression edge normalisation #2', [[[6], [4], [8], [4], [8]], 5, 9], ['s', 's', 's', 's', 's']),
('regression edge normalisation #3',
[[[8, 6, 12, 10, 8], [6, 1, 1, 7, 5], [1, 6, 12, 6, 0], [3, 8, 3, 6, 0], [1, 7, 3, 2, 0]], 6, 9],
['~~sss', '~~sss', '~~~~~', '~~~~~', '~~~~~']),
('regression edge normalisation #4', [[[10, 11], [1, 0]], 3, 9], ['gg', 'gg']),
('control #1', [[[1], [10], [0], [2]], 6, 10], ['~', '~', '~', '~']),
('control #2', [[[0]], 6, 9], ['~'])],
[('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1',
[[[8, 6, 12, 10, 8], [6, 1, 1, 7, 5], [1, 6, 12, 6, 0], [3, 8, 3, 6, 0], [1, 7, 3, 2, 0]], 6, 9],
['~~sss', '~~sss', '~~~~~', '~~~~~', '~~~~~']),
('fault site edge normalisation #1', [[[5, 5], [10, 3], [7, 0]], 2, 10], ['gg', 'gg', 'gg']),
('regression edge normalisation #2', [[[10, 11], [1, 0]], 3, 9], ['gg', 'gg']),
('regression edge normalisation #3', [[[9, 7]], 2, 6], ['^^']),
('control #1', [[[1, 0]], 2, 8], ['~~']),
('control #2', [[[8], [2], [5], [2], [6]], 6, 8], ['~', '~', '~', '~', '~'])]]
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 |
|---|---|---|---|
| corner cell average #1 | ['ss', 'ss'] | ['gg', 'gg'] | Failed |
| beach band edge #1 | ['~'] | ['g'] | Failed |
| single row #1 | ['~~~'] | ['^s^'] | Failed |
| regression edge normalisation #1 | ['ss', 'ss'] | ['gg', 'gg'] | Failed |
| regression edge normalisation #2 | ['~s~~~', '~s~~~'] | ['^^ss~', '^^ss~'] | Failed |
| regression edge normalisation #3 | ['~', '~'] | ['^', '^'] | Failed |
| control #1 | ['~', '~', '~'] | ['~', '~', '~'] | Passed |
| control #2 | ['~~~', '~~~'] | ['~~~', '~~~'] | Passed |
SHA-256 / f5f5ebd138e16489cc89b33eea4692d47831c55900dd7c1580f9d8e33e318339
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(heights, sea, mountain):
h = len(heights)
w = len(heights[0])
out = []
for r in range(h):
row = []
for c in range(w):
total = 0
cnt = 0
for rr in range(max(0, r - 1), min(h, r + 2)):
for cc in range(max(0, c - 1), min(w, c + 2)):
total += heights[rr][cc]
cnt += 1
v = total // (cnt + 1)
if v < sea:
row.append('~')
elif v < sea + 2:
row.append('s')
elif v < mountain:
row.append('g')
else:
row.append('^')
out.append(''.join(row))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('corner cell average #1', [[[9, 9], [9, 0]], 3, 8], ['gg', 'gg']),
('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1', [[[0, 9], [7, 2]], 2, 11], ['gg', 'gg']),
('regression edge normalisation #2', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #3', [[[9], [8]], 6, 6], ['^', '^']),
('control #1', [[[3], [4], [0]], 4, 10], ['~', '~', '~']),
('control #2', [[[9, 5, 6], [9, 0, 4]], 6, 10], ['~~~', '~~~'])],
[('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1', [[[0, 9], [7, 2]], 2, 11], ['gg', 'gg']),
('regression edge normalisation #2', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #3', [[[9], [8]], 6, 6], ['^', '^']),
('regression edge normalisation #4',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('control #1', [[[5, 3, 0, 8]], 6, 7], ['~~~~']),
('control #2', [[[4], [0]], 6, 11], ['~', '~'])],
[('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('beach band edge #1', [[[5]], 3, 9], ['g']),
('regression edge normalisation #1', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #2', [[[9], [8]], 6, 6], ['^', '^']),
('regression edge normalisation #3',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('regression edge normalisation #4', [[[6], [4], [8], [4], [8]], 5, 9], ['s', 's', 's', 's', 's']),
('control #1', [[[3, 2], [6, 0], [0, 5]], 4, 7], ['~~', '~~', '~~']),
('control #2', [[[3], [0]], 5, 10], ['~', '~'])],
[('corner cell average #1', [[[9, 9], [9, 0]], 3, 8], ['gg', 'gg']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('regression edge normalisation #2', [[[6], [4], [8], [4], [8]], 5, 9], ['s', 's', 's', 's', 's']),
('regression edge normalisation #3',
[[[8, 6, 12, 10, 8], [6, 1, 1, 7, 5], [1, 6, 12, 6, 0], [3, 8, 3, 6, 0], [1, 7, 3, 2, 0]], 6, 9],
['~~sss', '~~sss', '~~~~~', '~~~~~', '~~~~~']),
('regression edge normalisation #4', [[[10, 11], [1, 0]], 3, 9], ['gg', 'gg']),
('control #1', [[[1], [10], [0], [2]], 6, 10], ['~', '~', '~', '~']),
('control #2', [[[0]], 6, 9], ['~'])],
[('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1',
[[[8, 6, 12, 10, 8], [6, 1, 1, 7, 5], [1, 6, 12, 6, 0], [3, 8, 3, 6, 0], [1, 7, 3, 2, 0]], 6, 9],
['~~sss', '~~sss', '~~~~~', '~~~~~', '~~~~~']),
('fault site edge normalisation #1', [[[5, 5], [10, 3], [7, 0]], 2, 10], ['gg', 'gg', 'gg']),
('regression edge normalisation #2', [[[10, 11], [1, 0]], 3, 9], ['gg', 'gg']),
('regression edge normalisation #3', [[[9, 7]], 2, 6], ['^^']),
('control #1', [[[1, 0]], 2, 8], ['~~']),
('control #2', [[[8], [2], [5], [2], [6]], 6, 8], ['~', '~', '~', '~', '~'])]]
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 |
|---|---|---|---|
| corner cell average #1 | ['gg', 'gg'] | ['gg', 'gg'] | Passed |
| beach band edge #1 | ['~'] | ['g'] | Failed |
| single row #1 | ['sss'] | ['^s^'] | Failed |
| regression edge normalisation #1 | ['ss', 'ss'] | ['gg', 'gg'] | Failed |
| regression edge normalisation #2 | ['sss~~', 'sss~~'] | ['^^ss~', '^^ss~'] | Failed |
| regression edge normalisation #3 | ['~', '~'] | ['^', '^'] | Failed |
| control #1 | ['~', '~', '~'] | ['~', '~', '~'] | Passed |
| control #2 | ['~~~', '~~~'] | ['~~~', '~~~'] | Passed |
SHA-256 / e6f1b6f4ce070f60189dbc38fa4305d434f0124d43ce8022e5ad01597ff64916
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(heights, sea, mountain):
h = len(heights)
w = len(heights[0])
out = []
for r in range(h):
row = []
for c in range(w):
total = 0
cnt = 0
for rr in range(max(0, r - 1), min(h, r + 2)):
for cc in range(max(0, c - 1), min(w, c + 2)):
total += heights[rr][cc]
cnt += 1
v = total // cnt
if v < sea:
row.append('~')
elif v < sea + 2:
row.append('s')
elif v < mountain:
row.append('g')
else:
row.append('^')
out.append(''.join(row))
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('corner cell average #1', [[[9, 9], [9, 0]], 3, 8], ['gg', 'gg']),
('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1', [[[0, 9], [7, 2]], 2, 11], ['gg', 'gg']),
('regression edge normalisation #2', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #3', [[[9], [8]], 6, 6], ['^', '^']),
('control #1', [[[3], [4], [0]], 4, 10], ['~', '~', '~']),
('control #2', [[[9, 5, 6], [9, 0, 4]], 6, 10], ['~~~', '~~~'])],
[('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1', [[[0, 9], [7, 2]], 2, 11], ['gg', 'gg']),
('regression edge normalisation #2', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #3', [[[9], [8]], 6, 6], ['^', '^']),
('regression edge normalisation #4',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('control #1', [[[5, 3, 0, 8]], 6, 7], ['~~~~']),
('control #2', [[[4], [0]], 6, 11], ['~', '~'])],
[('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('beach band edge #1', [[[5]], 3, 9], ['g']),
('regression edge normalisation #1', [[[10, 11, 6, 11, 0], [9, 0, 9, 4, 4]], 5, 7], ['^^ss~', '^^ss~']),
('regression edge normalisation #2', [[[9], [8]], 6, 6], ['^', '^']),
('regression edge normalisation #3',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('regression edge normalisation #4', [[[6], [4], [8], [4], [8]], 5, 9], ['s', 's', 's', 's', 's']),
('control #1', [[[3, 2], [6, 0], [0, 5]], 4, 7], ['~~', '~~', '~~']),
('control #2', [[[3], [0]], 5, 10], ['~', '~'])],
[('corner cell average #1', [[[9, 9], [9, 0]], 3, 8], ['gg', 'gg']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1',
[[[5, 4, 2, 6, 4], [12, 10, 8, 2, 4], [4, 10, 11, 2, 6]], 2, 8],
['ggggg', 'ggggg', '^^ggs']),
('regression edge normalisation #2', [[[6], [4], [8], [4], [8]], 5, 9], ['s', 's', 's', 's', 's']),
('regression edge normalisation #3',
[[[8, 6, 12, 10, 8], [6, 1, 1, 7, 5], [1, 6, 12, 6, 0], [3, 8, 3, 6, 0], [1, 7, 3, 2, 0]], 6, 9],
['~~sss', '~~sss', '~~~~~', '~~~~~', '~~~~~']),
('regression edge normalisation #4', [[[10, 11], [1, 0]], 3, 9], ['gg', 'gg']),
('control #1', [[[1], [10], [0], [2]], 6, 10], ['~', '~', '~', '~']),
('control #2', [[[0]], 6, 9], ['~'])],
[('beach band edge #1', [[[5]], 3, 9], ['g']),
('single row #1', [[[0, 12, 0]], 3, 6], ['^s^']),
('regression edge normalisation #1',
[[[8, 6, 12, 10, 8], [6, 1, 1, 7, 5], [1, 6, 12, 6, 0], [3, 8, 3, 6, 0], [1, 7, 3, 2, 0]], 6, 9],
['~~sss', '~~sss', '~~~~~', '~~~~~', '~~~~~']),
('fault site edge normalisation #1', [[[5, 5], [10, 3], [7, 0]], 2, 10], ['gg', 'gg', 'gg']),
('regression edge normalisation #2', [[[10, 11], [1, 0]], 3, 9], ['gg', 'gg']),
('regression edge normalisation #3', [[[9, 7]], 2, 6], ['^^']),
('control #1', [[[1, 0]], 2, 8], ['~~']),
('control #2', [[[8], [2], [5], [2], [6]], 6, 8], ['~', '~', '~', '~', '~'])]]
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 |
|---|---|---|---|
| corner cell average #1 | ['gg', 'gg'] | ['gg', 'gg'] | Passed |
| beach band edge #1 | ['g'] | ['g'] | Passed |
| single row #1 | ['^s^'] | ['^s^'] | Passed |
| regression edge normalisation #1 | ['gg', 'gg'] | ['gg', 'gg'] | Passed |
| regression edge normalisation #2 | ['^^ss~', '^^ss~'] | ['^^ss~', '^^ss~'] | Passed |
| regression edge normalisation #3 | ['^', '^'] | ['^', '^'] | Passed |
| control #1 | ['~', '~', '~'] | ['~', '~', '~'] | Passed |
| control #2 | ['~~~', '~~~'] | ['~~~', '~~~'] | Passed |
SHA-256 / 34359ce6ad60c3cb3d142339dd41cb21cb052d567b73e342014aefb8beeabd59
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:52.075435+00:00.
Case digest / 9181de45ed19d049a623bf79ab57e4ca082a3fd58da246c0a40ea692103718dc