12 Creating Simulations and Games
Sketch 89: Predator-Prey Simulation
Picture rabbits and coyotes living together in their natural environment. They don’t get along in the traditional sense: coyotes tend to eat rabbits when they can. Rabbits can breed very quickly, whereas coyotes cannot. And, of course, if rabbits are the only prey, then if the rabbits should all perish, the coyotes will also, soon after. This is a predator-prey relationship, and it can be simply modeled when there is only one species in each group.
Mathematically the predator-prey relationship is represented by a pair of differential equations (don’t worry, very little ...
Get An Artist's Guide to Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.