← Back to projects
Genetic Golf
A visual genetic algorithm: 500 golf balls learn by evolution to reach the hole while dodging obstacles.
500agents per generation
The problem
The AI course's final project asked for a tangible demonstration of evolutionary computing, not a results spreadsheet.
What I did
Implemented the full evolutionary loop in JavaScript with p5.js: per-shot DNA of [x, y, angle, force], a fitness function with penalties, mating pool and mutation, animated in-browser with 500 agents and 15 shots per individual.
The outcome
Working in-browser simulator, presented as the Artificial Intelligence course's final project.
How it evolves
- 500 balls with random DNAInput
- DNA of position, angle and power15 shots per individual
- Shot simulationWith obstacles
- Fitness with penaltiesHow close to the hole
- Mating pool and mutationThe best ones breed
- A generation that reaches the holeOutput
Nobody teaches the ball where the hole is. Each generation takes its shots, gets scored by how close it got, and the best ones breed: the behavior emerges from selection, not from programming.
Stack
- JavaScript
- p5.js
- HTML/CSS