Class GameEngine

  • Direct Known Subclasses:
    HideAndSeekGameEngine

    public class GameEngine
    extends java.lang.Object
    This is the engine which runs a simulation of a treasure hunt.
    • Field Detail

      • SCANNING_DISTANCE

        public static double SCANNING_DISTANCE
      • searcher

        protected final Searcher searcher
      • hider

        protected final Hider hider
      • initialSearcherPoint

        protected final org.locationtech.jts.geom.Point initialSearcherPoint
      • finished

        protected boolean finished
        Tells, whether the game is done or not.
      • firstMove

        protected boolean firstMove
        Tells, whether a first move is happened in the game yet, or not.
      • lastHint

        protected Hint lastHint
      • lastSearchPath

        protected SearchPath lastSearchPath
      • searcherPos

        protected org.locationtech.jts.geom.Point searcherPos
      • treasurePos

        protected org.locationtech.jts.geom.Point treasurePos
    • Constructor Detail

      • GameEngine

        public GameEngine​(Searcher searcher,
                          Hider hider)
        The constructor.
        Parameters:
        searcher - playing the game
        hider - playing the game
      • GameEngine

        public GameEngine​(Searcher searcher,
                          Hider hider,
                          org.locationtech.jts.geom.Point initialSearcherPoint)
        The constructor.
        Parameters:
        searcher - playing the game
        hider - playing the game
        initialSearcherPoint - the initial Searcher Point.
    • Method Detail

      • located

        public static boolean located​(SearchPath searchPath,
                                      org.locationtech.jts.geom.Point treasurePos)
        Parameters:
        searchPath - a valid SearchPath, the Searcher moved
        treasurePos - the Point, describing the location of the treasure
        Returns:
        true if the Searcher found the treasure. false otherwise. The Searcher found the treasure, if had a distance of ≤ SCANNING_DISTANCE in this SearchPath.
      • cutSearchPath

        public static SearchPath cutSearchPath​(SearchPath searchPath,
                                               org.locationtech.jts.geom.Point treasurePos)
        Parameters:
        searchPath - the SearchPath, in which the Searcher found the treasure.
        treasurePos - the Point the treasure lies on.
        Returns:
        a cut SearchPath, containing only the points needed, to find the treasure.
      • init

        public Turn init()
        Initializes Searcher, Hider and the treasure position and simulates an initial Step.
        Returns:
        a Turn, since the initialization must be displayed.
      • move

        public Turn move()
        This simulates just one step of the simulation. The searcher begins since we want not force him, to take a initial hint, he eventually do not need, f.e. if he works randomized!
        Returns:
        the Turn, happened in this step.
      • verifySearchPath

        protected void verifySearchPath​(SearchPath searchPath)
        Verifies whether the SearchPath searchPath given by the Hider followed the given rules.
        Parameters:
        searchPath - Hint to be verified
        Throws:
        java.lang.IllegalArgumentException - if the SearchPath searchPath did not followed the rules.
      • verifyHint

        protected static void verifyHint​(AngleHint previousAngleHint,
                                         AngleHint currentAngleHint,
                                         org.locationtech.jts.geom.Point treasurePosition,
                                         org.locationtech.jts.geom.Point searcherPosition)
        Verifies whether the AngleHint angleHint given by the Hider followed the given rules.
        Parameters:
        previousAngleHint - the previous AngleHint
        currentAngleHint - AngleHint to be verified
        treasurePosition - Point of the treasure position
        searcherPosition - Point of the searcher position
        Throws:
        java.lang.IllegalArgumentException - if the AngleHint angleHint did not followed the rules.
      • verifyHint

        protected static void verifyHint​(CircleHint previousCircleHint,
                                         CircleHint currentCircleHint,
                                         org.locationtech.jts.geom.Point treasurePosition,
                                         org.locationtech.jts.geom.Point searcherPosition)
        Verifies whether the CircleHint circleHint given by the Hider followed the given rules.
        Parameters:
        previousCircleHint - the previous CircleHint
        currentCircleHint - CircleHint to be verified
        treasurePosition - Point of the treasure position
        searcherPosition - Point of the Searcher position
        Throws:
        java.lang.IllegalArgumentException - if the CircleHint circleHint did not followed the rules
      • verifyHint

        protected static void verifyHint​(Hint previousHint,
                                         Hint currentHint,
                                         org.locationtech.jts.geom.Point treasurePosition,
                                         org.locationtech.jts.geom.Point searcherPosition)
        Verifies whether the Hint hint given by the Hider followed the given rules.
        Parameters:
        previousHint - the previous Hint
        currentHint - Hint to be verified
        treasurePosition - Point of the treasure position
        searcherPosition - Point of the searcher position
        Throws:
        java.lang.IllegalArgumentException - if the Hint hint did not followed the rules.
      • hiderMove

        protected void hiderMove()
        Let the hider give its Hint.
      • getSearcher

        public Searcher getSearcher()
      • getHider

        public Hider getHider()
      • getStatistics

        public Statistic getStatistics()
      • isFinished

        public boolean isFinished()
        Tells, whether the game is done or not.