In this project, you will experiment with and modify the ecological simulation of "Fish" and "Bear" populations given in your textbook.
You are to do this project individually.
Download the eco.py file we have been working with, as well as the Fish.gif and Bear.gif images. You must place the image files in the same folder with the program. The images are from openclipart.org.
To gain an appreciation of just how different the biology of simulated Bears is from that of real bears, see what happens if you run the simulation starting with 1 Bear and 0 Fish, rather than 10 of each. To understand what lies behind your observations, start by thinking about the events within the life of a single Bear. Within the life of a single Bear, what oddity of the simulated Bear biology helps account for your observations? Other important issues span beyond a single Bear, to the relationship between a parent and a child; make sure you understand what allows the population of Bears deprived of any food source to behave as it does over the full course of the simulation. Be sure you understand what births and deaths occur and why. Consider whether any attempt at breeding ever fails because the chosen adjacent cell is occupied, and why or why not. Write a paragraph or two in college-level English thoroughly explaining your observations of the visible behavior and what aspects of the simulated biology account for them.
Add a method go the World class called getPopulation that can be used to find the population of any particular class, for example myworld.getPopulation(Fish) to find out how many Fish there are in myworld. This method takes one parameter other than self; that one parameter will always be a class such as Fish or Bear, but you should not rely on it necessarily being one of those two; your method should keep working even if other classes are added. (Warning: do not use the name "class" for this parameter, because that is a special reserved word in Python, like "def" or "if".)
Restore the mainSimulation function to starting with 10 Fish and 10 Bear, and modify it so that after all the time steps are over, but before freezing the world, it prints out information on the final population of Fish and of Bear. It should not just print out the two numbers; rather, it should also print out text that explains what the numbers are. An example might be
Final populations: 17 Fish and 39 Bear
Modify the Bear class so that when a Bear breeds, and creates a child Bear, it passes into the constructor (that is, the initialization method) information about how close to starvation the parent is, so that the child can start out correspondingly nutritionally compromised. You will also need to modify the mainSimulation function so that when the simulation starts, all of the Bears are initially fully nourished. Finally, describe in a sentence the impact this change had on the behavior of the simulation.
For this project, send an email message to max@gustavus.edu that includes the following items:
Your answer to the question about what happens when the world starts with one Bear and zero Fish, including a thorough explanation of what aspects of the simulated Bear biology result in this phenomenon.
Your answer to the question about how the simulation's behavior changed after your modifications to the Bear class.
Your complete program file, incorporating all the changes you made.
You will earn one point for each of the following accomplishments:
You accurately described the visible behavior of the 1 Bear, 0 Fish simulation.
You explained how the simulated behavior of each individual Bear contributed to the observed population-level behavior.
You explained how the condition of each newly born Bear, compared with that of its parent, contributed to the observed population-level behavior.
You correctly addressed the question of whether any breeding attempts ever failed due to an occupied cell, and why or why not.
Your explanation of the observed behavior and the mechanisms underlying it was written in college-level English.
Your getPopulation method starts with an appropriate def line.
Your getPopulation method examines each of the things in the world.
Your getPopulation method applies the appropriate test to each thing it considers.
Your getPopulation method keeps count.
Your getPopulation method returns the count.
Your mainSimulation function obtains the population of Fish at an appropriate point.
Your mainSimulation function obtains the population of Bear at an appropriate point.
Your mainSimulation function prints out the Fish population.
Your mainSimulation function prints out the Bear population.
Your mainSimulation function prints out appropriate identifying text.
You modified the Bear class so that the constructor accepts information about nutritional status.
You modified the Bear class so that when a Bear breeds, it passes along the appropriate nutritional information.
You modified the mainSimulation function so that when it creates each Bear, it calls the constructor with the appropriate number of parameters.
Your modification of the mainSimulation function creates each initial Bear fully nourished.
You wrote a sentence describing how the simulation's behavior changed after your modifications concerning the nutritional status of Bear cubs.