N-Queens Solver using Genetic Algorithm
📌 Overview
This project implements a solution to the classic N-Queens problem using a Genetic Algorithm (GA) approach.
The goal of the N-Queens problem is to place N queens on an N×N chessboard such that no two queens attack each other.
🧠 Approach
This solution uses a Genetic Algorithm that includes:
- Population initialization
- Fitness evaluation (non-attacking queen pairs)
- Selection (probability-based)
- Crossover (offspring generation)
- Mutation (random changes)
- Iterative evolution until optimal solution is found
⚙️ How It Works
- Generate an initial population of random solutions
- Evaluate fitness of each chromosome
- Select parents based on probability
- Generate offspring using crossover
- Apply mutation randomly
- Repeat until a valid solution is found
🏆 Fitness Function
The fitness function calculates the number of non-attacking pairs of queens.
Maximum fitness means:
✔️ No queens attack each other
✔️ Valid solution found
▶️ How to Run