# Basic Rubiks Cube

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## WHAT IS IT?

This is a 3D version of a rubix cube I made to play around with

## THINGS TO DO

Use "Spin" to spin the cube arround the z-axis

Use "Roll" to roll cube around y-axis

Use "R" to spin the right face clockwise

All other moves are composed of these three elementry moves

## SOLVING

The notation and pre-built algorithms support solving the cube using this guide:

https://www.rubiks.com/uploads/general_content/Rubiks_cube_3x3_solution-en.pdf

## Copyright

Rob Patchin, 2017

Please use and improve!

## Comments and Questions

turtles-own [ x_solve y_solve z_solve piece-type] breed [cubes a-cube] breed [stickers a-sticker] globals [i j k ] to setup clear-all setxyz 20 -40 16 ; set the observer position build-cube end to mix set i 0 while [i < 20] [ set j random 3 if j = 0 [ rotate-face ] if j = 1 [ roll-cube ] if j = 2 [ spin-cube ] set i (i + 1)] paint-neighbors end to solve-1 ; ask patch 3 3 -4 [ask turtles-here [set j color]] ; if j = color-1 [roll-cube roll-cube] ; repeat 4 [ ; ask patch -1 3 0 [ask turtles-here [set i color]] ; ifelse i = color-1 [roll-cube] [spin-cube]] ; ask patch 3 3 4 [ask turtles-here [set j color]] ; if j = color-1 [show "sucess"] end ;; This procedure creates 27 turtles in puts them in a cube to build-cube crt 27 [ set x_solve (who mod 3) set y_solve ((int (who / 3)) mod 3) set z_solve ((int (who / 9)) mod 3) set breed cubes setxyz (x_solve * 3) (y_solve * 3) (z_solve * 3 - 3) set color 35 set heading 0] ask turtle 13 [die] ask cubes with [y_solve = 2] [hatch 1 [set color 25 set breed stickers]] ask cubes [set heading 90] ask cubes with [x_solve = 2] [hatch 1 [set color 105 set breed stickers]] ask cubes [set heading 180] ask cubes with [y_solve = 0] [hatch 1 [set color 15 set breed stickers]] ask cubes [set heading 270] ask cubes with [x_solve = 0] [hatch 1 [set color 55 set breed stickers]] ask cubes [set heading 0 tilt-up 90] ask cubes with [z_solve = 2] [hatch 1 [set color 9.9 set breed stickers]] ask cubes [set heading 0 tilt-down 180] ask cubes with [z_solve = 0] [hatch 1 [set color 45 set breed stickers]] ask cubes [die] ask stickers [fd 1] ask stickers [create-links-with turtles-on neighbors] ask turtles [ if count link-neighbors = 2 [set piece-type "corner"] if count link-neighbors = 0 [set piece-type "face"] if count link-neighbors = 1 [set piece-type "edge"]] ; paint-neighbors end to find-face end to rotate-face ask stickers-on patch 7 0 3 [setxyz 7 6 2] ask stickers-on patch 7 0 -3 [setxyz 7 0 3] ask stickers-on patch 7 6 -3 [setxyz 7 0 -3] ask stickers-on patch 7 6 3 [setxyz 7 6 -3] ask stickers-on patch 7 6 2 [setxyz 7 6 3] ask stickers-on patch 7 3 3 [setxyz 7 6 1] ask stickers-on patch 7 0 0 [setxyz 7 3 3] ask stickers-on patch 7 3 -3 [setxyz 7 0 0] ask stickers-on patch 7 6 0 [setxyz 7 3 -3] ask stickers-on patch 7 6 1 [setxyz 7 6 0] ask stickers-on patch 6 0 4 [setxyz 6 7 4] ask stickers-on patch 6 -1 -3 [setxyz 6 0 4] ask stickers-on patch 6 6 -4 [setxyz 6 -1 -3] ask stickers-on patch 6 7 3 [setxyz 6 6 -4] ask stickers-on patch 6 7 4 [setxyz 6 7 3] ask stickers-on patch 6 3 4 [setxyz 6 7 4] ask stickers-on patch 6 -1 0 [setxyz 6 3 4] ask stickers-on patch 6 3 -4 [setxyz 6 -1 0] ask stickers-on patch 6 7 0 [setxyz 6 3 -4] ask stickers-on patch 6 7 4 [setxyz 6 7 0] ask stickers-on patch 6 -1 3 [setxyz 6 7 4] ask stickers-on patch 6 0 -4 [setxyz 6 -1 3] ask stickers-on patch 6 7 -3 [setxyz 6 0 -4] ask stickers-on patch 6 6 4 [setxyz 6 7 -3] ask stickers-on patch 6 7 4 [setxyz 6 6 4] paint-neighbors end to spin-cube set i -3 while [i < 4] [ ask stickers-on patch 0 -1 i [setxyz 7 7 i] ask stickers-on patch -1 6 i [setxyz 0 -1 i] ask stickers-on patch 6 7 i [setxyz -1 6 i] ask stickers-on patch 7 0 i [setxyz 6 7 i] ask stickers-on patch 7 7 i [setxyz 7 0 i] ask stickers-on patch 3 -1 i [setxyz 7 7 i] ask stickers-on patch -1 3 i [setxyz 3 -1 i] ask stickers-on patch 3 7 i [setxyz -1 3 i] ask stickers-on patch 7 3 i [setxyz 3 7 i] ask stickers-on patch 7 7 i [setxyz 7 3 i] ask stickers-on patch -1 0 i [setxyz 7 7 i] ask stickers-on patch 0 7 i [setxyz -1 0 i] ask stickers-on patch 7 6 i [setxyz 0 7 i] ask stickers-on patch 6 -1 i [setxyz 7 6 i] ask stickers-on patch 7 7 i [setxyz 6 -1 i] set i (i + 3) ] set i -4 while [i < 5] [ ask stickers-on patch 0 0 i [setxyz 7 7 i] ask stickers-on patch 0 6 i [setxyz 0 0 i] ask stickers-on patch 6 6 i [setxyz 0 6 i] ask stickers-on patch 6 0 i [setxyz 6 6 i] ask stickers-on patch 7 7 i [setxyz 6 0 i] ask stickers-on patch 0 3 i [setxyz 7 7 i] ask stickers-on patch 3 6 i [setxyz 0 3 i] ask stickers-on patch 6 3 i [setxyz 3 6 i] ask stickers-on patch 3 0 i [setxyz 6 3 i] ask stickers-on patch 7 7 i [setxyz 3 0 i] set i (i + 8) ] paint-neighbors end to roll-cube set i 0 while [i < 7] [ ask stickers-on patch 0 i 4 [setxyz 0 i 5] ask stickers-on patch -1 i -3 [setxyz 0 i 4] ask stickers-on patch 6 i -4 [setxyz -1 i -3] ask stickers-on patch 7 i 3 [setxyz 6 i -4] ask stickers-on patch 0 i 5 [setxyz 7 i 3] ask stickers-on patch 3 i 4 [setxyz 0 i 5] ask stickers-on patch -1 i 0 [setxyz 3 i 4] ask stickers-on patch 3 i -4 [setxyz -1 i 0] ask stickers-on patch 7 i 0 [setxyz 3 i -4] ask stickers-on patch 0 i 5 [setxyz 7 i 0] ask stickers-on patch 6 i 4 [setxyz 0 i 5] ask stickers-on patch -1 i 3 [setxyz 6 i 4] ask stickers-on patch 0 i -4 [setxyz -1 i 3] ask stickers-on patch 7 i -3 [setxyz 0 i -4] ask stickers-on patch 0 i 5 [setxyz 7 i -3] set i (i + 3) ] set i -1 while [i < 9] [ ask stickers-on patch 0 i 0 [setxyz 0 i 5] ask stickers-on patch 3 i -3 [setxyz 0 i 0] ask stickers-on patch 6 i 0 [setxyz 3 i -3] ask stickers-on patch 3 i 3 [setxyz 6 i 0] ask stickers-on patch 0 i 5 [setxyz 3 i 3] ask stickers-on patch 0 i 3 [setxyz 0 i 5] ask stickers-on patch 0 i -3 [setxyz 0 i 3] ask stickers-on patch 6 i -3 [setxyz 0 i -3] ask stickers-on patch 6 i 3 [setxyz 6 i -3] ask stickers-on patch 0 i 5 [setxyz 6 i 3] set i (i + 8) ] paint-neighbors end to paint-neighbors clear-patches ask stickers [ paint-stickers neighbors ] end to paint-stickers [agents] ask agents [ set pcolor [color] of myself - 2 ] end ;;Robert Patchin 2017

There is only one version of this model, created almost 3 years ago by Robert Patchin.

## Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.