Java Reference

In-Depth Information

Exercise 10.14
Does increasing the maximum age for foxes lead to a significantly higher

numbers of foxes throughout a simulation, or is the rabbit population more likely to be reduced

to zero as a result?

Exercise 10.15
Experiment with different combinations of settings (breeding age, maximum

age, breeding probability, litter size, etc.) for foxes and rabbits. Do species always disappear

completely in some configurations? Are there configurations that are stableāi.e., that produce

a balance of numbers for a significant length of time?

Exercise 10.16
Experiment with different sizes of fields. (You can do this by using the

second constructor of
Simulator
.) Does the size of the field affect the likelihood of species

surviving?

Exercise 10.17
Compare the results of running a simulation with a single large field and two

simulations with fields that each have half the area of the single field. This models something

close to splitting an area in half with a freeway. Do you notice any significant differences in the

population dynamics between the two scenarios?

Exercise 10.18
Repeat the investigations of the previous exercise, but vary the proportions

of the two, smaller fields. For instance, try three-quarters and one quarter, or two-thirds and

one-third. Does it matter at all how the single field is split?

Exercise 10.19
Currently, a fox will eat at most one rabbit at each step. Modify the
find-

Food
method so that rabbits in all adjacent locations are eaten at a single step. Assess the im-

pact of this change on the results of the simulation. Note that the
findFood
method currently

returns the location of the single rabbit that is eaten, so you will need to return the location of

one of the eaten rabbits in your version. However, don't forget to return
null
if there are no

rabbits to eat.

Exercise 10.20
Following on from the previous exercise, if a fox eats multiple rabbits at a

single step, there are several different possibilities as to how we can model its food level. If we

add all the rabbit's food values, the fox will have a very high food level, making it unlikely to die

of hunger for a very long time. Alternatively, we could impose a ceiling on the fox's food level.

This models the effect of a predator that kills prey regardless of whether it is hungry or not.

Assess the impacts on the resulting simulation of implementing this choice.

Exercise 10.21
Challenge exercise
Given the random elements in the simulation,

argue why the population numbers in an apparently stable simulation could ultimately

collapse.

10.2.4 The
Simulator
class: setup

The
Simulator
class is the central part of the application that coordinates all the other pieces.

Code 10.3 illustrates some of its main features.

Search WWH ::

Custom Search