ACADEMIC
GENETIC KINGDOM
OVERVIEW
Tower-defense game in C++ and SFML where each enemy wave evolves through a genetic algorithm and finds its way through the player's towers with A* pathfinding.
HIGHLIGHTS
- Genetic algorithm over five genes (health, speed and three resistances), with fitness from distance traveled, time alive and damage received.
- Elitism, roulette or tournament selection depending on population diversity, two crossover types and adaptive Gaussian mutation.
- A* on an 11 by 20 grid with live re-routing; placing a tower that would block the path is refused.
- On-screen stats for generation, mutations and per-enemy fitness.
- Custom DynamicArray container used instead of std::vector.
STACK
MY CONTRIBUTION
- Genetic algorithm end to end: chromosomes, fitness, selection, crossover, mutation and the generation loop.
- A* pathfinding and the path-blocking check for tower placement.
- Wave system and the mapping from chromosomes to enemy stats.
- Game shell: state stack, menus, settings, audio, and the DynamicArray container.
SCREENS
Settings screen with master, music and SFX volume Main menu
CHALLENGE
With a population of only 20 and one wave per generation, the population can collapse into near-identical enemies. The algorithm tracks a diversity metric, switches from roulette to tournament selection when it drops, adapts mutation and crossover rates, and replaces the worst 20% with random chromosomes.