Gen 0
Item packed Item left out Best of generation
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.

Genetic Algorithm: 0/1 Knapsack Evolution

This simulation illustrates the core mechanics of genetic algorithms by solving a classic combinatorial optimization problem: the 0/1 knapsack. A population of binary chromosomes — each one a candidate packing of items into a limited-capacity knapsack — evolves generation after generation through tournament selection, single-point crossover, bit-flip mutation and elitism. Every individual is rendered live as a row of 3D cubes, sorted from best to worst, so you can watch the population converge from random noise toward a high-value, capacity-respecting solution in real time. Population size, mutation rate, crossover rate and playback speed are all adjustable, with generation count, best fitness, average fitness and best weight tracked live.