Class StatisticalHider
- java.lang.Object
-
- com.treasure.hunt.strategy.hider.impl.StatisticalHider
-
- Direct Known Subclasses:
FixedTreasureHider,MobileTreasureHider
public abstract class StatisticalHider extends java.lang.ObjectAn abstract hider which implements methods to play a basic game It also supplies methods to judge a given hint by generating statistics about the hint and saving them inStatisticalHiderHow these hints are rated is up to the
StatisticalHidersubclasses by implementing therateHint(AngleHintStatistic)method
-
-
Field Summary
Fields Modifier and Type Field Description protected doubleabsoluteAreaCutoffstatic java.lang.StringbadHintWeight_Preferenceprotected doublecentroidDistanceToTreasureprotected doublecounterStrategyGeometryCutoffprotected org.locationtech.jts.geom.GeometrycurrentPossibleAreastatic java.lang.StringDistanceFromNormalAngleLineToTreasureWeight_Preferenceprotected doubledistanceFromNormalAngleRaystatic java.lang.StringDistanceFromResultingCentroidToTreasureWeight_Preferenceprotected GameFieldgameFieldprotected org.locationtech.jts.geom.GeometryFactorygfprotected doublepreferredHintSizeprotected doublerelativeAreaCutoffstatic java.lang.StringrelativeAreaCutoffWeight_Preferenceprotected org.locationtech.jts.geom.PointstartingPointprotected org.locationtech.jts.geom.Pointtreasure
-
Constructor Summary
Constructors Constructor Description StatisticalHider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AngleHinteval(java.util.List<AngleHint> hints, SearchPath searchPath)Evaluates the Hints by generating some statistics on them, rating the Hints, and returning the best.protected doublefillDistanceToCentroid(AngleHintStatistic ahs)Inspects the given Hint in AngleHintStatistic and computes the distance between the angle-bisector and the treasure.protected doublefillDistanceToNormalLine(AngleHintStatistic ahs)Inspects the given Hint in AngleHintStatistic and computes the distance between the angle-bisector and the treasure.protected java.util.List<AngleHintStatistic>filterForValidHints(java.util.List<AngleHintStatistic> stats)Filters the givenAngleHints on the predicate of being able to seeprotected java.util.List<AngleHint>generateHints(int samples, org.locationtech.jts.geom.Point hintCenter)Todo: if hint is 180degree make it an explicit HalfPlaneHint/ hack it such that StrategyFromPaper receives a halfplaneHint Generatessamplesevenly spacedAngleHints.org.locationtech.jts.geom.PointgetTreasureLocation()voidinit(org.locationtech.jts.geom.Point searcherStartPosition)AngleHintmove(SearchPath searchPath)protected abstract doublerateHint(AngleHintStatistic ahs)Rates the Given Hint with a custom function, saves the result in the AngleHintStatistic - Wrapper and returns the result
-
-
-
Field Detail
-
relativeAreaCutoffWeight_Preference
public static final java.lang.String relativeAreaCutoffWeight_Preference
- See Also:
- Constant Field Values
-
DistanceFromNormalAngleLineToTreasureWeight_Preference
public static final java.lang.String DistanceFromNormalAngleLineToTreasureWeight_Preference
- See Also:
- Constant Field Values
-
DistanceFromResultingCentroidToTreasureWeight_Preference
public static final java.lang.String DistanceFromResultingCentroidToTreasureWeight_Preference
- See Also:
- Constant Field Values
-
badHintWeight_Preference
public static final java.lang.String badHintWeight_Preference
- See Also:
- Constant Field Values
-
gameField
protected GameField gameField
-
gf
protected org.locationtech.jts.geom.GeometryFactory gf
-
startingPoint
protected org.locationtech.jts.geom.Point startingPoint
-
currentPossibleArea
protected org.locationtech.jts.geom.Geometry currentPossibleArea
-
centroidDistanceToTreasure
protected double centroidDistanceToTreasure
-
absoluteAreaCutoff
protected double absoluteAreaCutoff
-
relativeAreaCutoff
protected double relativeAreaCutoff
-
counterStrategyGeometryCutoff
protected double counterStrategyGeometryCutoff
-
distanceFromNormalAngleRay
protected double distanceFromNormalAngleRay
-
treasure
protected org.locationtech.jts.geom.Point treasure
-
preferredHintSize
protected double preferredHintSize
-
-
Method Detail
-
init
public void init(org.locationtech.jts.geom.Point searcherStartPosition)
-
move
public AngleHint move(SearchPath searchPath)
-
eval
public AngleHint eval(java.util.List<AngleHint> hints, SearchPath searchPath)
Evaluates the Hints by generating some statistics on them, rating the Hints, and returning the best.- Parameters:
hints- the list ofAngleHints to evaluatesearchPath- theSearchPath- Returns:
- the chosen
AngleHintwith the best rating
-
rateHint
protected abstract double rateHint(AngleHintStatistic ahs)
Rates the Given Hint with a custom function, saves the result in the AngleHintStatistic - Wrapper and returns the result- Parameters:
ahs- The AngleHint - Wrapper , in which the result is saved- Returns:
- the rating of the hint
-
fillDistanceToNormalLine
protected double fillDistanceToNormalLine(AngleHintStatistic ahs)
Inspects the given Hint in AngleHintStatistic and computes the distance between the angle-bisector and the treasure. The result is written into the corresponding AngleHintStatistic- Parameters:
ahs- the AngleHintStatistic Wrapper containing the Hint- Returns:
- the distance
-
fillDistanceToCentroid
protected double fillDistanceToCentroid(AngleHintStatistic ahs)
Inspects the given Hint in AngleHintStatistic and computes the distance between the angle-bisector and the treasure. The result is written into the corresponding AngleHintStatistic- Parameters:
ahs- the AngleHintStatistic Wrapper containing the Hint- Returns:
- the distance
-
filterForValidHints
protected java.util.List<AngleHintStatistic> filterForValidHints(java.util.List<AngleHintStatistic> stats)
Filters the givenAngleHints on the predicate of being able to see- Parameters:
stats- the list ofAngleHintStatistics to filter- Returns:
- a list of valid
AngleHintStatistics
-
generateHints
protected java.util.List<AngleHint> generateHints(int samples, org.locationtech.jts.geom.Point hintCenter)
Todo: if hint is 180degree make it an explicit HalfPlaneHint/ hack it such that StrategyFromPaper receives a halfplaneHint Generatessamplesevenly spacedAngleHints. Generated hints are not always exactly the preferred hint Size, the diverge about 3 * e-13
-
getTreasureLocation
public org.locationtech.jts.geom.Point getTreasureLocation()
-
-