Class Creature
- java.lang.Object
-
- jadex.bdi.examples.hunterprey_classic.WorldObject
-
- jadex.bdi.examples.hunterprey_classic.Creature
-
public abstract class Creature extends WorldObject
Editable Java class for concept Creature of hunterprey ontology.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
age
The age of the creature (in simulation steps).protected 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.-
Fields inherited from class jadex.bdi.examples.hunterprey_classic.WorldObject
location
-
-
Constructor Summary
Constructors Constructor Description Creature()
Create a new Creature.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.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 objectsint
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(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.-
Methods inherited from class jadex.bdi.examples.hunterprey_classic.WorldObject
getLocation, setLocation, toString
-
-
-
-
Field Detail
-
alldirs
public static final java.lang.String[] alldirs
All possible directions.
-
age
protected int age
The age of the creature (in simulation steps).
-
points
protected int points
Attribute for slot points.
-
name
protected java.lang.String name
Unique name for this creature.
-
aid
protected transient IComponentIdentifier aid
Agent identifier of the creature.
-
visionrange
protected int visionrange
The distance a creature is able to see.
-
worldwidth
protected int worldwidth
The width of the world.
-
worldheight
protected int worldheight
The height of the world.
-
leaseticks
protected int leaseticks
The number of simulation ticks, this creature is considered alive.
-
-
Method Detail
-
getAge
public int getAge()
Get the age of this Creature. The age of the creature (in simulation steps).- Returns:
- age
-
setAge
public void setAge(int age)
Set the age of this Creature. The age of the creature (in simulation steps).- Parameters:
age
- the value to be set
-
getPoints
public int getPoints()
Get the points of this Creature.- Returns:
- points
-
setPoints
public void setPoints(int points)
Set the points of this Creature.- Parameters:
points
- the value to be set
-
getName
public java.lang.String getName()
Get the name of this Creature. Unique name for this creature.- Returns:
- name
-
setName
public void setName(java.lang.String name)
Set the name of this Creature. Unique name for this creature.- Parameters:
name
- the value to be set
-
getAID
public IComponentIdentifier getAID()
Get the aid of this Creature. Agent identifier of the creature.- Returns:
- aid
-
setAID
public void setAID(IComponentIdentifier aid)
Set the aid of this Creature. Agent identifier of the creature.- Parameters:
aid
- the value to be set
-
getVisionRange
public int getVisionRange()
Get the visionrange of this Creature. The distance a creature is able to see.- Returns:
- visionrange
-
setVisionRange
public void setVisionRange(int visionrange)
Set the visionrange of this Creature. The distance a creature is able to see.- Parameters:
visionrange
- the value to be set
-
getWorldWidth
public int getWorldWidth()
Get the world-width of this Creature. The width of the world.- Returns:
- world-width
-
setWorldWidth
public void setWorldWidth(int worldwidth)
Set the world-width of this Creature. The width of the world.- Parameters:
worldwidth
- the value to be set
-
getWorldHeight
public int getWorldHeight()
Get the world-height of this Creature. The height of the world.- Returns:
- world-height
-
setWorldHeight
public void setWorldHeight(int worldheight)
Set the world-height of this Creature. The height of the world.- Parameters:
worldheight
- the value to be set
-
getLeaseticks
public int getLeaseticks()
Get the leaseticks of this Creature. The number of simulation ticks, this creature is considered alive.- Returns:
- leaseticks
-
setLeaseticks
public void setLeaseticks(int leaseticks)
Set the leaseticks of this Creature. The number of simulation ticks, this creature is considered alive.- Parameters:
leaseticks
- the value to be set
-
equals
public boolean equals(java.lang.Object o)
Test if two creatures are equal.- Overrides:
equals
in classWorldObject
-
hashCode
public int hashCode()
Get the hash code of the creature.- Overrides:
hashCode
in classWorldObject
-
clone
public java.lang.Object clone()
Clone the creature.- Overrides:
clone
in classjava.lang.Object
-
createLocation
public Location createLocation(java.lang.String dir)
Create a location.- Parameters:
dir
- The direction.- Returns:
- The new location.
-
createLocation
public Location createLocation(Location loc, java.lang.String dir)
Create a location.- Parameters:
loc
- The location.dir
- The direction.- Returns:
- The new location.
-
getDistance
public int getDistance(WorldObject a)
Get the distance between me and an object.- Returns:
- The number of moves required to move between the objects
-
getDistance
public int getDistance(WorldObject a, WorldObject b)
Get the distance between two objects- Returns:
- The number of moves required to move between the objects
-
getLocationDistance
public int getLocationDistance(Location a, Location b)
Get the distance between two locations.- Returns:
- The number of moves required to move between the locations.
-
isNear
public boolean isNear(Location a, Location b, int range)
Test if two locations are near Range is in all direction (including diagonals).
-
isInVisionRange
public boolean isInVisionRange(Location a)
Test if a location is in my vision range.
-
getDirections
public java.lang.String[] getDirections(WorldObject a)
Get the directions between me and an object.- Returns:
- The possible directions to move nearer to the 2nd object.
-
getDirections
public java.lang.String[] getDirections(WorldObject a, WorldObject b)
Get the directions between two objects.- Returns:
- The possible directions to move nearer to the 2nd object.
-
getDirections
public java.lang.String[] getDirections(Location a, Location b)
Get the directions between two locations.- Returns:
- The possible directions to move nearer to the 2nd location.
-
sortByDistance
public void sortByDistance(WorldObject[] objects)
Sort objects by distance.
-
sortByDistance
public void sortByDistance(WorldObject[] objects, Location loc)
Sort objects by distance.
-
getObject
public WorldObject getObject(Location loc, WorldObject[] objects)
Get a world object at a specified location.- Parameters:
loc
- The location.- Returns:
- The object at the location.
-
getPossibleDirections
public java.lang.String[] getPossibleDirections(WorldObject[] objects)
Get all possible directions to move.- Parameters:
objects
- The objects near.- Returns:
- The objects one can move to.
-
update
public void update(Creature creature)
Update the creature.
-
-