Docsity

Enhancing Behavioral Simulation – Assignment 7 | CS 1316, Assignments of Computer Science

Toggle sidebar
bg1
Homework 7: Enhancing Behavioral Simulation
DUE DATE: NOON on Monday July 14th
In this homework you will be asked to enhance the Wolf and Deer Simulation.
Requirements
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
Agent
s.
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
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 Ag ents; that list had to
be provided as a parameter to the update methods so that any Agent can search for nea rby agents.

Partial preview of the text

Download Enhancing Behavioral Simulation – Assignment 7 | CS 1316 and more Assignments Computer Science in PDF only on Docsity!

Homework 7: Enhancing Behavioral Simulation

DUE DATE: NOON on Monday July 14th

In this homework you will be asked to enhance the Wolf and Deer Simulation.

Requirements

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

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.