cubejs
cubejs copied to clipboard
Feature request: "solve" cube from random state to any OTHER THAN SOLVED state
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?
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. :-)
I aleady remove my message :wink:
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
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;