Answers.Body: <p>This can be calculated quite easily in the context of 8-queen problem. Just start with a particular configuration. Starting from the queen in the left-most column just keep on counting the non-attacking positions (pairs) on the right with each queen. Carry on column by column towards your right until you reach the last queen. As a special case for the last queen the non-attacking pairs will be zero as their are no other queens after that. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-02T11:23:29.330Z
Answers.Text: This describes how to solve the problem, but it doesn't answer the question which is about  formulating this as a fitness function to use in evolutionary computing.
Answers.UserDisplayName: Oliver Mason
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-01T00:57:42.820Z
Answers.LastActivityDate: 2019-12-01T00:57:42.820Z
Answers.UserDisplayName: MuneshSingh
Answers.Body: <p><a href="https://kushalvyas.github.io/gen_8Q.html" rel="nofollow noreferrer">Here</a> you can find an example of how to apply genetic algorithms to solve the 8-queens problem.</p>
  <p>The proposed fitness function is based on the chessboard arrangement, and in particular, it is inversely proportional to the number of clashes amongst attacking positions of queens; thus, a high fitness value implies a low number of clashes.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-24T13:24:35.257Z
Answers.LastActivityDate: 2021-01-30T02:34:28.230Z
Answers.LastEditDate: 2021-01-30T02:34:28.230Z
Answers.UserDisplayName: PieCot
Body: <p>In evolutionary computation and, in particular, in the context of genetic algorithms, there is the concept of a <a href="https://en.wikipedia.org/wiki/Fitness_function" rel="nofollow noreferrer"><em>fitness function</em></a>. The better a state, the greater the value of the fitness function for that state.</p>
  <p>What would be a good fitness function for the <a href="https://en.wikipedia.org/wiki/Eight_queens_puzzle" rel="nofollow noreferrer">8-queens problem</a>?</p>
  
Tags: <genetic-algorithms><fitness-functions><evolutionary-computation><fitness-design><8-queens-problem>
Title: How to design a fitness function for the 8-queens problem?
UserDisplayName: Huma Qaseem
ThreadText: # How to design a fitness function for the 8-queens problem?
  
  (Asked by: username_0 on 2018-11-22)
  
  In evolutionary computation and, in particular, in the context of genetic algorithms, there is the concept of a [*fitness function*](https://en.wikipedia.org/wiki/Fitness_function). The better a state, the greater the value of the fitness function for that state.
  
  What would be a good fitness function for the [8-queens problem](https://en.wikipedia.org/wiki/Eight_queens_puzzle)?
  
  **Tags:** genetic-algorithms, fitness-functions, evolutionary-computation, fitness-design, 8-queens-problem
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2018-11-24. Score: 2 | Accepted answer
  
  [Here](https://kushalvyas.github.io/gen_8Q.html) you can find an example of how to apply genetic algorithms to solve the 8-queens problem.
  
  The proposed fitness function is based on the chessboard arrangement, and in particular, it is inversely proportional to the number of clashes amongst attacking positions of queens; thus, a high fitness value implies a low number of clashes.
  
  
  ---
  
  ### Answer by username_1 on 2019-12-01. Score: 0
  
  This can be calculated quite easily in the context of 8-queen problem. Just start with a particular configuration. Starting from the queen in the left-most column just keep on counting the non-attacking positions (pairs) on the right with each queen. Carry on column by column towards your right until you reach the last queen. As a special case for the last queen the non-attacking pairs will be zero as their are no other queens after that.
  
  > **Comments:**
  > **username_2**: This describes how to solve the problem, but it doesn't answer the question which is about  formulating this as a fitness function to use in evolutionary computing.  
  
  ---
  
  