Rubiks Cube/Tuple
From charlesreid1
4x4 Rubiks Cube Representation
Types of Pieces
To represent the 4x4 cube as a permutation, so that we can move toward a permutation algebra for 4x4 Rubiks Cubes, we have to think about the cube as being composed of three separate types of pieces:
- 8 corner pieces, 3 orientations each
- 24 squares, 6 of each color in groups of 4
- 12 left dedge pieces, 12 right dedge pieces
(Note: dedge = double edge)
While we can think about the 24 center squares and 24 dedge pieces as being as simple to represent as two 24-tuples, the 8 corner pieces require a bit more care.
We might think of representing the corners using an integer to indicate which of the 8 corner pieces a piece is, and a second tuple that would represent the orientation of each corner piece, with 0, 1, 2 labeling some predetermined (but ultimately arbitrary) scheme of corner orientations. Thus, a solved cube might be represented as:
(1 2 3 4 5 6 7 8) (0 0 0 0 0 0 0 0)
while a cube with corners mixed up might look something like:
(2 1 4 3 8 7 5 6) (1 2 2 0 1 0 2 2)
The difficulty is that one tuple has a single integer per item (no repeats), while the other can have any number per item (with repeats).
Instead, what we'll do is waste some space, and make the tuple representation longer, to simplify the representation.
Consider a single corner - the white, red, green corner. This corner can be represented using a 3-tuple, with a letter for each face:
(W R G) (G W R) (R G W)
So an alternative representation of the corners is to use a 3-tuple for each corner, with the orientation specified by which of the three-tuples represents the corner.
Specifying Cube State
We must specify an order for our tuple to represent the cube state. We define the following arbitrary ordering:
Specifying Corners
The corners are labeled by the tuple first. Each corner is represented by three slots, which are the three colors of the cube specified in clockwise order, starting with the upper or downward face. Thus, WRG means the upper face is white, then the face to the bottom right is red, then the face to the bottom left is green.
It is easiest to orient the cube as U = WHITE, F = GREEN, R = RED.
(Note that 6 colors map to 6 integers. We'll define a color map below.)
Specifying Centers
The centers are specified for each face in the order FRBLUD. Each of the six faces has four slots to specify the colors of the four center squares.
On each face, the order of the four corners is specified in the order: NW, NE, SE, SW
Specifying Dedges
The first four dedges we specify are the dedges along the upper face. Each dedge has both colors specified. The upper face U is specified first. Thus, on a solved cube, these dedges would be represented by the tuple WGO WRG WBR WOB.
The second four dedges we specify are the dedges along the downward face. Again, the color on each of the two faces of each dedge is specified. The downward face D is specified first. On a solved cube, these dedges are represented by YOG YGR YRB YBO.
The last four dedges connect the FRBL faces. We specify dedges by specifying the two colors of the dedge piece closes to U first, then closest to D. The order of edges proceeds by connecting corners 1 (white-green-orange) and 5 (yellow-orange-green). The first of the four face dedges is between FL or green and orange on the solved cube, so is specified by GOGO. Next dedge is between FR or green and red on the solved cube, so RGRG. And so on.
Flags