Read 26.3 template block states and verify jigsaw starts against vanilla
Templates store palette states as id/properties; reading only Name made every template block air. Add a vanilla oracle (structure placement, start selection and Structure.generate over a chunk rectangle), a bench mode dumping Rust starts in the same format, and a comparison script. For seed 0 over 97x97 chunks all 15 jigsaw starts (villages, trial chambers, trail ruins, abandoned camps) match vanilla piece for piece. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare Rust structure starts (chunkgen_bench --starts) with the vanilla oracle.
|
||||
|
||||
usage: compare_structure_starts.py VANILLA RUST [--all]
|
||||
Pieces are compared by type, bounding box and (for jigsaw pieces) position,
|
||||
rotation, ground level delta and junction count. Without --all, vanilla
|
||||
starts of structure types Rust does not generate yet are only counted.
|
||||
"""
|
||||
import collections
|
||||
import sys
|
||||
|
||||
|
||||
def load(path):
|
||||
starts = {}
|
||||
current = None
|
||||
for line in open(path):
|
||||
t = line.split()
|
||||
if not t:
|
||||
continue
|
||||
if t[0] == 'start':
|
||||
current = (int(t[1]), int(t[2]), t[3])
|
||||
starts[current] = [' '.join(t[4:])]
|
||||
elif t[0] == 'piece' and current:
|
||||
starts[current].append(' '.join(t[1:14]))
|
||||
return starts
|
||||
|
||||
|
||||
def main():
|
||||
vanilla, rust = load(sys.argv[1]), load(sys.argv[2])
|
||||
generated = {k[2] for k in rust}
|
||||
matched = 0
|
||||
missing = collections.Counter()
|
||||
for key in sorted(vanilla):
|
||||
if key not in rust:
|
||||
missing[key[2]] += 1
|
||||
if key[2] in generated or '--all' in sys.argv:
|
||||
print('missing', key)
|
||||
continue
|
||||
if vanilla[key] == rust[key]:
|
||||
matched += 1
|
||||
continue
|
||||
v, r = vanilla[key], rust[key]
|
||||
print('DIFF', key, 'pieces', len(v) - 1, len(r) - 1)
|
||||
for i, (a, b) in enumerate(zip(v, r)):
|
||||
if a != b:
|
||||
print(' first difference at line', i, '\n vanilla', a, '\n rust ', b)
|
||||
break
|
||||
for key in sorted(set(rust) - set(vanilla)):
|
||||
print('extra', key)
|
||||
print(f'{matched} of {len(vanilla)} vanilla starts match exactly; not generated by Rust:', dict(missing))
|
||||
return 0 if matched == len(rust) == sum(1 for k in vanilla if k[2] in generated) else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run the vanilla structure-start oracle for a seed and chunk rectangle.
|
||||
|
||||
usage: structure_start_oracle.py OUT SEED X0 Z0 X1 Z1
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
try:
|
||||
from . import lab, test_rust_parity as base
|
||||
except ImportError:
|
||||
import lab
|
||||
import test_rust_parity as base
|
||||
|
||||
|
||||
def main():
|
||||
out, seed, x0, z0, x1, z1 = sys.argv[1:7]
|
||||
lock, jars, libraries = base.verify_artifacts()
|
||||
source = lab.ROOT/'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaStructureStartOracle.java'
|
||||
build = lab.LOCAL/'structure-start-oracle'
|
||||
classes = build/'classes'
|
||||
classes.mkdir(parents=True, exist_ok=True)
|
||||
dependencies = os.pathsep.join(map(str, [jars['server'], *libraries]))
|
||||
subprocess.run(['javac', '--release', str(lock['minecraft']['java_major']), '-proc:none', '-cp', dependencies,
|
||||
'-d', str(classes), str(source)], check=True)
|
||||
result = subprocess.run(['java', '-Xmx2G', '-cp', str(classes)+os.pathsep+dependencies,
|
||||
'dev.horizonlab.parity.VanillaStructureStartOracle', out, seed, x0, z0, x1, z1],
|
||||
capture_output=True, text=True)
|
||||
if result.returncode:
|
||||
lines = [line for line in (result.stdout + result.stderr).splitlines() if 'Exception' in line or 'Caused' in line]
|
||||
raise SystemExit('oracle failed: ' + ' | '.join(lines[:5]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user