Package jadex.web.examples.puzzle.agent
Class PuzzleService
- java.lang.Object
-
- jadex.web.examples.puzzle.agent.PuzzleService
-
- All Implemented Interfaces:
IPropertiesProvider
,IPuzzleService
public class PuzzleService extends java.lang.Object implements IPuzzleService, IPropertiesProvider
Implementation of the puzzle service.
-
-
Field Summary
Fields Modifier and Type Field Description protected IInternalAccess
agent
The agent to which the service belongs.protected java.util.Map<java.lang.Integer,java.util.SortedSet<HighscoreEntry>>
entries
The highscore entries (boardsize->sorted set).protected IExternalAccess
exta
The external access for decoupling settings service calls.protected static int
MAX_ENTRIES
The number of entries per board size in the high score list.
-
Constructor Summary
Constructors Constructor Description PuzzleService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFuture<java.lang.Void>
addHighscore(HighscoreEntry entry)
Add a highscore entry and save the highscore list.IFuture<java.util.SortedSet<HighscoreEntry>>
getHighscore(int size)
Get the highscore entries for a given board size.IFuture<Properties>
getProperties()
Write current state into properties.IFuture<Move>
hint(Board board, long timeout)
Solve the game and give a hint on the next move.protected IFuture<java.lang.Void>
save()
Save highscore using settings service.IFuture<java.lang.Void>
setProperties(Properties props)
Update from given properties.IFuture<java.lang.Void>
shutdownService()
Termination method called on service shutdown.IFuture<java.lang.Void>
startService()
Init method called on service startup.
-
-
-
Field Detail
-
MAX_ENTRIES
protected static final int MAX_ENTRIES
The number of entries per board size in the high score list.- See Also:
- Constant Field Values
-
agent
protected IInternalAccess agent
The agent to which the service belongs.
-
exta
protected IExternalAccess exta
The external access for decoupling settings service calls.
-
entries
protected java.util.Map<java.lang.Integer,java.util.SortedSet<HighscoreEntry>> entries
The highscore entries (boardsize->sorted set).
-
-
Method Detail
-
startService
public IFuture<java.lang.Void> startService()
Init method called on service startup.
-
shutdownService
public IFuture<java.lang.Void> shutdownService()
Termination method called on service shutdown.
-
hint
public IFuture<Move> hint(Board board, long timeout)
Solve the game and give a hint on the next move.- Specified by:
hint
in interfaceIPuzzleService
- Parameters:
board
- The current board state.timeout
- A timeout to stop, when no solution is found in time (-1 for no timeout).- Returns:
- The tile to move next.
- Throws:
java.lang.Exception
- in future, when puzzle can not be solved in time.
-
addHighscore
public IFuture<java.lang.Void> addHighscore(HighscoreEntry entry)
Add a highscore entry and save the highscore list.- Specified by:
addHighscore
in interfaceIPuzzleService
- Parameters:
entry
- The highscore entry.
-
getHighscore
public IFuture<java.util.SortedSet<HighscoreEntry>> getHighscore(int size)
Get the highscore entries for a given board size.- Specified by:
getHighscore
in interfaceIPuzzleService
- Parameters:
size
- The board size (e.g. 3, 5, ...).- Returns:
- The sorted set of highscore entries (highest entry first).
-
save
protected IFuture<java.lang.Void> save()
Save highscore using settings service.
-
setProperties
public IFuture<java.lang.Void> setProperties(Properties props)
Update from given properties.- Specified by:
setProperties
in interfaceIPropertiesProvider
-
getProperties
public IFuture<Properties> getProperties()
Write current state into properties.- Specified by:
getProperties
in interfaceIPropertiesProvider
-
-