Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: "solve" cube from random state to any OTHER THAN SOLVED state #44

Open
ragcsalo opened this issue Jul 6, 2019 · 4 comments

Comments

@ragcsalo
Copy link

ragcsalo commented Jul 6, 2019

I would like to have a solution algorhythm that can "solve" the cube from a random state to any specific state, other than a fully solved state.

For example: cube state is U R F D B2, and I would like to reach state R L' B F' L R' F B' directly, without solving the cube first. Can I do this somehow with Cube.js, or it could be a new feature?

@ragcsalo

This comment has been minimized.

@ldez

This comment has been minimized.

@torjusti
Copy link

torjusti commented Dec 25, 2019

This might not be helpful (might also be way too late), but I guess you could invert the target algorithm and then apply the initial cube state algorithm and solve that by trying the solver at different depths. Example:

// (R L' B F' L R' F B')^-1 (U R F D B2) = B F' R L' F B' L R' U R F D B2
const cube = new Cube();
cube.move("B2 D' F' R' U D2 F' B R L' F2 B2")
// cube.solve 20, 19, 18, ...
cube.solve(12) // => B2 D' F' R' U D2 F' B R L' F2 B2

@FoxMcWeezer
Copy link

FoxMcWeezer commented Jan 12, 2024

This is definitely possible. The kociemba python package can do this

https://pypi.org/project/kociemba/

This is the code that does it https://github.com/muodov/kociemba/blob/e2690493b43921732960cd5eeee2b1ee91922a7b/kociemba/ckociemba/search.c#L315C30-L315C30

It takes the "destination" pattern and applies this series of operations to the source pattern. Then Kociemba can be called on the modified source. As a workaround, you can mimic the effect by calculating

const algSrcToSolved = Cube.fromString(currentPattern).solve();
const algDstToSolved = Cube.fromString(selectedScramble).solve();
const algSolvedToDst = Cube.inverse(algDstToSolved);
const algSrcToDst = algSrcToSolved + " " + algSolvedToDst;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants