LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rubik's cube solver

Hi All,

Just though I would share a silly side project I have been working on, a G based Rubik's cube solver. Smiley Happy

It is far from perfect, but it brought me some joy so I thought I would share it with the community. It mostly seems to work, I won't go into too many details here, but basically you start off with a clean cube, apply some random operations to it, and then get the algorithm to solve. I supppose it would be easy enough to change to allow user defined starting positions, but it is basically proof of concept for the algorithm so I haven't bothered taking it any further. Note, the solving algorithm is based on Dan Knight's 7 step solution, which works quite well once you get the hang of it. The solution is far, far from optimal, and in fact the vast majority of cubes can be solved in 17 moves or less (belive it or not)...

Attached is a zip of the files, note, it uses the openG 3D buttons, so I manually added that library to the zip. There are controls on the left hand side of the screen to apply the primitive transformations to the cube if you wanted to do it manually.

The randomisation used mathscript to allow for starting with a known random number seed (is this possible with the normal random functions?), if you dont have this installed feel free to use any random number generator Smiley Happy

I would be interested to hear comments or see other G code for solving the cube, or if I have left something out of the zip file.

Happy cubing...

nrp

ps: my record for solving the cube is about 2 mins, which is nowhere near the pros! Oh well...


Message 1 of 11
(6,725 Views)
care to share it in 8.2?
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 11
(6,724 Views)
Gabi1,

It is attached in 8.2 (I think), but I dont think its going to work properly as I used the for loop conditional stop quite a bit. If I get enough requests I will see if I can rework the logic to remove  the conditional for, its not difficult but just a  matter of finding the time!
0 Kudos
Message 3 of 11
(6,716 Views)
Very nice! 🙂

nrp wrote:
The randomisation used mathscript to allow for starting with a known random number seed (is this possible with the normal random functions?)
Use e.g. the random white noise from the "signal processing..signal generation" palette. 🙂 It has a seed input.

nrp wrote:
I would be interested to hear comments or see other G code for solving the cube, or if I have left something out of the zip file.
Do you know the guys who made the LabVIEW robot solver?
 
Message 4 of 11
(6,561 Views)

needs a bit reworking in the randomisation for 8.2, but works great!

very nice:) . it did it in 22 steps.

we could make a nice picture control for 3D cube now...:)

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 5 of 11
(6,550 Views)
Thanks for the tip on the random seed, I hadn't thought of that!

That solver is really neat, I have seen some amazing videos on youtube. Unfortunately the mechanical bit is totally out of my realm Smiley Very Happy


0 Kudos
Message 6 of 11
(6,495 Views)
22 steps? Wow thats lucky. How are you counting the steps? I would have thought it uses hundreds of steps as the algorithm is totally inefficient...

I tried using a 3D control, but gave up after about an hour or so with all I had to show for my time was a single lit block! Its definitely worth doing though to help with the visualisation Smiley Happy
0 Kudos
Message 7 of 11
(6,493 Views)

on your state machine loop, place an indicator on the index. then substract the value from the "solve" state to the final value after solving. you get nb of steps.

yes it would be neat the 3D picture control. when i get time (holidays soon!) i'll try to play with it.

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 8 of 11
(6,489 Views)
Gabi1,

I thought something was suspicious!, that will not work as some of the steps are looped internally, i.e. not everything loops through the main state-machine.
0 Kudos
Message 9 of 11
(6,469 Views)


nrp wrote:
Gabi1,

I thought something was suspicious!, that will not work as some of the steps are looped internally, i.e. not everything loops through the main state-machine.


oops! Smiley Tongue

i only glanced at it yesterday night at 1am during my teeth brush... will study it tonight 🙂

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 10 of 11
(6,463 Views)