cubejs icon indicating copy to clipboard operation
cubejs copied to clipboard

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

Open ragcsalo opened this issue 5 years ago • 4 comments

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 avatar Jul 06 '19 11:07 ragcsalo

Thanks Ludovic, but you misunderstood me... I know how to solve any random state. I would like to get from a random state to an other specific scrambled state with the fewest turns. So for this the solved cube should be a scrambled one. I know it's weird, I need it for a magic trick. :-)

ragcsalo avatar Jul 06 '19 22:07 ragcsalo

I aleady remove my message :wink:

ldez avatar Jul 06 '19 22:07 ldez

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

torjusti avatar Dec 25 '19 22:12 torjusti

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;

FoxMcWeezer avatar Jan 12 '24 14:01 FoxMcWeezer