whenWhen I think of this problem, I think of a static cube with the colors moving across it in known patterns. So....
A Cube object contains 6 Side objects that remain fixed indexed 0-5. Each side contains 9 position objects that remain fixed indexed 0-8. Each position contains a color.
For simplicity, handle every action in quarter turn increments. There are 3 axisaxes of rotation, each in 2 possible directions for a total of 6 possible actions on the cube. withWith this information, it becomes a fairly simple task to map out the 6 possible actions on the cube.
So the color green in side 6, position 3, may move to side 1 position 3, or side 2 position 7, amongst others, depending on the action taken. I haven't explored this enough to find any mathematical translations, but patterns will probably emerge that you can take advantage of in code.
Using the data structure, how can I know if a certain cube in a certain state is solvable? I have been struggling with this question myself and haven't quite found the answer yet.
To do this, never begin with a random cube state, instead. Instead, start with a solved state, and perform nn actions programmatically to get the cube into a random starting state, since. Since you only took legal actions to get to the current state, the cube must be solvable.