Class GameField


  • public class GameField
    extends java.lang.Object
    There are 3 Structures to represent the state of Algorithm Bounding Area: the biggest Area in which the Strategy wants to place the treasure checkedArea: the Area the player has visited and thus must not contain the target AreaExcludedByHints: the Area the previous hints have

    these 3 structures are used to calculate the remaining possible area to place the treasure into possibleArea: BoundingCircle \ {checkedArea + AreaExcludedByHints)

    • Constructor Summary

      Constructors 
      Constructor Description
      GameField()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.locationtech.jts.geom.Geometry commitHint​(AngleHint hint)
      Finally commits the hint and integrates it with the current possibleArea
      void commitPlayerMovement​(SearchPath searchPath)
      Updates the GameField's state with a new Players SearchPath
      GeometryItem<org.locationtech.jts.geom.Polygon> getInnerBufferItem()  
      org.locationtech.jts.geom.Geometry getPossibleArea()  
      org.locationtech.jts.geom.Point getStartingPoint()  
      java.util.List<javafx.util.Pair<org.locationtech.jts.geom.Coordinate,​java.lang.Double>> getWorstPointsOnAllEdges​(double minDistance)
      Checks all edges of the possibleArea for the Coordinate which maximizes the value of {dist(C - Player) / dist( C -Origin) }
      void init​(org.locationtech.jts.geom.Point searcherStartPosition, org.locationtech.jts.geom.Point treasureLocation)
      Initializes the Gamefield with its initial values
      boolean isWithinGameField​(org.locationtech.jts.geom.Point point)  
      void moveTreasure​(org.locationtech.jts.geom.Point newTreasureLocation)
      Asks the Gamefield to move the treasure to the speciefied new location
      void setSearcherScoutRadius​(double searcherScoutRadius)  
      org.locationtech.jts.geom.Geometry testHint​(AngleHint angleHint)
      Integrates the 2 intersections between the bounding circle and the current hint, then merges the resulting polygon and the remaining possible area to the new possible area.
      • Methods inherited from class java.lang.Object

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

      • CircleExtension_Preference

        public static final java.lang.String CircleExtension_Preference
        See Also:
        Constant Field Values
    • Constructor Detail

      • GameField

        public GameField()
    • Method Detail

      • moveTreasure

        public void moveTreasure​(org.locationtech.jts.geom.Point newTreasureLocation)
                          throws ImpossibleTreasureLocationException
        Asks the Gamefield to move the treasure to the speciefied new location
        Parameters:
        newTreasureLocation - the new treasure location
        Throws:
        ImpossibleTreasureLocationException - is thrown when newTreasureLocation is not within the checked area or violates a previously given hint
      • init

        public void init​(org.locationtech.jts.geom.Point searcherStartPosition,
                         org.locationtech.jts.geom.Point treasureLocation)
        Initializes the Gamefield with its initial values
        Parameters:
        searcherStartPosition - the position, the player starts at
        treasureLocation - the postition, the player wants to reach
      • getPossibleArea

        public org.locationtech.jts.geom.Geometry getPossibleArea()
        Returns:
        a Polygon containing the possible area, in which the treasure could be
      • commitPlayerMovement

        public void commitPlayerMovement​(SearchPath searchPath)
        Updates the GameField's state with a new Players SearchPath

        this method assumes that the the searcher cannot fly, e.g. For 2 visited points, all points on the line between them are counted as checked, and of those point, all points within a distance of searcherScoutRadius are checked as well

        Parameters:
        searchPath - the new SearchPath
      • testHint

        public org.locationtech.jts.geom.Geometry testHint​(AngleHint angleHint)
        Integrates the 2 intersections between the bounding circle and the current hint, then merges the resulting polygon and the remaining possible area to the new possible area.

        The resulting area is NOT committed, therefore this method can be used to test a possibleHint for its result

        Parameters:
        angleHint - The hint to integrate
        Returns:
        the resulting Geometry
      • commitHint

        public org.locationtech.jts.geom.Geometry commitHint​(AngleHint hint)
        Finally commits the hint and integrates it with the current possibleArea
        Parameters:
        hint - the Hint to be integrated
        Returns:
        the resulting Area in which the Treasure could be
      • isWithinGameField

        public boolean isWithinGameField​(org.locationtech.jts.geom.Point point)
        Parameters:
        point - the Point we want to know, whether it lies in this area
        Returns:
        true if the specified Point point lies within the this area, false otherwise
      • getWorstPointsOnAllEdges

        public java.util.List<javafx.util.Pair<org.locationtech.jts.geom.Coordinate,​java.lang.Double>> getWorstPointsOnAllEdges​(double minDistance)
        Checks all edges of the possibleArea for the Coordinate which maximizes the value of {dist(C - Player) / dist( C -Origin) }
        Parameters:
        minDistance -
        Returns:
        a list of pairs, containing Coordinates with their corresponding constant of (Coordinate C ; their associated Value of {dist(C-Player)/dist(C-Origin)} )
      • getStartingPoint

        public org.locationtech.jts.geom.Point getStartingPoint()
      • getInnerBufferItem

        public GeometryItem<org.locationtech.jts.geom.Polygon> getInnerBufferItem()
      • setSearcherScoutRadius

        public void setSearcherScoutRadius​(double searcherScoutRadius)