N-queen
genetic algorithm
Empty board
G0 1select
 (0(0,3,1,3
(1,1,2,0)1
(2,3,1,1)2
(1,2,3,0)3
2fitness
 By counting number of attack queen for each
Queen.
Basic fitness=n*(n-1)=12/2=6
0(0,3,1,3)1+1+0+2=4/2=2 fitness=6-2=4
1(1,1,2,0)1+2+1+0=4/2=2 fitness=6-2=4
2(2,3,1,1)1+1+1+2=5/2=2.5 fitness=6-2.5=3.5
                and so on
3Selection
Select 2 generation random or high fitness
  (0,3,1,3)       (2,3,1,1 )
Then choose same random index for two
  solution index=1
Replacement array1 from index+1 to n-1 with
  array2
(1,3)< == >(1,1)
(0,3,1,1)        (2,3,1,3)
(0,3,1,1)   (2,3,1,3)
4cross over
2 generation random or high fitness
  (0,3,1,3)       (2,3,1,1 )
Then choose same random index for two
  solution index=2
Replacement this element with
  corresponding element on the same index
1< == > 1
(0,3,1,3)      (2,3,1,1 )
5mutation
• Select random solution
For example: (0,3,1,3) select a random index
   and replace this element with a random value
   from(0,1,2,3)
Index =1       replacement with 2
.: solution (0,2,1,3)
When we finished this steps
            if fitness==0
• Then I’ have a solution

N queen