c5fc4d7eb5
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>
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
#!/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())
|