883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
68 lines
4.5 KiB
Python
68 lines
4.5 KiB
Python
"""Only the newly proved2 flatOcean fishability cases; no old87 replay."""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import struct
|
|
import sys
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from map_asset_preflight import _adt_split_chunk,_adt_split_records,adt_root_flat_ocean_candidate
|
|
|
|
J=Path('runtime/rea-system-jobs-20261022/terrain-liquid-closure-20261025')
|
|
source=json.loads((J/'legacy139-water-operand-leaves.json').read_text())['rows']
|
|
rows=[r for r in source if r['all_blocks_original_ocean_depth_profile_candidate']
|
|
and any(set(map(int,b['Source_cell_flag_values']))&{1,129} for b in r['blocks'])]
|
|
assert len(rows)==2
|
|
OUT=J/'private-nonfishable-Ocean2-ROOT';OUT.mkdir(exist_ok=True)
|
|
results=[];nonfishable=instances=0
|
|
for row in rows:
|
|
old=Path(row['input_ROOT']).read_bytes();new,audit=adt_root_flat_ocean_candidate(old)
|
|
before,after=_adt_split_records(old),_adt_split_records(new)
|
|
liquid=next(d for t,d,z in after if t=='MH2O')
|
|
assert [(t,d,z) for t,d,z in before if t not in ('MHDR','MCNK')]==[
|
|
(t,d,z) for t,d,z in after if t not in ('MHDR','MCNK','MH2O')]
|
|
expected={tuple(b['cell']):b for b in row['blocks']}
|
|
for a,b in zip([d for t,d,z in before if t=='MCNK'],[d for t,d,z in after if t=='MCNK']):
|
|
wa,wb=struct.unpack_from('<32I',a),struct.unpack_from('<32I',b)
|
|
assert wb[0]==wa[0]&~0x3c and wb[24:26]==(0,0)
|
|
assert all(wa[i]==wb[i] for i in range(1,32) if i not in (22,24,25,29))
|
|
ca,cb=_adt_split_records(a[128:]),_adt_split_records(b[128:])
|
|
assert [(t,d,z) for t,d,z in ca if t!='MCLQ']==cb
|
|
x,y=wa[1:3];off,count,attrs=struct.unpack_from('<3I',liquid,(y*16+x)*12)
|
|
original=expected.get((x,y))
|
|
if original is None:
|
|
assert (off,count,attrs)==(0,0,0);continue
|
|
block=next(d for t,d,z in ca if t=='MCLQ');assert count==1
|
|
wet=int.from_bytes(bytes.fromhex(original['wet_bitmap_hex']),'little')
|
|
fish=sum(1<<n for n,v in enumerate(block[656:720]) if v&64)&wet
|
|
deep=sum(1<<n for n,v in enumerate(block[656:720]) if v&128)&wet
|
|
assert struct.unpack_from('<QQ',liquid,attrs)==(fish,deep)
|
|
typ,fmt,lo,hi,ox,oy,w,h,bits,vertex=struct.unpack_from('<HHffBBBBII',liquid,off)
|
|
assert (typ,fmt,lo,hi,ox,oy,w,h)==(2,42,0.,0.,0,0,8,8)
|
|
assert struct.unpack_from('<Q',liquid,bits)[0]==wet
|
|
assert liquid[vertex:vertex+81]==bytes.fromhex(original['depth_bytes_hex'])
|
|
nonfishable+=(wet&~fish).bit_count();instances+=1
|
|
filename=OUT/(Path(row['source_reference']).stem+'.root.adt');filename.write_bytes(new)
|
|
results.append(dict(source_reference=row['source_reference'],input_ROOT=row['input_ROOT'],output_ROOT=str(filename),
|
|
bytes=len(new),sha256=hashlib.sha256(new).hexdigest(),audit=audit))
|
|
assert nonfishable>0
|
|
|
|
# Unknown flags remain held after admitting only the two proven boolean roles.
|
|
top=_adt_split_records(Path(rows[0]['input_ROOT']).read_bytes());ci=next(i for i,(t,d,z) in enumerate(top) if t=='MCNK' and struct.unpack_from('<I',d)[0]&0x3c)
|
|
cell=top[ci][1];children=_adt_split_records(cell[128:]);mi=next(i for i,r in enumerate(children) if r[0]=='MCLQ');block=children[mi][1];at=next(i for i,v in enumerate(block[656:720]) if v in (1,65,129,193))
|
|
for flag in (33,161,225,197):
|
|
changed=bytearray(block);changed[656+at]=flag;parts=list(children);parts[mi]=('MCLQ',bytes(changed),b'')
|
|
data=b''.join(_adt_split_chunk(t,d)+z for t,d,z in parts);records=list(top);records[ci]=('MCNK',cell[:128]+data,b'')
|
|
try:adt_root_flat_ocean_candidate(b''.join(_adt_split_chunk(t,d)+z for t,d,z in records))
|
|
except ValueError:pass
|
|
else:raise AssertionError('Unknown Source wet flag admitted')
|
|
report=dict(status='PASS_NEW_TWO_NONFISHABLE_OCEAN_BOOLEAN_ROLE_CASES',flat_Ocean_denominator=89,
|
|
old87_reused_without_replay=True,new2_admitted=2,complete_flat_legacy_Ocean=89,
|
|
native_instances=instances,nonfishable_wet_quads_preserved=nonfishable,refusals=4,
|
|
Fishable='Source0x40 wet-cell bitmap',Deep='Source0x80 wet-cell bitmap',
|
|
original_nonfishable_control=str(J/'native-original-active-nonfishable-control.json'),
|
|
PBR_material_equivalence_claim=False,all_other_fields_and_payloads_preserved=True,
|
|
old_geometry_alpha_liquid_or_SDK_tests_repeated=False,publishable=False)
|
|
(J/'nonfishable2-focused-check.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
(J/'nonfishable2-candidate-manifest.json').write_text(json.dumps(dict(status=report['status'],rows=results),indent=2)+'\n')
|
|
print(json.dumps(report))
|