# Rubik's Cube Simulator in Excel



## Adrian0 (Mar 19, 2014)

Hey guys, 

so after learning a little bit of Excel VBA I managed to write some code that simulates a 3x3x3 Rubik's cube in Excel.







I first saw a similar attempt here: http://thepunditpunnedit.wordpress.com/2011/08/28/excel-rubiks-cube/

But every turn had a huge lag since the code it seems is just based on copy-pasting to do the turns. With my attempt I did the calculations with arrays before outputting the values to the excel sheet so the turns are much more fast and smooth to do.

Other features include: 

x,y,z rotations
3-D view of the cube (F,U,R faces)
Scrambler, takes into account previous move so not to undo it
Seconds timer
Will check to see if solved to stop the timer

Download link:
http://www.mediafire.com/download/wd83a734ut0vm3h/Rubik's+Cube+Simulator.xlsm

Feel free to make your own changes, improve it, etc.


----------



## Cuber9991 (Mar 19, 2014)

That is cool. I didn't even know you could do stuff like that on excel :tu


----------



## kinch2002 (Mar 19, 2014)

Nice! I'll download later!

Was thinking about doing this myself soon actually, as I already have arrays that store cube positions and turns from my Excel CFOP solver.

Why is the timer only seconds? You can use the inbuilt timer to give 1/256 second accuracy


----------



## kinch2002 (Mar 19, 2014)

Sorry, double post, but I downloaded it now anyway.
I like it! Just a few comments.

Why does the scrambling take so long?
Can you figure out a way to allow standard sim controls using the keyboard?
As a radical option, allow the user to hide as many tiles as he wants. You can solve the whole cube by looking at 2 stickers positions only


----------



## Adrian0 (Mar 19, 2014)

kinch2002 said:


> Sorry, double post, but I downloaded it now anyway.
> I like it! Just a few comments.
> 
> Why does the scrambling take so long?
> ...




Is the scramble time too unreasonable? For me 20-30 scrambles takes less than a second, one way to improve it I think would be to not have the 'check if solved' subroutine tied to every single time a move is made or also to turn off the screen updating.

Also, I tried to figure out if it was possible to use milliseconds in the timer but apparently in VBA the timer functions, like Now(), only return seconds. If you or anyone think you can improve this feel free to mess around with the code. The subroutine I use for the Timer is called Timer() near the bottom of the code, you can access it by going to Developer->Visual Basic -> Module 1. (Also if you're gonna change that also change in Reset() to update to from count.Value = count.Value +1, to whatever increment it will now be doing or whatever suits your change)

Lastly, I added keyboard controls to it here: http://www.mediafire.com/download/g...ed.xlsm#39;s_Cube_Simulator_-_keys_added.xlsm

Right now they are set so that clockwise left = shift + L, counter-clockwise left = ctrl + shift + L, etc.

You can customize the keys by going to Developer -> Macros -> click the turn you want, such as left_turn or left_turn_p, -> options-> then add your shortcut key
And also you can move the buttons around too.


----------



## kinch2002 (Jul 31, 2014)

Here's a fun version I just made quickly:
Dropbox Link
Cell C1 stores the chance that the move you choose is actually executed. If it isn't, a random move will be done 
I wonder how low you can make that value, and still complete the cube...


----------



## 10461394944000 (Jul 31, 2014)

kinch2002 said:


> Here's a fun version I just made quickly:
> Dropbox Link
> Cell C1 stores the chance that the move you choose is actually executed. If it isn't, a random move will be done
> I wonder how low you can make that value, and still complete the cube...



2:08 lel


----------



## kinch2002 (Aug 1, 2014)

10461394944000 said:


> 2:08 lel


Hehe nice. Now try putting 0.51 in C1. I'm pretty sure 0.5 is the threshold to make it possible (without getting really lucky).

Actually I just realised it sucks to have to click buttons to move. I'll add standard sim controls when I get home.


----------



## kinch2002 (Aug 2, 2014)

Standard Sim Controls added. You need to press reset to get them working, and also the scramble button wasn't working too well for me...not sure what's up with that. But spamming it enough times gave me a decent scramble.
Dropbox


----------

