Rubik_Cube[0 thru 5][9] represents each of the 6 sides, while int Rubik_Cube[6][0 thru 8] represents each of the nine cubes on each of the 6 sides
|
First of all, I think you need to tighten up your terminology. A side does not have 9 cubes. A side has 9 squares or faces or colors. If you want to treat the puzzle as 27 cubes that move around, you can do that, but I think you are actually treating this as 6 3x3 grids that are interconnected. So, be careful using the term "cube".
Other things to think about. If you never move a middle band (only move top, bottom, or a side) the middle squares never move. They can rotate (which is not important in a traditional Rubik's cube), but the color never changes.
How you rotate the bottom and top depends on how you have numbered your grids. Assuming all side grids are numbered 0, 1, 2 on the top row, rotating the top counterclockwise would be:
F[0] = old L[0], F[1] = old L[1], F[2] = old L[2], L[0..2] = old B[0..2], B[0..2] = old R[0..2] R[0..2] = old F[0..2]. (B is Back, not Bottom in this example.)
T[0] = old T[2], T[1] = old T[5], T[2] = old T[8], T[3] = old T[1], T[4] = old T[4] (center square does not move), T[5] = old T[7], T[6] = old T[0], T[7] = old T[3] and T[8] = old T[6].
You might be able to do some sort of matrix manipulation to use less code than this, but you won't get much performance improvement over a simplistic brute force method.
If you can figure out a standard orientation of your faces you can write a singe function to rotate any face. By standard orientation, I mean, all faces are oriented with 0 in the upper LH corner and are 0, 1, 2 across the top and the square on the face above the '0' square is the same number for all faces and the squared on the face to the left of the '0' square is the same for all faces. If the orientation of each face vis a vis the orientation of all adjacent faces is the same for all faces on the cube, your coding become much easier.