|
-
January 28th, 2011, 08:23 AM
#1
Rubiks cube solver
I've began writing a Rubiks cube solver in Java. Normally when you perform a move on a Rubiks, you turn the appropriate face 90 degrees clockwise, this has the effect of changing the position of the colours on four of the adjacent cuboid faces.
When I began thinking about how I would write this in software, it became apparent that I had to create a collection of matrices to represent each tile on each face of the full Rubiks cuboid, and I would need a scheme to map the matrix on the cuboid face being rotated to the four other adjacent faces, whose values would need to be updated.
I began writing a truth table which mapped the adjacent faces and it came out like so:
(F = Front, T = Top, L = Left, B = Bottom, A = Away, R = Right)
F T L B A R
F 0 1 1 1 0 1
T 1 0 1 0 1 1
L 1 1 0 1 1 0
B 1 0 1 0 1 1
A 0 1 1 1 0 1
R 1 1 0 1 1 0
It immediately becomes apparent that there's some repitition within the table and I can reduce it as so:
F T L B A R
F/A 0 1 1 1 0 1
T/B 1 0 1 0 1 1
L/R 1 1 0 1 1 0
But again if you look at the first/last 3 values of each row there is some repititon still. So my question is, is there a simple algorithm for calculating the adjacent faces of a cube without any sort of lookup table?
Can the truth table above be reduced further through another approach to working out the adjacent faces, and have I overcomplicated the matter?
Thanks,
James
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|