public class Carnivore extends Animal
Modifier and Type | Field and Description |
---|---|
private Direction |
currentDirection |
static Genome |
defaultGenome |
static int |
fights_won |
private int[] |
preyPosition |
static int |
total_fights |
age, attemptedMovesThisTurn, energy, exhaustion, generation, genome, gestationPeriod, IDnumber, isAlive, movesThisTurn, offspring, parent, random, type, x, y
Constructor and Description |
---|
Carnivore(int setID,
Genome newGenome,
int myGeneration,
int setX,
int setY,
int setEnergy,
int parentID)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
attack()
The carnivore has run down a herbivore and now tries to kill it
XXX Warning: here be magic numbers!
|
private void |
hunt()
The carnivore runs toward a herbivore
|
private boolean |
strengthEnergyFight(int pred_str,
int pred_en,
int prey_str,
int prey_en)
A fight method based on the strength and current energy of the combatants.
|
private boolean |
strengthFight(int predStrength,
int preyStrength)
A fight method based on the strength of the combatants.
|
void |
update()
Each turn, the carnivore looks for a herbivore and moves towards it.
|
changeEnergy, closestSearch, exhaust, getAge, getDirection, getDistance, getEnergy, getGeneration, getGenome, getID, getInfo, getNeighbouringField, getOffspring, getParent, getType, getX, getY, isAlive, mixedSearch, move, randomizedSearch, reproduce, search, setAge, setEnergy, setPosition
public static int fights_won
public static int total_fights
private int[] preyPosition
private Direction currentDirection
public static Genome defaultGenome
public Carnivore(int setID, Genome newGenome, int myGeneration, int setX, int setY, int setEnergy, int parentID)
setID
- newGenome
- myGeneration
- setX
- setY
- setEnergy
- parentID
- public void update()
private void hunt()
private void attack()
private boolean strengthEnergyFight(int pred_str, int pred_en, int prey_str, int prey_en)
private boolean strengthFight(int predStrength, int preyStrength)