Upload
htotisum
View
226
Download
0
Embed Size (px)
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 1/60
Advanced Artificial IntelligenceCS 702 ± Fall ( 2011 / 2012)
Rubik¶s Cube
Presented by (Presented by (HAW):HAW):
HatimHatim Al Sum Al Sum Wael IbrahimWael Ibrahim
Ahmed Faisal Ahmed Faisal
PresentedPresented to:to:
Dr Dr.. HeshamHesham ElEl--DeebDeeb
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 2/60
Agenda
(1) Introduction History
What is Rubik¶s Cube
How the Cube Works
Puzzle Objective
Puzzle Complexity
(2) The Algorithm Notations
Manual Solution Steps
Optimal Solution
(3) Demo Rubik¶s Cube Solver Robot ± Videos
Rubik¶s Cube Solver Simulator ± Application
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 3/60
Agenda
(1) Introduction(1) Introduction History
What is Rubik¶s Cube
How the Cube Works
Puzzle Objective
Puzzle Complexity
(2) The Algorithm Notations
Manual Solution Steps
Optimal Solution
(3) Demo Rubik¶s Cube Solver Robot ± Videos
Rubik¶s Cube Solver Simulator ± Application
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 4/60
History
Rubik's Cube?! Who is Rubik¶s 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"
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 5/60
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-sellingpuzzle game.
It is widely considered to be the
world's best-selling toy.
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 6/60
What is Rubik¶s Cube
In a classic Rubik's Cube,
each of the six faces is covered
by nine stickers, each of one of sixsolid colors, (traditionally white,
red, blue, orange, green, and
yellow).
A pivot mechanism enables
each face to turn independently,thus mixing up the colors.
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 7/60
Rubik¶s Cube Puzzle
Initial State Goal State
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 8/60
Initial State Goal State
In order to solve the Rubik Cube puzzle; each face must
be returned to consisting of one color.
Puzzle Objective
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 9/60
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 don¶t move relative
to each other
NoteNote::
TheThe color of a center color of a center determinesdetermines whatwhat color that facecolor that face will be when thewill be when the
cube is completedcube is completed
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 10/60
Puzzle Complexity
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 11/60
Puzzle Complexity
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 12/60
Number of Configurations
The original (3×3×3) 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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 13/60
43,252,003,274,489,856,000
If one were to make one move every second, it would take1,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 (65MYA), he/she would have reached only 4.7% of all the cases
If a cube existed for every configuration, and all were lined up nextto each other, they would circle the earth five times
That is 124,508 miles, or about half the distance from Earth to themoon
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 14/60
Rubik¶s Cube Importance
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 15/60
Rubik¶s Cube Importance
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 16/60
Rubik¶s Cube Importance
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 17/60
Rubik¶s Cube Importance
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 18/60
Agenda
(1) Introduction History
What is Rubik¶s Cube
How the Cube Works Puzzle Objective
Puzzle Complexity
(2) The Algorithm (Planning)(2) The Algorithm (Planning) Notations
Human Planning: Manual Solution (Steps with Example)
Computer Planning: Optimal Solution (Advanced Algorithms)
(3) Demo Rubik¶s Cube Solver Robot ± Videos
Rubik¶s Cube Solver Simulator ± Applications
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 19/60
Solve by Planning
In Rubik's cubists' parlance,
a memorized sequence of moves that has a desired effect on the cube
is called an algorithmalgorithm.
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 Cubeemploys 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.
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 20/60
Notation
Everyone needs to know the notation used for cubing!
Many 3×3×3 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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 21/60
Notation
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 22/60
Notation
F = front face B = back face R = right face L = left face
U = up face D = down 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.
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 23/60
Notation: U and D
U
U¶
U2
D
D¶
D2
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 24/60
Notation: F and B
F
F¶
F2
B
B¶
B2
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 25/60
Notation: R and L
R
R¶
R2
L
L¶
L2
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 26/60
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.
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 27/60
Beginners Plan
The method you will learn consists of 6 major steps, and each stepis 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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 28/60
The Solution, Step by Step
1. Top Edges 4. Finish 2 Layers
2. Top Corners 5. Orient LL
3. Middle Edges 6. Permute LL
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 29/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 30/60
Cross - Details
Oriented vs. non-oriented 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 edge
Good edge -->
<-- Bad cross
Good cross -->
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 31/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 32/60
Corners
Solving the corners completes the top
layer
This step is easier than the cross since
there are fewer possibilities
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 33/60
Solving a Corner
The only thing to keep in mind is you can¶t 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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 34/60
Finding a Corner
Remember that the centers don¶t move
So the corner (which has three stickers) depends on the color of three
centers:
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
This must be orange
This must be greenThis must be white
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 35/60
Three Possibilities
Once you have a corner in the right spot in the bottom layer, you
must determine it¶s orientation.
F D F¶ R¶ D¶ R R¶ D R F D2 F¶
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 36/60
The Other Corners
Follow this step for the other three corners
When 3 corners are done, it should look
like this:
It¶s important to have
the ³T´ on each face
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 37/60
Middle Layer
Flip over the cube so the top layer becomes the bottomlayer
Find an edge that belongs in the middle layer
Hold cube so
the edge willend up here,
in FR
Make sure theempty corner is
below the edge
you want to
solve
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 38/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 39/60
The Other 2 Edges
Always hold the cube so the edge that you wish to solvewill end up in FR
This means you will have to change the orientation of thecube in your hands
You will also need to rotate the bottom layer so theempty corner is just below where the edge is to beplaced
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 40/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 41/60
Orient Edges
Three cases
[A] = F U R U¶ R¶ F¶ [B] = F R U R¶ U¶ F¶ [A] U2 [B]
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 42/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 43/60
Orient Corners
R¶ U2 R2 U R2 U R2 U2 R¶ R¶ U¶ R U¶ R¶ U R¶ U R¶ U2 R¶
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 44/60
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 won¶t encounter either of these cases inany particular solve. There is one other case:
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 45/60
Permutation
You must learn at least one of the first two cases:
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.
(R2 U) (F B¶) R2 (F¶ B) (U R2) (R2 U¶) (F B¶) R2 (F¶ B) (U¶ R2)
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 46/60
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)
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 47/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 48/60
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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 49/60
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!
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 50/60
Agenda
(1) Introduction History
What is Rubik¶s Cube
How the Cube Works Puzzle Objective
Puzzle Complexity
(2) The Algorithm (Planning)(2) The Algorithm (Planning) Notations
Human Planning: Manual Solution (Steps with Example) Computer Algorithms: Optimal Solution (God¶s Algorithms)
(3) Demo Rubik¶s Cube Solver Robot ± Videos
Rubik¶s Cube Solver Simulator ± Applications
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 51/60
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 isknown as God's algorithm.
http://en.wikipedia.org/wiki/Optimal_solutions_for_Rubik's_Cube
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 52/60
A History of God's Number
http://www.cube20.org/
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 53/60
Search Technique
God¶s 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 lower-
bound 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
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 54/60
Iterative deepening search
algorithm
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 55/60
How It Works
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 56/60
Why God¶s 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)
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 57/60
Agenda
(1) Introduction History
What is Rubik¶s Cube
How the Cube Works Puzzle Objective
Puzzle Complexity
(2) The Algorithm Notations
Manual Solution Steps Optimal Solution
(3) Demo(3) Demo Rubik¶s Cube Solver Robot ± Videos
Rubik¶s Cube Solver Simulator ± Application
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 58/60
Rubik¶s Cube Robot
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 59/60
Rubik¶s Cube Simulator
8/3/2019 Rubik's Cube (HAW)
http://slidepdf.com/reader/full/rubiks-cube-haw 60/60
Thank You