• Welcome to the Speedsolving.com, home of the web's largest puzzle community!
    You are currently viewing our forum as a guest which gives you limited access to join discussions and access our other features.

    Registration is fast, simple and absolutely free so please, join our community of 40,000+ people from around the world today!

    If you are already a member, simply login to hide this message and begin participating in the community!

Rubik's Cube Simulator in Excel

Adrian0

Member
Joined
Jul 4, 2013
Messages
10
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.

6AGUFNt.png


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.
 

Attachments

  • Capture.PNG
    Capture.PNG
    76.2 KB · Views: 19
Last edited:

kinch2002

Premium Member
Joined
Dec 22, 2008
Messages
2,504
Location
Guildford! UK!
WCA
2009SHEP01
YouTube
Visit Channel
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

Premium Member
Joined
Dec 22, 2008
Messages
2,504
Location
Guildford! UK!
WCA
2009SHEP01
YouTube
Visit Channel
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 :p
 

Adrian0

Member
Joined
Jul 4, 2013
Messages
10
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 :p


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.
 
Last edited:

kinch2002

Premium Member
Joined
Dec 22, 2008
Messages
2,504
Location
Guildford! UK!
WCA
2009SHEP01
YouTube
Visit Channel
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
 
Top