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 SummaryFields Modifier and Type Field Description protected IInternalAccessagentThe agent to which the service belongs.protected java.util.Map<java.lang.Integer,java.util.SortedSet<HighscoreEntry>>entriesThe highscore entries (boardsize->sorted set).protected IExternalAccessextaThe external access for decoupling settings service calls.protected static intMAX_ENTRIESThe number of entries per board size in the high score list.
 - 
Constructor SummaryConstructors Constructor Description PuzzleService()
 - 
Method SummaryAll 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_ENTRIESprotected static final int MAX_ENTRIES The number of entries per board size in the high score list.- See Also:
- Constant Field Values
 
 - 
agentprotected IInternalAccess agent The agent to which the service belongs.
 - 
extaprotected IExternalAccess exta The external access for decoupling settings service calls.
 - 
entriesprotected java.util.Map<java.lang.Integer,java.util.SortedSet<HighscoreEntry>> entries The highscore entries (boardsize->sorted set).
 
- 
 - 
Method Detail- 
startServicepublic IFuture<java.lang.Void> startService() Init method called on service startup.
 - 
shutdownServicepublic IFuture<java.lang.Void> shutdownService() Termination method called on service shutdown.
 - 
hintpublic IFuture<Move> hint(Board board, long timeout) Solve the game and give a hint on the next move.- Specified by:
- hintin interface- IPuzzleService
- 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.
 
 - 
addHighscorepublic IFuture<java.lang.Void> addHighscore(HighscoreEntry entry) Add a highscore entry and save the highscore list.- Specified by:
- addHighscorein interface- IPuzzleService
- Parameters:
- entry- The highscore entry.
 
 - 
getHighscorepublic IFuture<java.util.SortedSet<HighscoreEntry>> getHighscore(int size) Get the highscore entries for a given board size.- Specified by:
- getHighscorein interface- IPuzzleService
- Parameters:
- size- The board size (e.g. 3, 5, ...).
- Returns:
- The sorted set of highscore entries (highest entry first).
 
 - 
saveprotected IFuture<java.lang.Void> save() Save highscore using settings service.
 - 
setPropertiespublic IFuture<java.lang.Void> setProperties(Properties props) Update from given properties.- Specified by:
- setPropertiesin interface- IPropertiesProvider
 
 - 
getPropertiespublic IFuture<Properties> getProperties() Write current state into properties.- Specified by:
- getPropertiesin interface- IPropertiesProvider
 
 
- 
 
-