Class StatisticalHider
- java.lang.Object
-
- com.treasure.hunt.strategy.hider.impl.StatisticalHider
-
- Direct Known Subclasses:
FixedTreasureHider
,MobileTreasureHider
public abstract class StatisticalHider extends java.lang.Object
An 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 inStatisticalHider
How these hints are rated is up to the
StatisticalHider
subclasses by implementing therateHint(AngleHintStatistic)
method
-
-
Field Summary
Fields Modifier and Type Field Description protected double
absoluteAreaCutoff
static java.lang.String
badHintWeight_Preference
protected double
centroidDistanceToTreasure
protected double
counterStrategyGeometryCutoff
protected org.locationtech.jts.geom.Geometry
currentPossibleArea
static java.lang.String
DistanceFromNormalAngleLineToTreasureWeight_Preference
protected double
distanceFromNormalAngleRay
static java.lang.String
DistanceFromResultingCentroidToTreasureWeight_Preference
protected GameField
gameField
protected org.locationtech.jts.geom.GeometryFactory
gf
protected double
preferredHintSize
protected double
relativeAreaCutoff
static java.lang.String
relativeAreaCutoffWeight_Preference
protected org.locationtech.jts.geom.Point
startingPoint
protected org.locationtech.jts.geom.Point
treasure
-
Constructor Summary
Constructors Constructor Description StatisticalHider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.protected double
fillDistanceToCentroid(AngleHintStatistic ahs)
Inspects the given Hint in AngleHintStatistic and computes the distance between the angle-bisector and the treasure.protected double
fillDistanceToNormalLine(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 givenAngleHint
s 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 Generatessamples
evenly spacedAngleHint
s.org.locationtech.jts.geom.Point
getTreasureLocation()
void
init(org.locationtech.jts.geom.Point searcherStartPosition)
AngleHint
move(SearchPath searchPath)
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
-
-
-
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 ofAngleHint
s to evaluatesearchPath
- theSearchPath
- Returns:
- the chosen
AngleHint
with 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 givenAngleHint
s on the predicate of being able to see- Parameters:
stats
- the list ofAngleHintStatistic
s to filter- Returns:
- a list of valid
AngleHintStatistic
s
-
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 Generatessamples
evenly spacedAngleHint
s. Generated hints are not always exactly the preferred hint Size, the diverge about 3 * e-13
-
getTreasureLocation
public org.locationtech.jts.geom.Point getTreasureLocation()
-
-