Class GameField
- java.lang.Object
-
- com.treasure.hunt.strategy.hider.impl.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 havethese 3 structures are used to calculate the remaining possible area to place the treasure into possibleArea: BoundingCircle \ {checkedArea + AreaExcludedByHints)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CircleExtension_Preference
-
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 possibleAreavoid
commitPlayerMovement(SearchPath searchPath)
Updates the GameField's state with a new Players SearchPathGeometryItem<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 valuesboolean
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 locationvoid
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.
-
-
-
Field Detail
-
CircleExtension_Preference
public static final java.lang.String CircleExtension_Preference
- See Also:
- Constant Field Values
-
-
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 attreasureLocation
- 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 SearchPaththis 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
- thePoint
we want to know, whether it lies in this area- Returns:
true
if the specifiedPoint
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
Coordinate
s 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)
-
-