Class Simulator

java.lang.Object
  extended by Simulator

public class Simulator
extends Object

A simple predator-prey simulator, based on a rectangular field containing rabbits and foxes.

Version:
2011.07.31
Author:
David J. Barnes and Michael Kölling

Constructor Summary
Simulator()
          Construct a simulation field with default size.
Simulator(int depth, int width)
          Create a simulation field with the given size.
 
Method Summary
 void reset()
          Reset the simulation to a starting position.
 void runLongSimulation()
          Run the simulation from its current state for a reasonably long period, (4000 steps).
 void simulate(int numSteps)
          Run the simulation from its current state for the given number of steps.
 void simulateOneStep()
          Run the simulation from its current state for a single step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Simulator

public Simulator()
Construct a simulation field with default size.


Simulator

public Simulator(int depth,
                 int width)
Create a simulation field with the given size.

Parameters:
depth - Depth of the field. Must be greater than zero.
width - Width of the field. Must be greater than zero.
Method Detail

reset

public void reset()
Reset the simulation to a starting position.


runLongSimulation

public void runLongSimulation()
Run the simulation from its current state for a reasonably long period, (4000 steps).


simulate

public void simulate(int numSteps)
Run the simulation from its current state for the given number of steps. Stop before the given number of steps if it ceases to be viable.

Parameters:
numSteps - The number of steps to run for.

simulateOneStep

public void simulateOneStep()
Run the simulation from its current state for a single step. Iterate over the whole field updating the state of each fox and rabbit.