180 likes | 361 Views
3x3x3 Rubik’s Cube Solver. Kevin Van Kammen Kyle Rupnow Jason Lavrenz. Complexity. 8 corners, 12 middle edges, 6 centers 2*(12!)*3*(8!)*(6!) combinations = 8.8343e^16 combinations Conversion of visual algorithms to computer algorithms User interface. Visual Example. User Interface.
E N D
3x3x3 Rubik’s Cube Solver Kevin Van Kammen Kyle Rupnow Jason Lavrenz
Complexity • 8 corners, 12 middle edges, 6 centers • 2*(12!)*3*(8!)*(6!) combinations = 8.8343e^16 combinations • Conversion of visual algorithms to computer algorithms • User interface
User Interface • Microsoft Foundation Class • Randomly create cube • Manually create cube • Solve cube, output step by step instructions • Potentially allow user to manually solve
Creating 3D cube • Cube is drawn as 54 separate polygons, need coordinates for all polygon points. • Want to be able to easily modify size/appearance. • Set reference points and cube size. • All other points determined from reference points and cube size – only do this solving once and store them in an array. • Each polygon then corresponds to certain points, referenced when updating the color of that polygon.
Yellow points – reference points Red points – can all be solved knowing yellow’s coordinates The three yellow points in back can be adjusted for better looking cube Y - coordinate X - coordinate
Final appearance Face 2 is a copy of face 1, offset. Face 5 is a copy of face 3, offset. Face 6 is a copy of face 4, offset.
Making Moves Graphically • After each move is determined, an array of 54 contains the color of each block. • This array is read in by GUI and all blocks are updated with new colors.
Cube Creation • Random creation algorithm • Start with a solved cube. • Perform a random number of random moves on the cube. • Each move is done in a random direction. • (uses three random number generators)
Data Structure • One array that stores the entire cube • Arrays storing the indices of the corners and edges. • Each element of the corner (edge) array contains 3 (2) elements. • Arrays that stores the correct color and orientation for each piece.
Solver Algorithm • Step 1 – Solve one face • Step 2 – Position and orient four corner pieces of opposite face • Step 3 – Solve this face completely • Step 4 – Position and orient final four faces
Solve One Face for each corner of the top face find position of desired piece determine orientation of piece execute correct move based on orientation for each edge piece find position of desired piece determine orientation of piece execute correct move based on orientation and position
Result after Part 1: • Turn the top so that the colors match the centers of the sides
Step 2 – Position and Orient Corners of Opposite Face • Note: Because the top four corners are in the correct position, at least two corners on the bottom must be in the correct position. • Use this fact to perform step two.
Step 2: find the correct corners correctly position the remaining corners (based on the location of the correct corners) for each edge piece determine the location of the desired edge line up the keyhole on top and the side on bottom execute the correct move based on the orientation of the edge piece.
Finish Step 2: Determine the orientation of the keyhole created in step 2. Execute the appropriate move to fill in the keyhole. Note: at this point two of the faces are completely solved.
Step 4 – Position and Orient Final Four Faces determine the location of a correct piece (if any) Iteratively perform a move based on the location of the correct pieces until all of the four edges are in the correct location (but not necessarily correctly oriented)
Finish Step 4: determine if any edge pieces are incorrectly oriented. for each pair of incorrectly oriented edges perform “Rubes” move to correctly orient the edges