3x3x3 Solver in Python

Joined
Nov 29, 2008
Messages
302
I wrote a solver for Rubik's cube in Python. There were several reasons to do so:
1. First of all I wanted to learn Python.
2. I do not think there is any other Python solver around which implements the two-phase algorithm in its fully developed form with symmetry reduction and parallel search for different cube orientations.
3. I quite often get requests from people who build a cube solving robot and which run into problems when they try to use Cube Explorer in their project. It is much easier to integrate some Pyhton modules than to use the quite unflexible interface of Cube Explorer.
4. The solver runs without any changes on any platform (as far as I know)

Some discussion about the solver was in the thread "5x5x5-6x6x6-7x7x7-or-nxnxn"-solvers but dwalton76 rightly proposed tho open a new thread for this subject. I am aware that the solver does nothing better than my Cube Explorer program so it might not be of interest for you.

You can download the project from
https://github.com/hkociemba/RubiksCube-TwophaseSolver

Currently (and for the next days) I have the server module "start_server.py" running on my Raspberry Pi3 at home. So if you just run the module "client_gui.py" and fill in the hostname "http://f9f0b2jt6zmzyo6b.myfritz.net" and the port "8080" my raspi should solve your cube without the need of any tables to be generated on your machine.
If you run "start_server.py" or "example.py" instead some tables are generated which will take about one hour on moderate PC-hardware.
 
It was not too difficult to modify/simplify the two phase solver to get an optimal solver for the 2x2x2 cube. It returns all optimal solutions almost immediately. It needs only one 4MB pruning table which is computed in less than a minute.

You can download the project from
https://github.com/hkociemba/Rubiks2x2x2-OptimalSolver

Speaking of python and 2x2x2 solvers, have you ever looked at the winner of this code golf challenge?
http://codegolf.stackexchange.com/questions/35002/solve-the-rubiks-pocket-cube

The one that is "edit: half a year later: 427 - 50% = 213.5" has a few bug fixes. It is very difficult to read so I started ungolfing it.
https://github.com/dwalton76/rubiks...ster/rubikscubennnsolver/RubiksCube222.py#L29

I need to ungolf it some more, it is still really cryptic.
 
I took a look at https://github.com/dwalton76/rubiks...ster/rubikscubennnsolver/RubiksCube222.py#L29 and I must admit that I do not understand the details. But a look at the "lookup-table-2x2x2-solve.txt" shows me that the approach can be much simplified. The table does not need 8!*3^7= 88179840 entries but only 7!*3^6=3674160 entries if you fix for example the DBL corner and do not use any moves D, B and L.
 
Last edited:
Back
Top