|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.module.Module
The base class for all modules in the system. This class is probably the most crucial one for the developer who wants to contribute their own implementation of a module.
Field Summary | |
private DebugType[] |
debugTypes
The debug types that this module supports. |
private HashMap |
helpers
The name is a HelperType object, and the value is the Helper object. |
private GameId |
id
The game that this module is associated with. |
private ModuleName |
moduleName
The name of the module. |
private float |
time
|
Constructor Summary | |
protected |
Module(GameId id,
ModuleName name)
Create the Module object. |
Method Summary | |
protected float |
checkTime()
Return information on how the game as a whole is doing on time. |
Object |
clone()
Clone the module. |
static Module |
create(GameId id,
ModuleName name)
Create a Module object. |
protected Helper |
createHelper(String name)
Create a helper for this module |
void |
debug(String msg)
Log a debug message in the module. |
protected void |
error(Exception e)
Log an error in the module. |
void |
error(String msg)
Log an error in the module. |
protected void |
fatal(Exception e)
Log a fatal error in the module. |
void |
fatal(String msg)
Log a fatal error in the module. |
private String |
formatMessage(String msg)
Format the message string so that it can be easily parsed. |
abstract void |
generateMove(Module[] modules)
Generate the move for this module. |
protected Helper[] |
getAllHelpers()
Get all of the helpers for this module. |
abstract Debug[] |
getDebugInformation(DebugType[] types)
Return the debug information for this module. |
abstract DebugType[] |
getDebugTypes()
Return the types of debug information that this module supports. |
protected Helper |
getHelper(HelperType ht)
Get the helper of a specific type. |
protected GameId |
getId()
Get the id that this module is associated with. |
protected float |
getKomi()
|
static Module |
getModule(Module[] modules,
ModuleType type)
Return the module from the array that is of the specific type. |
ModuleName |
getModuleName()
Return the ModuleName object. |
abstract RatedMove[] |
getMoves()
Return the moves generated by the module. |
abstract ModuleType[] |
getRequiredModuleList()
Return the modules that this module requires to perform its task. |
Scheduler |
getScheduler()
Get a Scheduler object for this module. |
void |
information(String msg)
Log an information message in the module. |
private String |
logPrefix()
Get the string that is to be logged before the actual message. |
abstract void |
makeMove(Move move,
Module[] modules)
Update the internal data structures of this module with the new move. |
void |
setTime(float t)
Set the time for this module. |
protected void |
warning(Exception e)
Log a warning in the module. |
void |
warning(String msg)
Log a warning in the module. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private DebugType[] debugTypes
private GameId id
private float time
private ModuleName moduleName
private HashMap helpers
Constructor Detail |
protected Module(GameId id, ModuleName name) throws InternalErrorException
id
- The id of the game.name
- The name of the module.
InternalErrorException
- Thrown if anything goes wrong.Method Detail |
public static final Module create(GameId id, ModuleName name) throws InternalErrorException
id
- The id of the game.name
- The name of the module.
InternalErrorException
- Thrown if anything goes wrong.
Should never happen except during development.protected float checkTime()
protected float getKomi()
public Object clone()
clone
in interface ModuleInterface
clone
in class Object
public void setTime(float t) throws IllegalArgumentException
t
- The time to be set.
IllegalArgumentException
- Thrown if t is outside the range of -1.0 to 1.0.public final Scheduler getScheduler()
getScheduler
in interface ModuleInterface
public abstract void generateMove(Module[] modules) throws InternalErrorException
modules
- An array of modules which this module needs
in order to perform its work. Those modules reflect the
current state of the board but are copies of the actual modules,
so this method is free to manipulate them.
InternalErrorException
public abstract Debug[] getDebugInformation(DebugType[] types)
types
- The debug types that the caller knows how to handle.
public abstract DebugType[] getDebugTypes()
protected final GameId getId()
public final ModuleName getModuleName()
public static final Module getModule(Module[] modules, ModuleType type) throws NoSuchDataException
modules
- An array of module objectstype
- The module type being searched for.
NoSuchDataException
- An exception is thrown if the desired module
type is not present.public abstract RatedMove[] getMoves()
getMoves
in interface ModuleInterface
public abstract ModuleType[] getRequiredModuleList()
public abstract void makeMove(Move move, Module[] modules) throws IllegalMoveException, InternalErrorException
move
- The move that was just made.modules
- The modules that this method needs to perform its job.
Exception
- Thrown if the move is illegal for some reason.
IllegalMoveException
InternalErrorException
protected Helper[] getAllHelpers()
protected Helper getHelper(HelperType ht) throws NoSuchDataException
ht
- The helper type to be retrieved.
NoSuchDataException
- Thrown if there is no helper of that type.protected Helper createHelper(String name) throws NoSuchDataException, InternalErrorException
name
- The name of the helper.
NoSuchDataException
- Thrown if the name does not correspond to a valid helper type.
InternalErrorException
- Thrown if the operation fails for any reason.protected void fatal(Exception e)
e
- The exception that was thrown.protected void error(Exception e)
e
- The exception that was thrown.protected void warning(Exception e)
e
- The exception that was thrown.public void fatal(String msg)
msg
- The message to be logged.public void error(String msg)
msg
- The message to be logged.public void warning(String msg)
msg
- The message to be logged.public void information(String msg)
msg
- The message to be logged.public void debug(String msg)
msg
- The message to be logged.private String logPrefix()
private String formatMessage(String msg)
msg
- The message.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |