« Go Back to Phase 1

Given our previous discussion of the basic twists on a Rubik's Cube, it's rather simple to represent the basic transformations given our common data structure.

This was all done very manually and tediously.

[In the future, I will be providing print-outs so you yourself can manually do the work of mapping out the moves!]

Note that using Array.create 12 0 or Array.create 8 0 is a blessing, not having to write out [|0; 0; ... many times over!

These come up when moves like U and R do not flip/twist any edged, for example.

let R = 
    { EdgePositions   = [| 0; 10; 2; 3; 4; 8; 6; 7; 1; 9; 5; 11 |]
      EdgeFlips       = Array.create 12 0
      CornerPositions = [| 1; 7; 2; 3; 0; 5; 6; 4 |]   
      CornerTwists    = [| 1; 2; 0; 0; 2; 0; 0; 1 |] } 

let U = 
    { EdgePositions   = [| 3; 0; 1; 2; 4; 5; 6; 7; 8; 9; 10; 11|]
      EdgeFlips       = Array.create 12 0
      CornerPositions = [| 3; 0; 1; 2; 4; 5; 6; 7 |]
      CornerTwists    = Array.create 8 0 }

let F = 
    { EdgePositions   = [| 8; 1; 2; 3; 9; 5; 6; 7; 4; 0; 10; 11 |]
      EdgeFlips       = [| 1; 0; 0; 0; 1; 0; 0; 0; 1; 1;  0;  0 |]
      CornerPositions = [| 4; 1; 2; 0; 5; 3; 6; 7 |]
      CornerTwists    = [| 2; 0; 0; 1; 1; 2; 0; 0 |] }

let L = 
    { EdgePositions   = [| 0; 1; 2; 9; 4; 5; 6; 11; 8; 7; 10; 3 |]
      EdgeFlips      = Array.create 12 0
      CornerPositions= [| 0; 1; 3; 5; 4; 6; 2; 7 |]
      CornerTwists   = [| 0; 0; 1; 2; 0; 1; 2; 0 |] }

let D = 
    { EdgePositions   = [| 0; 1; 2; 3; 5; 6; 7; 4; 8; 9; 10; 11 |]
      EdgeFlips       = Array.create 12 0
      CornerPositions = [| 0; 1; 2; 3; 7; 4; 5; 6 |]
      CornerTwists    = Array.create 8 0 }

let B = 
    { EdgePositions   = [| 0; 1; 11; 3; 4; 5; 10; 7; 8; 9; 2; 6 |]
      EdgeFlips       = [| 0; 0;  1; 0; 0; 0;  1; 0; 0; 0; 1; 1 |]
      CornerPositions = [| 0; 2; 6; 3; 4; 5; 7; 1 |]
      CornerTwists    = [| 0; 1; 2; 0; 0; 0; 1; 2 |] }