world_spawn harness: vanilla's server creates the world on one worker

Trees of neighbouring chunks overlap on chunk corners, and the one
decorated first wins. With several worker threads vanilla decorates in a
different order each run: seed -2080727421395798566 spawned at Y 64, 66
or 72 over 10 runs. The harness retried vanilla up to 3 times and passed
if any run matched, which still failed when none of them gave 72.

With -Dmax.bg.threads=1 (Util.maxAllowedExecutorThreads) vanilla
decorates in its scheduler's order, the one Horizon follows: that seed
gave 72 in 10 of 10 runs, as Horizon does. The other seeds that varied
are fixed too (10 of 10 each: -8171837717659076940 at 0 67 0,
-5296387317982839690 at -16 73 16, -211473008665507967 at 0 66 112).
The retries go, and vanilla's one spawn is compared exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-22 11:05:00 +02:00
parent e730dc1426
commit 0ae1ab2e70
+15 -22
View File
@@ -17,13 +17,13 @@ stops; Horizon's (`horizon-client --dedicated --nogui`) creates its own from
the same server.properties and stops; the `spawn` position of both
level.dat files is compared.
Vanilla is not deterministic everywhere: trees of neighbouring chunks
overlap on chunk corners, and which one is placed last depends on the order
the server's worker threads decorate the chunks. A spawn column on such a
corner can then stand on different leaves from one vanilla run to the next.
When the spawns differ, vanilla creates the world up to RETRIES more times;
Horizon's spawn passes if one of vanilla's runs gives it too, and the seed is
reported as varying in vanilla.
Trees of neighbouring chunks overlap on chunk corners, and which one is
placed first depends on the order the chunks are decorated. With several
worker threads vanilla's order changes from run to run (seed
-2080727421395798566 spawned at Y 64, 66 or 72), so its server runs with one
(`-Dmax.bg.threads`, Util.maxAllowedExecutorThreads): the chunks are then
decorated in its scheduler's order, the one Horizon follows
(decoration_order::vanilla_order), and every run gives the same spawn.
Seeds: the player report's seed (1891623539983467248: Horizon spawned at
-48 -48, vanilla at 152 145), the chunk generation harness's seeds and
@@ -54,7 +54,6 @@ except ImportError:
NAME = 'world-spawn-parity'
REPORT = 1891623539983467248
RETRIES = 3
SEEDS = [REPORT, 12345, -7046029254386353131, 987654321987, 4242, -1, 0x5DEECE66D, 20260607, 777, 0]
RESOURCES = lab.RESOURCES
@@ -132,7 +131,8 @@ def main():
oh.run_logged(['cargo', 'build', '--release', '-p', 'horizon-client', '--bin', 'horizon-client'], build,
'compile-rust', timeout=3600)
binary = target_dir() / ('horizon-client.exe' if os.name == 'nt' else 'horizon-client')
vanilla_server = ['java', '-Xmx2g', '-cp', dependencies, 'net.minecraft.server.Main', 'nogui']
# One worker thread: the chunks decorated in a fixed order (see above).
vanilla_server = ['java', '-Xmx2g', '-Dmax.bg.threads=1', '-cp', dependencies, 'net.minecraft.server.Main', 'nogui']
horizon_server = [binary, '--resources', RESOURCES, '--dedicated', '--nogui']
os.environ['HORIZON_NO_AUDIO'] = '1'
@@ -140,27 +140,20 @@ def main():
t0 = time.time()
a = world_spawn(vanilla_server, build / f'vanilla-{seed}', seed, f'vanilla-{seed}')
b = world_spawn(horizon_server, build / f'horizon-{seed}', seed, f'horizon-{seed}')
runs = [a]
while b not in runs and len(runs) <= RETRIES:
runs.append(world_spawn(vanilla_server, build / f'vanilla-{seed}-{len(runs)}', seed, f'vanilla-{seed}-{len(runs)}'))
return seed, runs, b, time.time() - t0
return seed, a, b, time.time() - t0
spawn_diffs, varying = [], []
spawn_diffs = []
with ThreadPoolExecutor(args.jobs) as pool:
for seed, runs, b, took in pool.map(one, all_seeds):
ok = b in runs
for seed, a, b, took in pool.map(one, all_seeds):
ok = a == b
if not ok:
spawn_diffs.append(seed)
elif len(set(runs)) > 1:
varying.append(seed)
seen = ', '.join(' '.join(map(str, r)) for r in dict.fromkeys(runs))
print(f'{"ok " if ok else "DIFF"} {seed}: vanilla {seen} / horizon {b[0]} {b[1]} {b[2]} '
print(f'{"ok " if ok else "DIFF"} {seed}: vanilla {a[0]} {a[1]} {a[2]} / horizon {b[0]} {b[1]} {b[2]} '
f'(origin chunk {vanilla[seed][2]} {vanilla[seed][3]}; {took:.0f}s)', flush=True)
if ok:
for path in build.glob(f'*-{seed}*'):
shutil.rmtree(path, ignore_errors=True)
print(f'World spawns: {len(all_seeds) - len(spawn_diffs)}/{len(all_seeds)} seeds match in {time.time() - started:.0f}s'
+ (f'; vanilla itself gave several spawns for {len(varying)}: {varying}' if varying else ''))
print(f'World spawns: {len(all_seeds) - len(spawn_diffs)}/{len(all_seeds)} seeds match in {time.time() - started:.0f}s')
if origin_diffs or spawn_diffs:
sys.exit(1)