Skip to content

Implement backtracking for multi_phase_search, set max depth for 4x4x4 phase3 solver - #165

Open
Nogesma wants to merge 2 commits into
cubing:mainfrom
Nogesma:main
Open

Implement backtracking for multi_phase_search, set max depth for 4x4x4 phase3 solver#165
Nogesma wants to merge 2 commits into
cubing:mainfrom
Nogesma:main

Conversation

@Nogesma

@Nogesma Nogesma commented Jul 22, 2026

Copy link
Copy Markdown

Switch the SearchPhase trait solutions to not take a mutable reference, and instead use a RefCell to get interior mutability for increasing the size of the prune table.

Also sets the max_depth_exclusive to 15 for the 4x4x4 phase3.
From what I benchmarked, setting it to 14, as it was in the comment makes it take several times longer to solve. Increasing it to 15 fixes it.

This is basically a ~1% regression for scrambles that were finding a solution without backtracking, due to the introduction of the RefCell, but a improvement of 10-35% for the rest. The benchmark code I used is in src/lib/bin/bench4x4x4.rs

Nogesma added 2 commits July 22, 2026 18:49
Switch the SearchPhase trait solutions to not take a mutable reference,
and instead use a RefCell to get interior mutability for increasing the
size of the prune table.
@lgarron

lgarron commented Jul 22, 2026

Copy link
Copy Markdown
Member

Backtracking for multi-phase is definitely something I've wanted for a while!

Before I take a look, I need to ask: was an LLM or similar tool used in preparing this PR in any way?

@Nogesma

Nogesma commented Jul 22, 2026

Copy link
Copy Markdown
Author

The code is entirely mine, but I did use an LLM to get better understanding of the repo before I implemented this ie. asking question about the code, but never asking it to write code.

@Nogesma

Nogesma commented Jul 29, 2026

Copy link
Copy Markdown
Author

After testing a bit more, I noticed some scrambles can take a lot more time (~400s). This is due to the solver not finding a solution at depth 14 for phase3, for multiple phase2 solutions.
I checked how tnoodle handles this, and they actually increase the max depth after a number of failed attempts (100 in their case). And they also seem to store the phase2 results to retry them after increasing the depth.

I was thinking of adding a field to IndividualSearchOptions to handle the increase in max depth.
I think in the case of 4x4, because of the slow phase3, having it increase the depth after 2-3 attempts would yield the best results.
As phase2 is so fast compared to phase3, I don't think storing the result is really needed for now. But maybe restarting the entire phase2 search from the start is required.

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