Class Creature

  • Direct Known Subclasses:
    Hunter, Observer, Prey

    public abstract class Creature
    extends WorldObject
    Editable Java class for concept Creature of hunterprey ontology.
    • 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.
      • 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.
    • Constructor Detail

      • Creature

        public Creature()
        Create a new Creature.
    • 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 class WorldObject
      • hashCode

        public int hashCode()
        Get the hash code of the creature.
        Overrides:
        hashCode in class WorldObject
      • clone

        public java.lang.Object clone()
        Clone the creature.
        Overrides:
        clone in class java.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.