Skip to content

Solving the 8 Queens problem using Genetic Algorithm

License

Notifications You must be signed in to change notification settings

dsong127/8queens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

8 Queens - Genetic Algorithm Solution

Solving the 8 queens puzzle using Genetic Algorithm. The goal of the program is to place 8 queens on a board in such a way that no queens are attacking each other.

Change global variables N and mutation_pct to experiment with different population number and mutation percentage.

Requirements

Installing

cd into cloned directory. Then:

  • virtualenv env
  • source env/bin/activate
  • pip install -r requirements.txt
  • python main.py

Discussion

Mutation rate seemed to play a significant part in finding the solution. Whenever the algorithm converged to a single value, the mutation enabled the algorithm to still find a solution (But a solution is still not guaranteed in Genetic Algorithm).

Setting mutation percentage to a low value (1%) caused the algorithm to run to take anywhere between 1000-5000+ iterations to find a solution. Setting mutation percentage to 5% significantly attenuated this problem. The algorithm was able to obtain a solution under 1000 iterations most of the time.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Solving the 8 Queens problem using Genetic Algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages