Add verified diamond and heart pattern examples

This commit is contained in:
Yaossg 2026-10-17 00:04:47 +08:00
parent 7952207735
commit 2eeb2ff0d4
7 changed files with 189 additions and 1 deletions

View file

@ -40,8 +40,36 @@ def main():
with tempfile.TemporaryDirectory() as tmp:
path=Path(tmp)/'pattern.txt';path.write_bytes(b'?##.\r\n#..?\r\n..#?\r\n')
assert run('--radius',0,'--pattern-file',path,'--dry-run')['pattern']==pattern.split('/')
diamond_fixture=json.loads((HERE/'results/diamond-4x4-example.json').read_text())
assert (HERE/'patterns/diamond-4x4.txt').read_text().splitlines()==diamond_fixture['pattern']
assert all(slime(diamond_fixture['seed48'],diamond_fixture['chunk_x']+dx,diamond_fixture['chunk_z']+dz)==(ch=='#')
for dz,row in enumerate(diamond_fixture['pattern']) for dx,ch in enumerate(row))
heart_fixture=json.loads((HERE/'results/heart-5x5-example.json').read_text())
assert (HERE/'patterns/heart-5x5.txt').read_text().splitlines()==heart_fixture['pattern']
assert all(slime(heart_fixture['seed48'],heart_fixture['chunk_x']+dx,heart_fixture['chunk_z']+dz)==(ch=='#')
for dz,row in enumerate(heart_fixture['pattern']) for dx,ch in enumerate(row))
summary={'cli_scope_and_errors':True,'pattern_inputs':True}
if args.gpu:
heart_poc=run('--x',heart_fixture['chunk_x'],'--z',heart_fixture['chunk_z'],'--radius',0,
'--pattern-file',HERE/'patterns/heart-5x5.txt','--max-results',2000)
heart_hits=heart_poc['rounds'][0]
assert heart_hits['matches']==heart_fixture['single_anchor']['matches']
assert heart_hits['root_jobs']==heart_fixture['single_anchor']['root_jobs']
assert not heart_hits['sample_truncated'] and len(heart_hits['sample'])==heart_hits['matches']
assert len(set(map(tuple,heart_hits['sample'])))==heart_hits['matches']
assert [heart_fixture['seed48'],heart_fixture['chunk_x'],heart_fixture['chunk_z']] in heart_hits['sample']
for seed,x,z in heart_hits['sample']:
assert all(slime(seed,x+dx,z+dz)==(ch=='#') for dz,row in enumerate(heart_fixture['pattern']) for dx,ch in enumerate(row))
summary['heart_pattern_verified_matches']=heart_hits['matches']
diamond_poc=run('--x',diamond_fixture['chunk_x'],'--z',diamond_fixture['chunk_z'],'--radius',0,
'--pattern-file',HERE/'patterns/diamond-4x4.txt','--max-results',64)
diamond_hits=diamond_poc['rounds'][0]
assert diamond_hits['matches']==diamond_fixture['single_anchor']['matches']
assert diamond_hits['root_jobs']==diamond_fixture['single_anchor']['root_jobs']
assert len(diamond_hits['sample'])==64
for seed,x,z in diamond_hits['sample']:
assert all(slime(seed,x+dx,z+dz)==(ch=='#') for dz,row in enumerate(diamond_fixture['pattern']) for dx,ch in enumerate(row))
summary['diamond_pattern_verified_matches']=diamond_hits['matches']
# A mixed-mask regression fixture; this is not the target creeper pattern.
fixture=json.loads((HERE/'testdata/mixed-mask-regression.json').read_text())
face=run('--x',fixture['chunk_x'],'--z',fixture['chunk_z'],'--radius',0,