public class Nibbler extends Animal
Note that the spatial x, y, and neighbourhood details are inherited from 'Animal'.
To do: Crowded nibblers with nowhere to move to will currently loop forever. Need a stopping condition adding. See "run()".
| Constructor and Description |
|---|
Nibbler(Environment worldIn,
java.util.ArrayList<Agent> agentsIn)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
interactWithEnvironment()
Checks the value in the environment at the location, and 'nibbles' it down a bit
if there is values to nibble.
|
private boolean |
locationSuitable(int x,
int y)
Checks a prospective location for suitability.
|
private void |
move()
Moves the nibbler from its current location to a random position one step away.
|
void |
run()
Moves the nibbler from its current location to a random position one step away.
|
getNeighbourhood, getNeighbourhood, getX, getYpublic Nibbler(Environment worldIn, java.util.ArrayList<Agent> agentsIn)
worldIn - environment for the modelagentsIn - list of all the agents in the modelpublic void run()
private void move()
private boolean locationSuitable(int x,
int y)
x - spatial x coordinatey - spatial y coordinateprivate void interactWithEnvironment()