Using loop to Evolve!
Let’s create another game, making full use of
loop. But this won’t be a game that we play. Instead, it will be a game world that evolves as we watch it! We’re going to create an environment of steppes and jungles, filled with animals running around, foraging, eating, and reproducing. And after a few million units of time, we’ll see that they’ve evolved into different species!
This example is adapted from A.K. Dewdney’s article “Simulated evolution: wherein bugs learn to hunt bacteria,” in the “Computer Recreations” column of Scientific American (May 1989: 138-141).
Our game world is extremely simple. It consists of a simple ...