adrianliaw / PyCuber

Rubik's Cube solver in Python
MIT License
199 stars 47 forks source link

Output from CFOPSolver doesn't actually solve a cube #16

Closed agraubert closed 8 years ago

agraubert commented 8 years ago

I was messing around with PyCuber and I found something interesting about the CFOPSolver. It doesn't always solve a cube back to its original state when a cube differs greatly from the original state (the faces always end up solved, but sometimes the faces are in a reversed order). Additionally, the output from the solver doesn't actually solve the cube if done manually. Here is the output from CFOPSolver after I made 10,000 randomly generated turns:

Cross: R2 F D F' D R' D'
F2L('green', 'orange'): U F' U F R U R'
F2L('orange', 'blue'): y U R U R' U R U' R'
F2L('blue', 'red'): y R U2 R' F' U2 F U F' U2 F
F2L('red', 'green'): y F' U' F U F' U' F
OLL:  F R U R' U' R U R' U' F'
PLL:  U R' U L' U2 R U' R' U2 L R U'

FULL: R2 F D F' D R' D' U F' U F R U R' U B U B' U B U' B' L U2 L' B' U2 B U B' U2 B L' U' L U L' U' L2 F U F' U' F U F' U' L' U F' U B' U2 F U' F' U2 B F U'
R2 F D F' D R' D' U F' U F R U R' U B U B' U B U' B' L U2 L' B' U2 B U B' U2 B L' U' L U L' U' L2 F U F' U' F U F' U' L' U F' U B' U2 F U' F' U2 B F U'

Specifically the 'FULL:' sequence does not revert the cube its original solved state (and it doesn't get into that kinda-solved state that I mentioned above, either).

I attached files to reproduce this issue. turnsequence.txt is a randomly generated 10,000 turn sequence to get the cube from the solved state to a sufficiently random state (and is the exact sequence I used when I discovered this issue). inversesequence.txt is the inverse of that sequence (it directly undoes the first sequence). Lastly, cfopsolution.txt is the FULL: sequence produced by CFOPSolution.

Two other steps I did to verify:

(pycuber 0.2.1)

adrianliaw commented 8 years ago

Hi @agraubert, it seems like you accidentally put the solution after FULL: and the output returned by CFOPSolver.solve function (which is the exact same solution) together, resulted into an 120 steps formula that do the solution twice.

The CFOPSolver.solve function prints out the solution step-by-step, and also prints out the full solution in one line after FULL:, and finally, return the solution formula. You probably used something like print(solver.solve()), so it will also print out the result returned by the function, which confused you.

Printed in the function -->  FULL: R2 F D F' D R' D' U F' U F R U R' U B U B' U B U' B' L U2 L' B' U2 B U B' U2 B L' U' L U L' U' L2 F U F' U' F U F' U' L' U F' U B' U2 F U' F' U2 B F U'
Returned by solver.solve --> R2 F D F' D R' D' U F' U F R U R' U B U B' U B U' B' L U2 L' B' U2 B U B' U2 B L' U' L U L' U' L2 F U F' U' F U F' U' L' U F' U B' U2 F U' F' U2 B F U'

You can either not use print, or use solver.solve(suppress_progress_messages=True), to avoid confusion.