Losanges bouffants
Age at the end of the project: 16
Losanges bouffants (hungry diamonds) is an artificial life simulation that I programmed in JavaScript with p5.js in high school, out of curiosity for artificial intelligence. Three populations of diamonds, green, red and blue, live in the same arena. Each population has its own food, and the food of the others is poison for it.
Every diamond is controlled by a small neural network. Its inputs are its speed and the direction and distance of the nearest food and poison, and its outputs are rotation, forward speed and strafe. Nobody teaches them anything: when a diamond dies, a genetic algorithm creates a new one by copying or crossing over the DNA of the best individuals, chosen with a probability proportional to their fitness, then mutating it. After a few minutes, the diamonds learn by themselves to chase their food and avoid poison.
The simulation
The three populations learning to eat their food and avoid poison
Scoreboard
The arena on the left, and every individual ranked by fitness on the right
Neural network
The brain of the selected diamond: its inputs on the left, its decisions on the right
Try it live
This is the original code, running in your browser. Click on a diamond to follow it, press T to see its neural network, and click on the column titles to sort the scoreboard.