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.Object
This is the engine which runs a simulation of a treasure hunt.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
finished
Tells, whether the game is done or not.protected boolean
firstMove
Tells, whether a first move is happened in the game yet, or not.protected Hider
hider
protected org.locationtech.jts.geom.Point
initialSearcherPoint
protected Hint
lastHint
protected SearchPath
lastSearchPath
static double
SCANNING_DISTANCE
protected Searcher
searcher
protected org.locationtech.jts.geom.Point
searcherPos
protected org.locationtech.jts.geom.Point
treasurePos
-
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 SearchPath
cutSearchPath(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)
Hider
getHider()
Searcher
getSearcher()
Statistic
getStatistics()
protected void
hiderMove()
Turn
init()
boolean
isFinished()
Tells, whether the game is done or not.static boolean
located(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)
Turn
move()
This simulates just one step of the simulation.protected void
searcherMove()
Let thesearcher
makeSearchPath
.protected static void
verifyHint(Hint previousHint, Hint currentHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)
protected static void
verifyHint(AngleHint previousAngleHint, AngleHint currentAngleHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)
protected static void
verifyHint(CircleHint previousCircleHint, CircleHint currentCircleHint, org.locationtech.jts.geom.Point treasurePosition, org.locationtech.jts.geom.Point searcherPosition)
protected void
verifySearchPath(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
, theSearcher
movedtreasurePos
- thePoint
, describing the location of the treasure- Returns:
true
if theSearcher
found the treasure.false
otherwise. TheSearcher
found the treasure, if had a distance of ≤SCANNING_DISTANCE
in this SearchPath.
-
cutSearchPath
public static SearchPath cutSearchPath(SearchPath searchPath, org.locationtech.jts.geom.Point treasurePos)
- Parameters:
searchPath
- theSearchPath
, in which theSearcher
found the treasure.treasurePos
- thePoint
the 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 thesearcher
makeSearchPath
.
-
verifySearchPath
protected void verifySearchPath(SearchPath searchPath)
- Parameters:
searchPath
-Hint
to be verified- Throws:
java.lang.IllegalArgumentException
- if theSearchPath
searchPath
did 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 previousCircleHint
currentCircleHint
-CircleHint
to be verifiedtreasurePosition
-Point
of the treasure positionsearcherPosition
-Point
of theSearcher
position- Throws:
java.lang.IllegalArgumentException
- if theCircleHint
circleHint
did 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.
-
-