by Marius Aasan - IN3050/4050 Group 3 - 08.02.2021 1015-1200
The 8-queens puzzle is a combinatorial optimization problem where one tries to place 8 queens on a chessboard without any of the queens being in a position to capture one another. In principle, a candidate solution can be obtained by placing the queens randomly over the board. However, this would create a very large solution space. Instead, we represent the genotypes as permutations, such that each queen can occupy a single rank and file. This leaves only the diagonals to be checked. Let us solve this problem with a genetic algorithm and generalize to an N x N grid.
Some of the code in this notebook is omitted as to not crash with the mandatory assignment, but can be filled out as an exercise.