Rubik's Cube (HAW)

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 60

Advanced Artificial Intelligence

CS 702 Fall ( 2011 / 2012)

Rubiks Cube
Presented by (HAW): (HAW):
Hatim Al Sum Wael Ibrahim Ahmed Faisal

Presented to: Dr. Dr. Hesham El-Deeb El-

Agenda
(1) Introduction
     History What is Rubiks Cube How the Cube Works Puzzle Objective Puzzle Complexity

(2) The Algorithm


 Notations  Manual Solution Steps  Optimal Solution

(3) Demo
 Rubiks Cube Solver Robot Videos  Rubiks Cube Solver Simulator Application

Agenda
(1) Introduction
     History What is Rubiks Cube How the Cube Works Puzzle Objective Puzzle Complexity

(2) The Algorithm


 Notations  Manual Solution Steps  Optimal Solution

(3) Demo
 Rubiks Cube Solver Robot Videos  Rubiks Cube Solver Simulator Application

History
Rubik's Cube?!
 Who is Rubiks and why the name?

A 3-D mechanical puzzle invented in 1974 by Hungarian sculptor and professor of architecture Ern Rubik. Originally called the "Magic Cube"

History
The puzzle was licensed by Rubik to be sold by Ideal Toy Corp. in 1980 and won the German Game of the Year special award for Best Puzzle that year. As of January 2009, 350 million cubes had been sold worldwide making it the world's top-selling puzzle game. It is widely considered to be the world's best-selling toy.

What is Rubiks Cube


In a classic Rubik's Cube, each of the six faces is covered by nine stickers, each of one of six solid colors, (traditionally white, red, blue, orange, green, and yellow). A pivot mechanism enables each face to turn independently, thus mixing up the colors.

Rubiks Cube Puzzle


Initial State Goal State

Puzzle Objective
Initial State Goal State

In order to solve the Rubik Cube puzzle; each face must be returned to consisting of one color.

How the Cube Works


Taken apart, one can see that the cube consists of 6 centers, 8 corners, and 12 edges:

The centers are fixed on a central mechanism, so they dont move relative to each other
Note: Note: The color of a center determines what color that face will be when the cube is completed

Puzzle Complexity

Puzzle Complexity

Number of Configurations
The original (333) Rubik's Cube has eight corners and twelve edges. There are 8! (=40,320) ways to arrange the corner cubes. Seven can be oriented independently, and the orientation of the eighth depends on the preceding seven, giving 3^7 (=2,187) possibilities. There are 12!/2 (=239,500,800) ways to arrange the edges, since an odd permutation of the corners implies an odd permutation of the edges as well. Eleven edges can be flipped independently, with the flip of the twelfth depending on the preceding ones, giving 2^11 (=2,048) possibilities

43,252,003,274,489,856,000
If one were to make one move every second, it would take 1,370,000,000,000 (1.37 trillion) years to reach every case, assuming no repeats That amount of time spans the age of the universe ten times If this person began to twist from the moment the dinos died out (65 MYA), he/she would have reached only 4.7% of all the cases If a cube existed for every configuration, and all were lined up next to each other, they would circle the earth five times That is 124,508 miles, or about half the distance from Earth to the moon

Rubiks Cube Importance

Rubiks Cube Importance

Rubiks Cube Importance

Rubiks Cube Importance

Agenda
(1) Introduction
     History What is Rubiks Cube How the Cube Works Puzzle Objective Puzzle Complexity

(2) The Algorithm (Planning)


 Notations  Human Planning: Manual Solution (Steps with Example)  Computer Planning: Optimal Solution (Advanced Algorithms)

(3) Demo
 Rubiks Cube Solver Robot Videos  Rubiks Cube Solver Simulator Applications

Solve by Planning
In Rubik's cubists' parlance, a memorized sequence of moves that has a desired effect on the cube is called an algorithm algorithm. This terminology is derived from the mathematical use of algorithm, meaning a list of well-defined instructions for performing a certain task from a given (initial state), through well-defined successive states, to a (desired end-state). Each method of solving the Rubik's Cube employs its own set of algorithms, together with descriptions of what the effect of the algorithm is, and when it can be used to bring the cube closer to being solved.

Notation
Everyone needs to know the notation used for cubing! Many 333 Rubik's Cube enthusiasts use a notation developed by David Singmaster to denote a sequence of moves, referred to as "Singmaster notation" For example, what do these mean: F (R U R U) F (R2 U)(R U R U)(R U)(R U R) (M U)*4 (M U)*4 These are algorithms. Each letter represents a move to be carried out in sequence, and represents a face of the cube. There are 6 faces, named (F)ront, (B)ack, (U)p, (B)own, (R)ight, (L)eft. There are also 3 slices, named (M)iddle, (E)quator, (S)ide

Notation

Notation
F = front face B = back face U = up face D = down face R = right face L = left face

In addition to a letter, each move may be accompanied by an apostrophe or the number two:
   A letter by itself means turn that face 90 degrees clockwise (eg. F). A letter followed by an apostrophe means turn that face 90 degrees anti-clockwise (eg. F'). A letter followed by the number 2 means turn that face 180 degrees (direction is irrelevant), (eg. F2).

So R U' L2 is shorthand for "turn the right face 90 degrees clockwise, then turn the up face 90 degrees anti-clockwise, then turn the left face 180 degrees". When thinking whether to turn clockwise/anti-clockwise, imagine that you are looking directly at the particular face you are turning.

Notation: U and D
U D

U2

D2

Notation: F and B
F B

F2

B2

Notation: R and L
R L

R2

L2

Human Planning
There are many different methods for solving the Rubik's cube.
They can be divided into two broad categories
1) Layer methods 2) Corners first methods (and there are sub-categories within these broad categories).

The following method is a layer based method. This beginner method requires memorizing only a few algorithms, and when done efficiently can achieve solves of 60 seconds or faster.

Beginners Plan
The method you will learn consists of 6 major steps, and each step is broken down into smaller steps 1. Top edges 2. Three Top Layer corners
 At this point, we have all but one top layer cube solved

3. Three Middle Edges


 Now we (almost) have 2 layers done. Flip over the cube so the last layer (LL) is on top.

4. Solve the remaining corner and edge


 Now we have 2 layers (of three) solved.

5. Orient Last Layer (OLL)


 Edges first, then corners

6. Permute Last Layer (PLL)


 Again, edges first, then corners

The Solution, Step by Step


1. Top Edges 4. Finish 2 Layers

2. Top Corners

5. Orient LL

3. Middle Edges

6. Permute LL

Top Edges
Also called the cross We will use orange as our top face This is the first step towards completing the top layer Complete one edge at a time Experienced cubers usually solve the cross consistently in 6 moves, < 2 seconds Reasonable average is 15 moves, 10 seconds with some practice

Cross - Details
Oriented vs. non-oriented edge <-- Bad edge

Good edge --> Your first goal is to locate an edge that makes up the cross
 This means that it has orange as one of its two stickers

Remember that the center of a face determines what color it will be: <-- Bad cross

Good cross -->

In case of a bad cross


do the following:
 Rotate the top layer until at least two of the edges are in place (you will always be able to get two)  Match your cube with one of the following cases  Execute the sequence to place the edges that are out of place
These two edges need to switch places These two edges need to switch places

R U R U R

L R U2 L R

Corners
Solving the corners completes the top layer

This step is easier than the cross since there are fewer possibilities

Solving a Corner
The only thing to keep in mind is you cant mess up the cross
 To make progress, you must temporarily disturb what you have already solved, then restore it  Hopefully, when you restore a few solved pieces, progress gets made

To solve a corner, find one that belongs in the top layer


 Move it directly beneath where it belongs
Corner belongs here

Move corner to here

Finding a Corner
Remember that the centers dont move So the corner (which has three stickers) depends on the color of three centers:

This must be orange This must be green

This must be white

So, the corner that belongs in this spot must be orange, green, and white This is the process used to figure out where a piece belongs Use it to figure out where any piece belongs

Three Possibilities
Once you have a corner in the right spot in the bottom layer, you must determine its orientation.

F D F

R D R

R D R F D2 F

The Other Corners


Follow this step for the other three corners When 3 corners are done, it should look like this:

Its important to have the T on each face

Middle Layer
Flip over the cube so the top layer becomes the bottom layer
Make sure the empty corner is below the edge you want to solve Hold cube so the edge will end up here, in FR

Find an edge that belongs in the middle layer

Inserting an Edge
There are two flips of an edge
 Thus there are two cases for inserting an edge

U F U F

R U R

Follow these steps until three of the middle edges are solved

The Other 2 Edges


Always hold the cube so the edge that you wish to solve will end up in FR

This means you will have to change the orientation of the cube in your hands You will also need to rotate the bottom layer so the empty corner is just below where the edge is to be placed

Top Layer
At this point, 2/3 of the cube is done Last Layer Strategy:
    1. Orient Edges 2. Orient Corners 3. Permute Edges 4. Permute Corners

After orientation

After permutation

Orient Edges
Three cases

[A] = F U R U R F

[B] = F R U R U F

[A] U2 [B]

Orient Corners
Seven cases

R B L B R B L B

R2 D R U2 R D R U2 R

L B R B L B R B

L U R U L U R

R U L U R U L

Orient Corners

R U2 R2 U R2 U R2 U2 R

R U R U R U R U R U2 R

Permute Edges
Rotate the top layer until you have one of the following cases for edge permutation:

These two cases show that only one edge is permuted. It is possible that you wont encounter either of these cases in any particular solve. There is one other case:

Permutation
You must learn at least one of the first two cases:

(R2 U) (F B) R2 (F B) (U R2)

(R2 U) (F B) R2 (F B) (U R2)

Breaking down each sequence into groups of fewer moves makes it easier to learn long sequences
 These two sequences are broken into groups (indicated by parentheses) that make learning them easier.

The Other Case


In case you want to learn an extra sequence, here is the solution

(R B R B)(F R)(B F)(R B R)(F2 U)

Permute Corners
There are four possibilities for corner permutation Do not rotate the top layer like you did for edges (that would mess up the edges!) Here are the possibilities:

Case 1

Case 2

Case 3

Case 4

The Final Step


You only need to learn one of these cases (either c1 or c2) They have similar solutions

R F R D2 R F R D2 R2

R B R F2 R B R F2 R2

You Are Done!


You now know the way to avoid nearly all of the 43 quintillion combos of a cube Now you need to learn how to become faster by learning the following:
     Finger tricks/triggers Lubing your cube Solve from bottom -> top Learn all 57 orientations! Learn all 21 permutations!

Agenda
(1) Introduction
     History What is Rubiks Cube How the Cube Works Puzzle Objective Puzzle Complexity

(2) The Algorithm (Planning)


 Notations  Human Planning: Manual Solution (Steps with Example)  Computer Algorithms: Optimal Solution (Gods Algorithms)

(3) Demo
 Rubiks Cube Solver Robot Videos  Rubiks Cube Solver Simulator Applications

Computer Algorithm
There are many algorithms to solve scrambled Rubik's Cubes. The maximum number of face turns needed to solve any instance of the Rubik's cube is 20. This number is also known as the diameter of the Cayley graph of the Rubik's cube group. An algorithm that solves a cube in the minimum number of moves is known as God's algorithm.

http://en.wikipedia.org/wiki/Optimal_solutions_for_Rubik's_Cube

A History of God's Number

http://www.cube20.org/

Search Technique
Gods Algorithm Is based on IDA* which is a variant of the A* search algorithm which uses iterative deepening to keep the memory usage lower than in A*. IDA* is a depth-first search that looks for increasingly longer solutions in a series of iterations, using a lowerbound heuristic to prune branches once a lower bound on their length exceeds the current iterations bound. It is an informed search based on the idea of the uninformed iterative deepening depth-first search.

Iterative deepening search algorithm

How It Works

Why Gods Algorithm


Complete?
 Yes since it always find a solution

Time Complexity?
 O(n/m), m is the amount of memory

Space Complexity?
 O(n)

Optimal?
 Yes, (n^2 / log(n)) moves is enough (20 moves for 3x3 cube)

Agenda
(1) Introduction
     History What is Rubiks Cube How the Cube Works Puzzle Objective Puzzle Complexity

(2) The Algorithm


 Notations  Manual Solution Steps  Optimal Solution

(3) Demo
 Rubiks Cube Solver Robot Videos  Rubiks Cube Solver Simulator Application

Rubiks Cube Robot

Rubiks Cube Simulator

Thank You

You might also like