Modifier and Type | Field and Description |
---|---|
protected int |
age |
protected int |
attemptedMovesThisTurn |
protected int |
energy |
protected int |
exhaustion |
protected int |
generation |
protected Genome |
genome |
protected int |
gestationPeriod |
protected int |
IDnumber |
protected boolean |
isAlive |
protected int |
movesThisTurn |
protected int |
offspring |
protected int |
parent |
protected java.util.Random |
random |
protected OccupantType |
type |
protected int |
x |
protected int |
y |
Constructor and Description |
---|
Animal(int setID,
OccupantType myType,
Genome newGenome,
int myGeneration,
int setX,
int setY,
int setEnergy,
int parentID)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
changeEnergy(int amount)
Change the energy level of this animal.
|
int[] |
closestSearch(OccupantType type)
Search for the inputed object within the line of sight.
|
void |
exhaust(int e) |
int |
getAge() |
Direction |
getDirection(int xpos,
int ypos)
In which direction are the given coordinates relative to this animal?
|
int |
getDistance(int xpos,
int ypos)
How many steps are needed to get to the specified position?
|
int |
getEnergy() |
int |
getGeneration() |
Genome |
getGenome() |
long |
getID() |
java.util.HashMap<java.lang.String,java.lang.Integer> |
getInfo()
Return a hash map containing all the information about this animal.
|
int[] |
getNeighbouringField(Direction dir)
Calculate the neighbouring square in the specified direction
(return null if out of bounds)
|
int |
getOffspring() |
int |
getParent() |
OccupantType |
getType() |
int |
getX() |
int |
getY() |
boolean |
isAlive() |
int[] |
mixedSearch(OccupantType type)
Search for the inputed object within the line of sight.
|
boolean |
move(Direction dir)
The animal moves in the specified direction.
|
int[] |
randomizedSearch(OccupantType type)
Search for the inputed object within the line of sight.
|
void |
reproduce()
The animal reproduces, setting down a child on a neighbouring square
|
int[] |
search(OccupantType type)
Search for the inputed object within the line of sight.
|
void |
setAge(int newAge) |
void |
setEnergy(int newEnergy) |
void |
setPosition(int newX,
int newY) |
void |
update()
This method has to be called by every species.
|
protected int IDnumber
protected int parent
protected Genome genome
protected int generation
protected int offspring
protected OccupantType type
protected int x
protected int y
protected int age
protected int energy
protected int movesThisTurn
protected int attemptedMovesThisTurn
protected int exhaustion
protected int gestationPeriod
protected boolean isAlive
protected java.util.Random random
public Animal(int setID, OccupantType myType, Genome newGenome, int myGeneration, int setX, int setY, int setEnergy, int parentID)
setID
- myType
- newGenome
- myGeneration
- setX
- setY
- setEnergy
- parentID
- public void update()
public void reproduce()
public boolean move(Direction dir)
public int[] search(OccupantType type)
public int[] randomizedSearch(OccupantType type)
public int[] closestSearch(OccupantType type)
public int[] mixedSearch(OccupantType type)
public int[] getNeighbouringField(Direction dir)
public Direction getDirection(int xpos, int ypos)
xpos
- ypos
- public int getDistance(int xpos, int ypos)
public java.util.HashMap<java.lang.String,java.lang.Integer> getInfo()
public boolean isAlive()
public long getID()
public Genome getGenome()
public int getGeneration()
public int getParent()
public int getOffspring()
public OccupantType getType()
public int getX()
public int getY()
public int getAge()
public int getEnergy()
public void changeEnergy(int amount)
amount
- public void setEnergy(int newEnergy)
public void setAge(int newAge)
public void setPosition(int newX, int newY)
public void exhaust(int e)