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 intageThe age of the creature (in simulation steps).protected IComponentIdentifieraidAgent identifier of the creature.static java.lang.String[]alldirsAll possible directions.protected intleaseticksThe number of simulation ticks, this creature is considered alive.protected java.lang.StringnameUnique name for this creature.protected intpointsAttribute for slot points.protected intvisionrangeThe distance a creature is able to see.protected intworldheightThe height of the world.protected intworldwidthThe 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.Objectclone()Clone the creature.LocationcreateLocation(Location loc, java.lang.String dir)Create a location.LocationcreateLocation(java.lang.String dir)Create a location.booleanequals(java.lang.Object o)Test if two creatures are equal.intgetAge()Get the age of this Creature.IComponentIdentifiergetAID()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.intgetDistance(WorldObject a)Get the distance between me and an object.intgetDistance(WorldObject a, WorldObject b)Get the distance between two objectsintgetLeaseticks()Get the leaseticks of this Creature.intgetLocationDistance(Location a, Location b)Get the distance between two locations.java.lang.StringgetName()Get the name of this Creature.WorldObjectgetObject(Location loc, WorldObject[] objects)Get a world object at a specified location.intgetPoints()Get the points of this Creature.java.lang.String[]getPossibleDirections(WorldObject[] objects)Get all possible directions to move.intgetVisionRange()Get the visionrange of this Creature.intgetWorldHeight()Get the world-height of this Creature.intgetWorldWidth()Get the world-width of this Creature.inthashCode()Get the hash code of the creature.booleanisInVisionRange(Location a)Test if a location is in my vision range.booleanisNear(Location a, Location b, int range)Test if two locations are near Range is in all direction (including diagonals).voidsetAge(int age)Set the age of this Creature.voidsetAID(IComponentIdentifier aid)Set the aid of this Creature.voidsetLeaseticks(int leaseticks)Set the leaseticks of this Creature.voidsetName(java.lang.String name)Set the name of this Creature.voidsetPoints(int points)Set the points of this Creature.voidsetVisionRange(int visionrange)Set the visionrange of this Creature.voidsetWorldHeight(int worldheight)Set the world-height of this Creature.voidsetWorldWidth(int worldwidth)Set the world-width of this Creature.voidsortByDistance(WorldObject[] objects)Sort objects by distance.voidsortByDistance(WorldObject[] objects, Location loc)Sort objects by distance.voidupdate(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:
equalsin classWorldObject
-
hashCode
public int hashCode()
Get the hash code of the creature.- Overrides:
hashCodein classWorldObject
-
clone
public java.lang.Object clone()
Clone the creature.- Overrides:
clonein 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.
-
-