15,946,988 members
See more:
Can I have java code for 8 queen problem using genetic algorithm.

sanarasimha@gmail.com

Posted
Updated 25-Sep-15 13:17pm
v2
Matt T Heffron 25-Sep-15 18:32pm
As Afzaal said, you need to do your own homework.
I'll give you 2 hints.
If I were going to do this I'd:
1. represent the genome as 64 Boolean values (only 8 can be true) representing the board state
2. the fitness function is based on how many queens are "safe"
PIEBALDconsult 25-Sep-15 19:21pm
N-Queens is actually much easier than that. It's actually one-dimensional; not two-dimensional as people assume. Find the Permutations of N things taken N at a time.
Matt T Heffron 25-Sep-15 19:35pm
I agree to both comments. As a homework assignment I assumed that use of genetic algorithm was required.
PIEBALDconsult 25-Sep-15 19:52pm
"It's homework" is also the only valid reason to use recursion for factorials. But don't come here asking for code.
Matt T Heffron 25-Sep-15 19:53pm
Yep!

## Solution 1

No, if that is your homework you need to do it yourself. We won't provide any code unless you show us what you did and where did it get your stuck. Here is the algorithm, https://en.wikipedia.org/wiki/Eight_queens_puzzle[^] (See solutions) and you may want to have a look at a few PDFs provided in this Google search[^].

Sergey Alexandrovich Kryukov 25-Sep-15 21:06pm
Again, fair enough, a 5.
—SA
Thank you, Sergey.
Matt T Heffron 28-Sep-15 13:08pm
+5
Thank you, Matt.

## Solution 2

We do not do your homework !

By the way, try to define genetic algorithm. This wording covers many things. Which one is related to your question?

v3
Matt T Heffron 28-Sep-15 13:08pm
+5
Patrice T 28-Sep-15 13:31pm
Thank you

Top Experts
Last 24hrsThis month
 OriginalGriff 10 Robert Bushlow -6 Leonard42 -10 atik sarker -16 Clifford Nelson -26
 Pete O'Hanlon 975 OriginalGriff 870 Richard Deeming 715 merano99 345 Dave Kreskowiak 310

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900