Skip to content

Tantrix: moves and guided rearrangement (off by default, mixed results) - #67

Merged
barrybecker4 merged 1 commit into
masterfrom
claude/phase4-tantrix
Oct 24, 2026
Merged

barrybecker4 merged 1 commit into
masterfrom
claude/phase4-tantrix

Conversation

@barrybecker4

Copy link
Copy Markdown
Member

Tantrix and the new bb4-optimization hooks: tried, mixed result, so off by default

Draft, for you to decide. Depends on bb4-optimization #34 (merged). Independent of the Red PR (#66).

What it adds

  • TantrixPath supports moves. A Tantrix neighbor is a whole rearranged path (a pivot reversal or swap of sub paths), not a swap, so a move (PathMove) just carries the path it leads to. applyMove(proposeMove(r)) is the same path as getRandomNeighbor(r) (tested).
  • GuidedPivot: pick a tile whose secondary colors don't match its neighbors, and rearrange the path only at that tile and the ones beside it, choosing among the alternatives the same way a random neighbor does. Offered through TantrixPath.proposeGuidedMove and GeneticSearchSolver.proposeGuidedMove.
  • GeneticSearchSolver.GUIDED_MOVE_PROBABILITY feeds the tuned simulated annealing's guidedMoveProbability. It is 0.0, so behavior is unchanged.

Measurements (this machine, 20 s cap, runs that found a solution)

Simulated annealing (the tuned one), 40 runs each:

Tiles Guided probability Solved Median time
9 0 37/40 42 ms
9 0.5 40/40 104 ms
9 1.0 40/40 134 ms
12 0 35/40 70 ms
12 0.5 40/40 616 ms
12 1.0 38/40 605 ms

Genetic search, 10 runs on 9 tiles: 7, 6, 5 solved with probability 0, 0.5, 1.0 (no gain). Global simulated annealing solved 10/10 at every setting.

So annealing becomes more reliable but each solved run takes 2 to 9 times longer, because a guided neighbor builds and scores several rearrangements. Genetic search does not benefit. That is not the clear win Red got, so I left it off. The exact solvers (SHAPE_THEN_ASSIGN and friends) solve these in 20 to 35 ms anyway.

Choices for you

  • Merge as is: the hook is there and tested, one constant turns it on.
  • Set the constant to 0.5 if you would rather have fewer failed annealing runs than a fast typical run.
  • Close it if you don't want the extra code.

Testing

Manual build: GuidedPivotSuite (9 tests) passes; the only failures are the same two Tantrix suites as before (PathPivotPermuterSuite, SubPathMutatorBase load). I could not run Gradle here.


Generated by Claude Code

…y default)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175jMLxrP7wZ3vfj6UfeDZx
@barrybecker4
barrybecker4 marked this pull request as ready for review October 24, 2026 13:51
@barrybecker4
barrybecker4 merged commit 07ac9ff into master Oct 24, 2026
1 check 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