
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

In this homework you will be asked to enhance the Wolf and Deer Simulation.
You are given a zip file containing a working version of the wolf and deer simulation. Your task is to give deer that are not being chased by wolves the capability to become hungry and eat corn. The steps to accomplish this might be as follows: a. Create a new class Corn that extends the Agent class. It should not move, obviously, and should be drawn as a small yellow dot. When it has been eaten (the DEAD state), it should not be drawn, but can remain on the list. b. In the Model class where the original list of Agents is populated with deer, add some number of Corn objects scattered around the field to the list of Agents. c. Periodically, the Corn update method should create new Corn objects and add them to the Agent list provided to the update method. It might be interesting to locate the new corn objects randomly, but close to the object that creates them. You will need to fine tune the creation rate to make sure that a reasonable amount of corn is created.i d. Add suitable behavior and graphics to the hungry state in the deer’s state diagram. e. If a deer is HUNGRY, find the nearest corn and go there. f. When the deer is close enough, set that corn object state to DEAD and set the deer’s state to NORMAL. g. Any time a hungry wolf is close enough, the deer needs to switch to the SCARED state which causes it to forget about being hungry. h. Whether or not the deer is scared, it will starve if it doesn’t eat.
Turn in only the Model.java, Corn.java and Deer.java files.
i (^) Ignore my conversation in class about how an Agent doesn’t have access to the list of Agents; that list had to
be provided as a parameter to the update methods so that any Agent can search for nearby agents.