I wanted to build a petri dish you could watch. Drop some creatures into a space with limited food and see what happens. They eat, grow, reproduce, and die, and the population booms, crashes, and recovers the way populations do when they share a resource that comes back at a fixed rate. You can intervene by dropping food wherever you click, or you can leave it alone and watch.
None of that is modeled. There's no population equation in the code. The oscillation comes out of a handful of per-creature rules and a constant food spawn rate, and it has the same shape a logistic curve or Lotka-Volterra would give.
The creatures
Each creature gets random traits: a body color from anywhere on the hue wheel, a diameter between 6 and 25 pixels, and six to nine tentacles. The tentacles animate with a sine undulation, so each creature has its own swimming motion. Two white eyes with black pupils sit on the body. They land somewhere between a cartoon octopus and something from a plankton net.
Eating makes a creature grow, and the per-frame energy cost grows with the square of the radius, so a creature twice as wide burns four times as fast. Past some size, intake can't keep up and it starves, so I never needed a size cap.
What they do
Creatures steer toward nearby food, push away from each other at close range, and flee the cursor inside a 100-pixel radius. Each frame the pulls sum into an acceleration, and velocity carries over with a drag factor below 1 so nothing teleports. They drift, turn, speed up toward food, and scatter when the cursor gets close. The cursor drags a faint blue glow so you can tell where the thing they're fleeing from is.
Food spawns at random positions at a constant rate and disappears after 300 frames if nobody reaches it. That constant rate sets the carrying capacity. With too many creatures they compete for what's there, and with too few the food sits uneaten until it vanishes. Clicking adds food at the cursor, which raises the ceiling for as long as you keep clicking.
Birth and death
Every frame, every living creature has a 1 percent chance of spawning a new one nearby. Offspring get fresh random traits rather than a copy of the parent, so the garden stays visually varied. With that rate, a creature that lives 200 frames has an 87 percent chance of reproducing at least once. Nothing selects on traits, but creatures that happen to be near food live longer and get more rolls of the dice.
A hunger counter climbs every frame and resets on eating, and when it crosses a threshold the creature dies. A lifespan counter runs alongside it, so a well-fed creature still dies when that runs out. The stats bar shows the current living count, the food count, and a score.