Rubik's Cube Algorithm Finder
- 6 Devlogs
- 17 Total hours
Search a Rubik's Cube for short algorithms that solve a scramble or reach a target pattern.
Search a Rubik's Cube for short algorithms that solve a scramble or reach a target pattern.
I haven’t worked on this in a very long time, haha
So I stopped working on my Rubik’s Cube solver a while ago because it was more or less complete. I never actually submitted it though!
I just spent a few hours cleaning up the repo, fixing some stuff, etc.. It is now presentable and shippable!
I’m not sure exactly how to do this but my demo is actually a hosted web page giving instructions on how to install and run it. It’s not one line but actually two (one for cloning and one for pip install-ing) but I hope that’s okay.
Thanks all!
My program found solutions that I’ve never seen before :)
*
I told it to find an algorithm that takes an F2L pair out (e.g., R U R’ U’). If you are not familiar with the Rubik’s cube, I told it to find a sequence of moves that would result in a certain state.
*
I knew about one, very common sequence (R U R’ U’) and it found 17 others that I had never seen before, in about a minute of search time.
*
Now all that’s left is to optimize it so it can find longer algorithms!
This was meant to be a quick side project. I have now spent more time on this than my main project. What happened??
Successfully searched up to depth 6 (meet-in-the-middle, so essentially up to 12) and solved a 10 move scramble in 50 seconds!
*
This program solved a rubik’s cube that had been scrambled with “F R U’ B’ D’ R’ L F’ B U’”, so ten moves. It correctly found the optimal 10 move solution, as well as many others.
*
This is Python, and I’m already running 18 searches in parallel, so I’m not sure if I’ll be able to improve the raw speed, but I hope to prune more and maybe even do a heuristic-based search in the future.
*
I’m planning on doing some more with this that may involve loosening the constraints. That may or may not speed it up.
Well I thought this would be a quick project. 2.5 hours of programming later: It was not.
*
Since the last devlog, I have a Rubik’s Cube represented correctly in the code now, and it can make moves.
All I have left to do for this part of the project is to fix the str method that returns a visualization of the cube. Right now, it gets the orientation mixed up on up and down quarter turns, but it shouldn’t be too much debugging…
*
Here’s a screenshot of it working next to it not working:
This project is very difficult to debug! It’s just a big lookup table that I entered in by hand… I’m sure I made many typos, so that will be fun.