Giter Site home page Giter Site logo

cube's Issues

Hangs forever if a corner's been twisted

If someone rotated a corner of the cube before giving it to me, perhaps as a prank, this isn't caught by the current codebase; it just hangs indefinitely.

>>> from rubik.cube import Cube
>>> from rubik.solve import Solver
>>> s = Solver(Cube('orwowgwywgbgrgrbobowyggbrrbybrgowoygryrbbgoobyoyrywyww'.upper()))
>>> s.solve()
^Cā€¦

For other non-solvable states, such as a flipped edge, the code does catch these.

But when it comes to rotated corners, it just enters an infinite loop.

Solver Moves

First and foremost, great job! I have a question about the solver. I might be missing something here, or I could be using it incorrectly. In the example below, I input an already solved cube. My confusion is why the solver is generating a solving sequence for a cube that's already solved. Shouldn't the solver's "moves" array be empty in such a case?

Code:

c = Cube("OOOOOOOOOYYYWWWGGGBBBYYYWWWGGGBBBYYYWWWGGGBBBRRRRRRRRR")
print(c)
print(c.is_solved())
solver = Solver(c)
solver.solve()
print(solver.moves)

Output:

    OOO
    OOO
    OOO
YYY WWW GGG BBB
YYY WWW GGG BBB
YYY WWW GGG BBB
    RRR
    RRR
    RRR

True

['Z', 'Zi', 'D', 'B', 'Di', 'B', 'B', 'B', 'B', 'D', 'Bi', 'Di', 'Z', 'D', 'B', 'Di', 'B', 'B', 'B', 'B', 'D', 'Bi', 'Di', 'Z', 'D', 'B', 'Di', 'B', 'B', 'B', 'B', 'D', 'Bi', 'Di', 'Z', 'D', 'B', 'Di', 'B', 'B', 'B', 'B', 'D', 'Bi', 'Di', 'Z', 'B', 'L', 'Bi', 'Li', 'Bi', 'Di', 'B', 'D', 'B', 'Bi', 'Di', 'B', 'D', 'B', 'L', 'Bi', 'Li', 'Z', 'B', 'L', 'Bi', 'Li', 'Bi', 'Di', 'B', 'D', 'B', 'Bi', 'Di', 'B', 'D', 'B', 'L', 'Bi', 'Li', 'Z', 'B', 'L', 'Bi', 'Li', 'Bi', 'Di', 'B', 'D', 'B', 'Bi', 'Di', 'B', 'D', 'B', 'L', 'Bi', 'Li', 'Z', 'B', 'L', 'Bi', 'Li', 'Bi', 'Di', 'B', 'D', 'B', 'Bi', 'Di', 'B', 'D', 'B', 'L', 'Bi', 'Li', 'Z', 'X', 'X', 'D', 'F', 'R', 'Fi', 'Ri', 'Di', 'Xi', 'Xi', 'X', 'X', 'Zi', 'Li', 'Fi', 'L', 'D', 'F', 'Di', 'Li', 'F', 'L', 'F', 'F', 'Z', 'F', 'Li', 'Fi', 'L', 'D', 'F', 'Di', 'Li', 'F', 'L', 'F', 'Li', 'Fi', 'L', 'D', 'F', 'Di', 'Li', 'F', 'L', 'F', 'F', 'F', 'Li', 'Fi', 'L', 'D', 'F', 'Di', 'Li', 'F', 'L', 'F', 'Xi', 'Xi', 'X', 'X', 'F', 'F', 'R', 'F', 'Ri', 'F', 'R', 'F', 'F', 'Ri', 'F', 'F', 'Ri', 'Fi', 'R', 'Fi', 'Ri', 'F', 'F', 'R', 'F', 'F', 'F', 'F', 'Xi', 'Xi', 'X', 'X', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'R', 'R', 'F', 'D', 'Ui', 'R', 'R', 'Di', 'U', 'F', 'R', 'R', 'Z', 'Z', 'Z', 'Z', 'R', 'R', 'F', 'D', 'Ui', 'R', 'R', 'Di', 'U', 'F', 'R', 'R', 'Z', 'Di', 'Li', 'Ri', 'S', 'Ri', 'Ri', 'S', 'S', 'Ri', 'Fi', 'Fi', 'R', 'Si', 'Si', 'Ri', 'Ri', 'Si', 'R', 'Fi', 'Fi', 'L', 'D']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.