public abstract class Creature extends WorldObject
Modifier and Type | Field and Description |
---|---|
protected int |
age
The age of the creature (in simulation steps).
|
protected jadex.bridge.IComponentIdentifier |
aid
Agent identifier of the creature.
|
static java.lang.String[] |
alldirs
All possible directions.
|
protected int |
leaseticks
The number of simulation ticks, this creature is considered alive.
|
protected java.lang.String |
name
Unique name for this creature.
|
protected int |
points
Attribute for slot points.
|
protected int |
visionrange
The distance a creature is able to see.
|
protected int |
worldheight
The height of the world.
|
protected int |
worldwidth
The width of the world.
|
location
Constructor and Description |
---|
Creature()
Create a new Creature.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Clone the creature.
|
Location |
createLocation(Location loc,
java.lang.String dir)
Create a location.
|
Location |
createLocation(java.lang.String dir)
Create a location.
|
boolean |
equals(java.lang.Object o)
Test if two creatures are equal.
|
int |
getAge()
Get the age of this Creature.
|
jadex.bridge.IComponentIdentifier |
getAID()
Get the aid of this Creature.
|
java.lang.String[] |
getDirections(Location a,
Location b)
Get the directions between two locations.
|
java.lang.String[] |
getDirections(WorldObject a)
Get the directions between me and an object.
|
java.lang.String[] |
getDirections(WorldObject a,
WorldObject b)
Get the directions between two objects.
|
int |
getDistance(WorldObject a)
Get the distance between me and an object.
|
int |
getDistance(WorldObject a,
WorldObject b)
Get the distance between two objects
|
int |
getLeaseticks()
Get the leaseticks of this Creature.
|
int |
getLocationDistance(Location a,
Location b)
Get the distance between two locations.
|
java.lang.String |
getName()
Get the name of this Creature.
|
WorldObject |
getObject(Location loc,
WorldObject[] objects)
Get a world object at a specified location.
|
int |
getPoints()
Get the points of this Creature.
|
java.lang.String[] |
getPossibleDirections(WorldObject[] objects)
Get all possible directions to move.
|
int |
getVisionRange()
Get the visionrange of this Creature.
|
int |
getWorldHeight()
Get the world-height of this Creature.
|
int |
getWorldWidth()
Get the world-width of this Creature.
|
int |
hashCode()
Get the hash code of the creature.
|
boolean |
isInVisionRange(Location a)
Test if a location is in my vision range.
|
boolean |
isNear(Location a,
Location b,
int range)
Test if two locations are near
Range is in all direction (including diagonals).
|
void |
setAge(int age)
Set the age of this Creature.
|
void |
setAID(jadex.bridge.IComponentIdentifier aid)
Set the aid of this Creature.
|
void |
setLeaseticks(int leaseticks)
Set the leaseticks of this Creature.
|
void |
setName(java.lang.String name)
Set the name of this Creature.
|
void |
setPoints(int points)
Set the points of this Creature.
|
void |
setVisionRange(int visionrange)
Set the visionrange of this Creature.
|
void |
setWorldHeight(int worldheight)
Set the world-height of this Creature.
|
void |
setWorldWidth(int worldwidth)
Set the world-width of this Creature.
|
void |
sortByDistance(WorldObject[] objects)
Sort objects by distance.
|
void |
sortByDistance(WorldObject[] objects,
Location loc)
Sort objects by distance.
|
void |
update(Creature creature)
Update the creature.
|
getLocation, setLocation, toString
public static final java.lang.String[] alldirs
protected int age
protected int points
protected java.lang.String name
protected transient jadex.bridge.IComponentIdentifier aid
protected int visionrange
protected int worldwidth
protected int worldheight
protected int leaseticks
public int getAge()
public void setAge(int age)
age
- the value to be setpublic int getPoints()
public void setPoints(int points)
points
- the value to be setpublic java.lang.String getName()
public void setName(java.lang.String name)
name
- the value to be setpublic jadex.bridge.IComponentIdentifier getAID()
public void setAID(jadex.bridge.IComponentIdentifier aid)
aid
- the value to be setpublic int getVisionRange()
public void setVisionRange(int visionrange)
visionrange
- the value to be setpublic int getWorldWidth()
public void setWorldWidth(int worldwidth)
worldwidth
- the value to be setpublic int getWorldHeight()
public void setWorldHeight(int worldheight)
worldheight
- the value to be setpublic int getLeaseticks()
public void setLeaseticks(int leaseticks)
leaseticks
- the value to be setpublic boolean equals(java.lang.Object o)
equals
in class WorldObject
public int hashCode()
hashCode
in class WorldObject
public java.lang.Object clone()
clone
in class java.lang.Object
public Location createLocation(java.lang.String dir)
dir
- The direction.public Location createLocation(Location loc, java.lang.String dir)
loc
- The location.dir
- The direction.public int getDistance(WorldObject a)
public int getDistance(WorldObject a, WorldObject b)
public int getLocationDistance(Location a, Location b)
public boolean isNear(Location a, Location b, int range)
public boolean isInVisionRange(Location a)
public java.lang.String[] getDirections(WorldObject a)
public java.lang.String[] getDirections(WorldObject a, WorldObject b)
public java.lang.String[] getDirections(Location a, Location b)
public void sortByDistance(WorldObject[] objects)
public void sortByDistance(WorldObject[] objects, Location loc)
public WorldObject getObject(Location loc, WorldObject[] objects)
loc
- The location.public java.lang.String[] getPossibleDirections(WorldObject[] objects)
objects
- The objects near.public void update(Creature creature)