Skip to content

Phase 5: the Rust contact search, with roofs, pruning and symmetry - #6

Merged
madeline-v-brandt merged 3 commits into
mainfrom
phase-5-rust-contact-dfs
Nov 11, 2026
Merged

madeline-v-brandt merged 3 commits into
mainfrom
phase-5-rust-contact-dfs

Conversation

@kuvychko

Copy link
Copy Markdown
Member

Chained on #5 (phases 2 to 4 into main); the base is phase-3-geometry, so the diff is phase 5 alone.

What it adds

rust.contact_dfs: the corner contact search of the Python prototype, run in one call into Rust, in the footprint and relief regimes. It solves all 16 corpus fixtures, runs every search to its end, and every assembly it returns passes the independent validator.

Every rule beyond the prototype's is an option that can be switched off, and the whole search is tested to find the same assemblies with it on and off. The point is to measure what makes a puzzle hard and what helps, not to be fast.

  • Roofs in candidate generation: height at the corner, then the step along every shared edge stretch. Candidate set corner-contact-relief/1.
  • Cavity pruning by area and least width.
  • Closure pruning: a straight run between two convex corners must be a sum of whole edges of different remaining pieces, a convex corner a sum of their angles.
  • Lookahead of one placement, off by default.
  • The tray's rotations: an anchor piece held to one sector, and canonical forms (tiling-search::canonical) to drop repeats. tray_rotations=all restores the prototype's counting.
  • Candidate order: matched edges, as generated, or random from the seed.

Also SolverSpec with a candidate set per regime, maxplus-solve --option NAME=VALUE, and tiling-geometry's proptest strategies behind a testing feature.

Findings

Relative to the candidates generated, in f64 with tolerances. Tables and arguments are in docs/algorithms.md.

  • In relief every corpus puzzle has exactly one assembly and the search hardly backtracks: at most 146 nodes for 20 pieces with every rule off. The roofs are what make these puzzles easy.
  • As footprints, six of eight have one assembly; rat1-flat has 101 and rat2-flat has 2.
  • Piece count is a poor measure of difficulty: the 20-piece rat2-flat takes an eighth of the nodes of the 16-piece new1-flat.
  • Closure pruning is the rule that works on the smaller footprints; the anchor matters most on the 16-piece ones; cavity pruning does almost nothing; lookahead cuts nodes but wins in states examined on only three of eight footprints.
  • The two 16-piece footprints take about a million nodes each under every configuration tried.

Tests

  • Exit criterion: tests/corpus/test_rust_contact_dfs.py. All 16 fixtures in their own regime, validated, key found once, first-solution and exhaust times separate; same assemblies as the prototype on the five fixtures it can finish, and the same node counts with the additions off.
  • Differential: cavities against a Shapely difference, roof steps against the validator's seam mismatch, canonical forms against the polygon-set oracle.
  • Rust properties over random tilings cut by chords.
  • Architecture: a production solver makes one _native call; every search rule is a documented switch.
  • Eleven rules were broken by hand, one at a time, and the tests watched to fail.

A bug this found: canonical forms ignored that congruent pieces are stored at unrelated rotations. The validator caught it on the synthetic fixtures.

The two 16-piece whole searches are marked slow and still run in CI; they add a few minutes. The roadmap marks phase 5 as awaiting CI and is ticked in a follow-up commit once both platforms pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jfg9fgTR9LYn4D2rTtfifs

kuvychko and others added 3 commits November 10, 2026 17:51
rust.contact_dfs runs the corner contact search in one call into Rust,
in the footprint and relief regimes. It solves all 16 corpus fixtures,
runs every search to its end, and every assembly it returns passes the
independent validator.

Every rule beyond the prototype's is an option that can be switched
off, and the whole search is tested to find the same assemblies either
way: roof continuity in candidate generation, cavity pruning, closure
pruning, a one-placement lookahead (off by default), an anchor piece
and canonical forms to take out the tray's rotations, and the order in
which candidates are tried. docs/algorithms.md has the argument for
each rule and the ablation tables.

Also: cavities and roof steps in tiling-geometry, canonical forms in
tiling-search, differential tests against Shapely and the validator,
SolverSpec with a candidate set per regime, and maxplus-solve --option.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jfg9fgTR9LYn4D2rTtfifs
@kuvychko
kuvychko changed the base branch from phase-3-geometry to main November 11, 2026 14:52
@madeline-v-brandt
madeline-v-brandt merged commit d9fc3c2 into main Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants