Professional Documents
Culture Documents
ARTIFICIAL INTELLIGENCE
FOR IT & NON-IT PROFESSIONALS
8-QUEENS PROBLEM
White boxes
show attack
range of a Q
queen
Eight Queens are shown
•We define a scheme to
denote the board’s
position at any given time
•For every Queen Q
Q
•Each No. below Q Q
represents the row No. Q
And position of the Q
number is the column Q
26834531 Q
8-Queens Problem
Fitness Function:
Q1 can attack NONE Q8
Q4 Q7
Q3 can attack Q6 Q5
Q4 can attack Q5 Q6
Q5 can attack Q4 Q2
Q6 can attack Q5 Q3
Q7 can attack Q4
Q8 can attack Q5
Fitness = No of. Queens that can attack none
Fitness = 2
8-Queens Problem
Q Q
Q Q
Q
2 Q
3
Q Q Q Q
Q
Q Q Q
Q Q
85727135 45827165
Eight Queens Problem
Using Crossover
Parents Children
85727135 85727165
45827165 45827135
Eight Queens Problem
Q Q
Q Q
Q
2 2
Q Q Q Q
Q
Q Q Q Q
Q Q
85727135 85727165
Q Q
Q 1 Q
Q
Q 3 Q 4
Q Q Q Q
Q
Q Q
Q Q
45827165 45827135
Eight Queens Problem
• Mutation, flip bits at random
45827165
45827135 Q
Q
Q
Q 4
Q Q
Q
Q
45827135
Eight Queens Problem
• Solution!
Q
Q 8
Q
46827135
The following flow chart summarizes the Genetic
Algorithm.