• Tidak ada hasil yang ditemukan

8 queen

N/A
N/A
Protected

Academic year: 2025

Membagikan "8 queen"

Copied!
2
0
0

Teks penuh

(1)

Warisa Sritriratanarak

2110742 Evolutionary Computation HW 2

S O LV I N G 8 - Q U E E N P R O B L E M

Using Genetic Algorithm to solve the 8-queen problem, the solution is represented with an array of 1 × 8 where {0,1,2,3,4,5,6,7} represent the position in the row 0, 1, 2, 3, 4, 5, 6, 7 respectively. The number is an integer (0..7) representing the column

number.

The first generation of population is randomly created that there is no repeated number. Therefore, there is no attack between the same row and the same column.

The fitness of each candidate is evaluated by counting how many times the queen attack each other diagonally. If there is no attack at all then the number is zero, means the solution is found.

The process to count how many times the queen attack each other is as follow:

For any two positions - (i, m) and (j, n), the row distance is ⎜i − j ⎜and the

column distance is ⎜m − n ⎜ Whenever the row distance and the column distance is the same then there is an attack. For example,

{ 7, 2, 3, 0,1, 4, 5, 6 }

The row distance between row 1 and 2 is equal to 1. The column distance between the position of the queen in row 1 (column =2) and row 2 (column =3) is equal to 1 (3-2). This means there is an attack and the attack number is 1.

To count the total attack number, the first queen position is compared to other 7 positions, the second queen is compared to other 6 positions, the third queen is compared to other 5 positions, and so on. The total attack number is the sum of all attack of every pair.

When the total attack of all population is calculated, the population is sorted

according to the total attack number. The population with the total attack number equal to zero is hence the solution. All the population is used to create the next generation.

(2)

Crossover

Two randomly selected parents, A and B, will be used. An 8-bit binary bit string is randomly created. Each bit will be use as a selector, if the bit is zero then the number from A is chosen otherwise the number from B is selected.

Mutation

A simple mutation will be applied by randomly selected two positions in a candidate and the two numbers are swapped.

Referensi

Dokumen terkait

Having analyzed the novel, it can be concluded that Queen Attolia is described as cruel, smart, attentive, calm, beautiful, jealous, cautious, avengeful and

“I have,” said Stink, pointing to Judy, Queen of the Crazy Strips.. “But these are M-I-N-E, mine.” “You drew this?” asked Rocky, looking at

solar ships g: Pyramid of Chephren h: Mortuary temple of Chephren i: Causeway j: Sphinx k: Valley temple of Chephren l: Sphinx temple m: Monument of Queen Chentkaue n: Pyramid

CONCLUSIONS AND SUGGESTIONS Based on my analysis using Gramsci’s theory of hegemony, I discovered that Victoria Aveyard’s Red Queen picturizes the construction of hegemony operation

WA member is open water queen Mandurah Masters club member Barbara Pellick achieved a milestone in August after completing the 32-kilometre channel swim from Catalina Island to the

The PDM is formulated as a mixed integer programming model MIP, in which the objective is to maximise M X i=1 TiQi, N = N X t=1 ri,tmin  Di,t, Qi− Ri X j=1 Di,t−j 

The second row of the 4x4 byte input data the state is shifted one byte position to the left in the matrix, the third row is shifted two byte positions to the left, and the fourth row

Packet Error Rate for the Proposed Scheme The packet error rate P ERT when the relay forwards the M-weakest packets is calculated as P ERT = 1 N M X i=1 P ERCi+ 1 N N−1 X j=M+1