Discuss Scratch
- Discussion Forums
- » Show and Tell
- » Rubik's cube scramble generators - all you need to know!
- SicknessGradient5
-
Scratcher
14 posts
Rubik's cube scramble generators - all you need to know!
Hello everyone,
Today, I will be providing you with an explanation on the process of making scramble generators in Scratch.
As a Rubik's Cube fan, this was the first idea I came up with. I decided to start with a 2x2 generator as this would probably be easiest.
Here is the explanation:
There are two lists: the possible axis and the variants. The 3 axis are F, U and R. The 3 variants are are normal - 90* ( ), prime - -90* (') and 2 - 180* (2). I named them 1, 2, or 3.
Then the code put together a (possible) move out of the 2 lists. The first move gets automatically added, but the others are only added if they are valid or not.
Valid means if 2 possible moves next to each other can not be done by a simpler move and the 2 moves next to each other are different.
This loop is defined under a block and the block runs until the list of moves is 12. Once there is a scramble, it needs to be displayed. Before, what i did was i made a stupidly long block of “Item x of scramble” attached to a join block which has a space bar. This can be hugely simplified, though.
In the make a move loop, there is already a set output to join move and space key. This works, but is annoyingly puts a space key at the start of the output.
So to fix this, I made it so that it only does this if the output is not blank. Else, there is a join block joining the output, scramble deg. list and the scramble axis list. Now the output is clear and there is a fully generated 2x2 solve when you click the green flag.
I have also made 3x3 and 4x4 versions, which you can find on my profile.
Thanks for reading this. I hope this has given you a better understanding.
The link to the original project:
https://scratch.mit.edu/projects/1207249135/
Thanks for reading, feel free to ask any questions.
Today, I will be providing you with an explanation on the process of making scramble generators in Scratch.
As a Rubik's Cube fan, this was the first idea I came up with. I decided to start with a 2x2 generator as this would probably be easiest.
Here is the explanation:
There are two lists: the possible axis and the variants. The 3 axis are F, U and R. The 3 variants are are normal - 90* ( ), prime - -90* (') and 2 - 180* (2). I named them 1, 2, or 3.
Then the code put together a (possible) move out of the 2 lists. The first move gets automatically added, but the others are only added if they are valid or not.
Valid means if 2 possible moves next to each other can not be done by a simpler move and the 2 moves next to each other are different.
This loop is defined under a block and the block runs until the list of moves is 12. Once there is a scramble, it needs to be displayed. Before, what i did was i made a stupidly long block of “Item x of scramble” attached to a join block which has a space bar. This can be hugely simplified, though.
In the make a move loop, there is already a set output to join move and space key. This works, but is annoyingly puts a space key at the start of the output.
So to fix this, I made it so that it only does this if the output is not blank. Else, there is a join block joining the output, scramble deg. list and the scramble axis list. Now the output is clear and there is a fully generated 2x2 solve when you click the green flag.
I have also made 3x3 and 4x4 versions, which you can find on my profile.
Thanks for reading this. I hope this has given you a better understanding.
The link to the original project:
https://scratch.mit.edu/projects/1207249135/
Thanks for reading, feel free to ask any questions.

- THEREALCATBOB
-
Scratcher
3 posts
Rubik's cube scramble generators - all you need to know!
Would it be possible to do this with different cubes eg Pyraminx and megaminxes. Would you create more lists.
- SicknessGradient5
-
Scratcher
14 posts
Rubik's cube scramble generators - all you need to know!
no, change the items in the list. Yes it is possible!

- MarcusScratcher1217
-
New Scratcher
2 posts
Rubik's cube scramble generators - all you need to know!
I can do it for you!
Last edited by MarcusScratcher1217 (Dec. 24, 2025 15:08:10)
- SicknessGradient5
-
Scratcher
14 posts
Rubik's cube scramble generators - all you need to know!
I can do it for you!Yes, you could remix! Make sure to credit me. You can have a look on my profile and it is one of my earliest projects.
Thank you!
- Discussion Forums
- » Show and Tell
-
» Rubik's cube scramble generators - all you need to know!