Package com.treasure.hunt.game
Class GameEngine
- java.lang.Object
-
- com.treasure.hunt.game.GameEngine
-
- Direct Known Subclasses:
HideAndSeekGameEngine
public class GameEngine extends java.lang.ObjectThis is the engine which runs a simulation of a treasure hunt.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanfinishedTells, whether the game is done or not.protected booleanfirstMoveTells, whether a first move is happened in the game yet, or not.protected Hiderhiderprotected org.locationtech.jts.geom.PointinitialSearcherPointprotected HintlastHintprotected SearchPathlastSearchPathstatic doubleSCANNING_DISTANCEprotected Searchersearcherprotected org.locationtech.jts.geom.PointsearcherPosprotected org.locationtech.jts.geom.PointtreasurePos
-
Constructor Summary
Constructors Constructor Description GameEngine(Searcher searcher, Hider hider)The constructor.GameEngine(Searcher searcher, Hider hider, org.locationtech.jts.geom.Point initialSearcherPoint)The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SearchPathcutSearchPath(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)HidergetHider()SearchergetSearcher()StatisticgetStatistics()protected voidhiderMove()Turninit()booleanisFinished()Tells, whether the game is done or not.static booleanlocated(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)Turnmove()This simulates just one step of the simulation.protected voidsearcherMove()Let thesearchermakeSearchPath.protected static voidverifyHint(Hint previousHint, Hint currentHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)protected static voidverifyHint(AngleHint previousAngleHint, AngleHint currentAngleHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)protected static voidverifyHint(CircleHint previousCircleHint, CircleHint currentCircleHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)protected voidverifySearchPath(SearchPath searchPath)
-
-
-
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
-
-
Method Detail
-
located
public static boolean located(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)
- Parameters:
searchPath- a validSearchPath, theSearchermovedtreasurePos- thePoint, describing the location of the treasure- Returns:
trueif theSearcherfound the treasure.falseotherwise. TheSearcherfound the treasure, if had a distance of ≤SCANNING_DISTANCEin this SearchPath.
-
cutSearchPath
public static SearchPath cutSearchPath(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)
- Parameters:
searchPath- theSearchPath, in which theSearcherfound the treasure.treasurePos- thePointthe treasure lies on.- Returns:
- a cut
SearchPath, containing only the points needed, to find the treasure.
-
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.
-
searcherMove
protected void searcherMove()
Let thesearchermakeSearchPath.
-
verifySearchPath
protected void verifySearchPath(SearchPath searchPath)
- Parameters:
searchPath-Hintto be verified- Throws:
java.lang.IllegalArgumentException- if theSearchPathsearchPathdid 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)
-
verifyHint
protected static void verifyHint(CircleHint previousCircleHint, CircleHint currentCircleHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)
- Parameters:
previousCircleHint- the previousCircleHintcurrentCircleHint-CircleHintto be verifiedtreasurePosition-Pointof the treasure positionsearcherPosition-Pointof theSearcherposition- Throws:
java.lang.IllegalArgumentException- if theCircleHintcircleHintdid 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)
-
hiderMove
protected void hiderMove()
-
getSearcher
public Searcher getSearcher()
-
getHider
public Hider getHider()
-
getStatistics
public Statistic getStatistics()
-
isFinished
public boolean isFinished()
Tells, whether the game is done or not.
-
-