Class TreasureHunterEnvironment

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class TreasureHunterEnvironment
    extends java.lang.Object
    implements java.io.Closeable
    The treasure hunter world representation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double HEIGHT
      The environment width.
      protected java.util.Set<Treasure> islands
      The collected treasures (just for painting).
      protected java.awt.geom.Point2D.Double location
      The treasure hunter location.
      protected jadex.bdiv3.quickstart.treasureisland.environment.EnvironmentPanel panel
      The gui.
      protected java.util.Random rnd
      The random number generator.
      protected java.util.Set<Treasure> treasures
      The treasures.
      static double WIDTH
      The environment width.
    • Constructor Summary

      Constructors 
      Constructor Description
      TreasureHunterEnvironment()
      Create a treasure hunter world of given size.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Auto close the gui when the agent is killed.
      java.awt.geom.Point2D getHunterLocation()
      Get the treasure hunter location.
      java.util.Set<Treasure> getTreasures()
      Get the current treasures.
      boolean isAtLocation​(java.awt.geom.Point2D location)
      Check if the hunter is at (i.e.
      IFuture<java.lang.Void> move​(double dx, double dy)
      Try to move a given distance.
      IFuture<java.lang.Void> pickUp​(Treasure treasure)
      Pickup a treasure.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • rnd

        protected java.util.Random rnd
        The random number generator.
      • location

        protected java.awt.geom.Point2D.Double location
        The treasure hunter location.
      • treasures

        protected java.util.Set<Treasure> treasures
        The treasures.
      • islands

        protected java.util.Set<Treasure> islands
        The collected treasures (just for painting).
      • panel

        protected jadex.bdiv3.quickstart.treasureisland.environment.EnvironmentPanel panel
        The gui.
    • Constructor Detail

      • TreasureHunterEnvironment

        public TreasureHunterEnvironment()
        Create a treasure hunter world of given size.
        Parameters:
        width - The width (in pixels).
        height - The height (in pixels).
    • Method Detail

      • getHunterLocation

        public java.awt.geom.Point2D getHunterLocation()
        Get the treasure hunter location.
      • getTreasures

        public java.util.Set<Treasure> getTreasures()
        Get the current treasures.
        Returns:
        A copy of the current treasures.
      • move

        public IFuture<java.lang.Void> move​(double dx,
                                            double dy)
        Try to move a given distance. Due to slip or terrain properties the end location might differ from the desired location.
        Parameters:
        dx - The intended horizontal movement, i.e. delta-x.
        dy - The intended vertical movement, i.e. delta-y.
        Returns:
        A future that is finished, when the movement operation is completed.
      • pickUp

        public IFuture<java.lang.Void> pickUp​(Treasure treasure)
        Pickup a treasure. Only works, when at the location.
        Parameters:
        treasure - The treasure to be picked up.
        Returns:
        A future that is finished, when the pick up operation is completed, i.e. failed or succeeded.
      • isAtLocation

        public boolean isAtLocation​(java.awt.geom.Point2D location)
        Check if the hunter is at (i.e. close enough to) a given location.
      • close

        public void close()
        Auto close the gui when the agent is killed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable