I am trying to write a program which uses a certain algorithm to solve a rubiks cube. The problem is though, i can't see which way would be the most intuitive way to make my virtual rubiks cube.
I my first idea was to make 2D Array for each side, and represent each color by a number,a problem comes up though, when I rotate each side, since the program doesn't know how the rubiks is build, it doesn't know how a rotation would affect the other sides, which means each rotation has to be hardcoded someway.
Can this be done in some easy way??
I though about using af 3d Array, but since no pieces are inside it, I've realized that it may not be the way to go.
But then again... each piece is also different, each side has 4 corner pieces and 4 edge pieces. Edge pieces contains 2 colors. and corner pieces contains 3 colors.
I could wrap it into a class... then again, then i would have to hardcode each piece for the rubiks cube.
Or.. could i do it in a way, so each position for the 3d array will determine the it's "attribute"..
and if so, then how..
The only way I see this would be posible, is by using if statement, and check whether a position is a edge or corner piece, and thereby give it is appropriate value.
This does also, mean that each piece would contain variables for opposite, but without any value.
but this will lead to another problem with top and buttom.
I don't think a 3d array would help here.. :(
Another problems appears if i initialize a rubiks cube in its scrambled form, if i initialize it incorrectly it might become unsolveable, since the pieces will be placed where there aren't allowed to by, so i must initialize in its solved form, and then scramble it.