This device is not compatible.


Solving the 8 Queens Problem Using a Genetic Algorithm in Elixir

In this project, we'll solve the 8-Queen problem using a genetic algorithm in Elixir. We'll explore a new technique that focuses on rigorous mutation.

Solving the 8 Queens Problem Using a Genetic Algorithm in Elixir

You will learn to:

Learn about the basics of Genetic Algorithms in Elixir.

Explore the processes of crossover and mutation.

Solve search-based problems using Genetic Algorithms.

Learn how to design the framework for using Genetic Algorithms.


Functional Programming

Genetic Algorithms


Good knowledge of Elixir

Basic knowledge of Genetic Algorithms



Project Description

A genetic algorithm is a process of natural selection of the fittest individuals from a population to search for the best results.

The 8 Queens problem consists of placing eight queens on an 8x8 chessboard such that none of the queens attack each other.

We will solve the eight queen problem using a very simple form of genetic algorithm. We will use a modified technique that requires an aggressive mutation to decrease the time needed to find the optimal solution. We will focus less on the initial population and more on mutating the parents based on their fitness value. The position of the queens will change as much as possible to reach maximum fitness. In case the maximum fitness is not achieved in one generation, the algorithm will generate the next generation.

Project Tasks


Set Up

Task 0: Get Started


Fitness Module

Task 1: Check Vertical Clashes

Task 2: Check Diagonal Clashes

Task 3: Test the Fitness Module


Crossover Module

Task 4: Create New Children

Task 5: Test the Crossover Module


Mutation Module

Task 6: Create Heuristic Function

Task 7: Test the Heuristic Function

Task 8: Create the Index Function

Task 9: Test the Index Function

Task 10: Improve the Fitness of Child

Task 11: Mutate the Child Chromosome

Task 12: Test the Mutation Module



Task 13: Make Function Calls

Task 14: Display the Result


Run the Algorithm

Task 15: Write a Script