
N-Queens Genetic Algorithm
Updated Nov 2025
PythonGenetic Algorithms
this project explores the n-queens puzzle through a compact genetic algorithm. it's intentionally small and transparent, so it's easy to see how population size, mutation behavior, and iteration caps affect convergence.
tournament selection + single-point crossover
mutation schedule that scales with board size
CLI/.env configurable experiments
what i built
- single-file genetic algorithm with tournament selection and crossover
- collision-based fitness function for scoring candidate boards
- CLI and .env configuration for quick experimentation
how it works
- 1initialize a population of candidate boards
- 2score conflicts and select parents via tournaments
- 3apply crossover and mutation across generations
- 4stop when a zero-collision solution is found or the iteration cap is hit
results
- ✓nice compact reference implementation for an evolutionary search workflow
what's next
- add seeded benchmarking and clearer example outputs
- try alternate encodings or hybrid local-search ideas