|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.framework.Scheduler
This class controls operations on the modules for a single game. These operations include the client making a move, the server making a move, or other operations such as the server suggesting a move for the client.
Field Summary | |
private DAG |
dag
The DAG object associated with this Scheduler. |
private GameId |
id
The id of the current game. |
private Mode |
mode
The mode of this game, e.g, FAST. |
private HashMap |
modules
The name is a ModuleType object, the value a Module object. |
private HashMap |
nameToType
The name is a ModuleName object, the value is a ModuleType object. |
private static HashMap |
schedulers
Key is a GameId object, value is a Scheduler object. |
Constructor Summary | |
protected |
Scheduler(GameId id,
Mode mode,
Handicap handicap,
Rules rules,
float komi)
Create a Scheduler object. |
protected |
Scheduler(GameId id,
Mode mode,
Rules rules,
float komi)
Create a Scheduler object. |
protected |
Scheduler(GameId id,
Module[] mods,
Mode mode)
Create a Scheduler object. |
Method Summary | |
private static void |
addPrerequisiteModules(Scheduler sch,
HashSet hs,
Module m)
Get all of the modules which are dependent on the given module. |
Object |
clone()
Override the Object.clone method. |
MoveDescriptor |
generateMove()
Have the server generate a move. |
protected DAG |
getDAG()
Get the DAG associated with this Scheduler. |
protected GameId |
getGameId()
This method returns the game id. |
Module |
getModule(ModuleName name)
Get a copy of a module of the specified name. |
Module |
getModule(ModuleType type)
Get a copy of a module of the specified type. |
Module[] |
getModules()
Get a copy of all of the modules. |
protected short |
getMoveNumber()
Get the number of the move to be made next. |
private Module[] |
getRequired(Module module)
Get the required modules for a given module. |
static Scheduler |
getScheduler(GameId id,
ModuleName name)
Get a copy of the Scheduler object. |
Module |
getUnclonedModule(ModuleName name)
Get the module of the specified name. |
protected Module |
getUnclonedModule(ModuleType type)
Get the module of the given module type. |
protected Module[] |
getUnclonedModules()
Get an array of all of the modules. |
MoveDescriptor |
makeMove(Move move)
This method adds a move to the game modules. |
protected MoveDescriptor |
makePass()
The move is made which is a pass. |
protected void |
setInitialBoard(Stone[] stones)
Set the initial board position. |
protected MoveDescriptor |
suggestMove()
Have the server suggest a move for the client. |
MoveDescriptor |
validateMove(Move move)
This method validates a move. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static HashMap schedulers
private DAG dag
private Mode mode
private HashMap modules
private HashMap nameToType
private GameId id
Constructor Detail |
protected Scheduler(GameId id, Mode mode, Handicap handicap, Rules rules, float komi) throws InternalErrorException
id
- The id of the game.mode
- The mode of the game.handicap
- The handicap for the game.rules
- The rule set to play the gamekomi
- The komi for the game.
InternalErrorException
- Thrown if an error occurs for any reason.protected Scheduler(GameId id, Mode mode, Rules rules, float komi) throws InternalErrorException
id
- The id of the game.mode
- The mode of the game.rules
- The rule set to play the gamekomi
- The komi for the game.
InternalErrorException
- Thrown if an error occurs for any reason.protected Scheduler(GameId id, Module[] mods, Mode mode) throws InternalErrorException
So for example, a LifeAndDeath module might want to get a Scheduler object in which the terminating module was LifeAndDeath, not MoveGenerator. If all of the modules are in the mods parameter, then this method does the same thing as the clone() method.
id
- The id of the game to restore.mods
- The Module objects that represent the game.mode
- The mode of the game.
InternalErrorException
- Thrown if the operation fails for any reason.Method Detail |
public MoveDescriptor generateMove() throws Exception
Exception
- Thrown if the operation fails for any reason.protected short getMoveNumber() throws InternalErrorException
InternalErrorException
protected MoveDescriptor suggestMove() throws Exception
Exception
public Module getModule(ModuleType type) throws NoSuchDataException
type
- The type of the module to get.
NoSuchDataException
- Thrown if the module type is not contained by the scheduler.protected Module getUnclonedModule(ModuleType type) throws NoSuchDataException
type
- The type of the module to get.
NoSuchDataException
- Thrown if the module type is not contained by the scheduler.public Module getModule(ModuleName name) throws NoSuchDataException
name
- The name of the module to get.
NoSuchDataException
- Thrown if the module name is not contained by the scheduler.public Module getUnclonedModule(ModuleName name) throws NoSuchDataException
name
- The name of the module to get.
NoSuchDataException
- Thrown if the module name is not contained by the scheduler.public Module[] getModules()
protected Module[] getUnclonedModules()
protected GameId getGameId()
protected DAG getDAG()
public static Scheduler getScheduler(GameId id, ModuleName name) throws NoSuchDataException, InternalErrorException
This method would be used by a module which was doing search based processing.
id
- The id of the game.name
- The name of the terminating module.
NoSuchDataException
- Thrown if the module name
is not present in the Scheduler.
InternalErrorException
- Thrown if the operation fails for any reason.private static void addPrerequisiteModules(Scheduler sch, HashSet hs, Module m)
sch
- The Scheduler object.hs
- The HashSet to add the Module objects to.m
- The Module from which prerequisite modules are determined.public MoveDescriptor makeMove(Move move) throws Exception
move
- The move to be made.
Exception
- Thrown if any of the modules throw an exception.public MoveDescriptor validateMove(Move move) throws Exception
move
- The move to be made.
Exception
- Thrown if the move is illegal, or an error occurs for any reason.private Module[] getRequired(Module module)
module
- The module for which the prerequisite modules are gotten.
protected MoveDescriptor makePass() throws Exception
Exception
protected void setInitialBoard(Stone[] stones) throws InternalErrorException
stones
- The initial board position.
InternalErrorException
- Thrown if the operation fails for any reason.public Object clone()
clone
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |