org.moyoman.module.random.randomimpl
Class RandomImpl

java.lang.Object
  |
  +--org.moyoman.module.Module
        |
        +--org.moyoman.module.random.randomimpl.RandomImpl
All Implemented Interfaces:
Cloneable, Component, ModuleInterface, Random, Serializable

public class RandomImpl
extends Module
implements Random

This module implements the Random interface. It rates all legal moves, as well as providing functionality for choosing 1 of N randomly.

See Also:
Serialized Form

Field Summary
private static float conf
          The confidence in the ratings of this module.
private static DebugType[] dt
          The debug types that this module supports.
private  boolean isGenerated
           
private  ModuleType[] mt
          The modules that this module requires.
private static Random rand
          The Java Random class.
private  RatedMove[] ratedMoves
          The rated moves for this module.
private static ServerConfig sc
          The ServerConfig singleton.
 
Fields inherited from class org.moyoman.module.Module
 
Fields inherited from interface org.moyoman.module.random.Random
CONFIDENCE
 
Constructor Summary
RandomImpl(GameId id, ModuleName name)
          Create the RandomImpl object.
 
Method Summary
 Object clone()
          Override the Object.clone() method.
 void generateMove(Module[] modules)
          Generate the rated moves.
 Debug[] getDebugInformation(DebugType[] types)
          Get the debug information for this module.
 DebugType[] getDebugTypes()
          Get the debug types that this module supports.
 RatedMove[] getMoves()
          Get the rated moves for this module.
 short getRandomShort(short total)
          This method returns a number between 0 and total - 1.
 ModuleType[] getRequiredModuleList()
          Get the modules that this module requires.
 void makeMove(Move move, Module[] modules)
          Update this module with the move.
 
Methods inherited from class org.moyoman.module.Module
checkTime, create, createHelper, debug, error, error, fatal, fatal, getAllHelpers, getHelper, getId, getKomi, getModule, getModuleName, getScheduler, information, setTime, warning, warning
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.moyoman.module.ModuleInterface
getScheduler
 

Field Detail

rand

private static Random rand
The Java Random class. The paranoid could use SecureRandom instead.


sc

private static ServerConfig sc
The ServerConfig singleton.


conf

private static float conf
The confidence in the ratings of this module.


mt

private ModuleType[] mt
The modules that this module requires.


ratedMoves

private RatedMove[] ratedMoves
The rated moves for this module.


isGenerated

private boolean isGenerated

dt

private static DebugType[] dt
The debug types that this module supports.

Constructor Detail

RandomImpl

public RandomImpl(GameId id,
                  ModuleName name)
           throws InternalErrorException
Create the RandomImpl object.

Parameters:
id - The game id.
name - The name of this module.
Throws:
InternalErrorException - Thrown if an error occurs for any reason.
Method Detail

getRandomShort

public short getRandomShort(short total)
This method returns a number between 0 and total - 1. This method can be used for tasks such as choosing which fuseki to play. Modules should use this method instead of using their own Random class because it allows for reproducibility of results for debugging purposes.

Specified by:
getRandomShort in interface Random
Parameters:
total - The number of choices.
Returns:
A short between 0 and total - 1.

generateMove

public void generateMove(Module[] modules)
Generate the rated moves. The result of this call is that the rated move array is filled in.

Specified by:
generateMove in class Module
Parameters:
modules - The modules that this method uses.

getDebugInformation

public Debug[] getDebugInformation(DebugType[] types)
Get the debug information for this module.

Specified by:
getDebugInformation in class Module
Parameters:
types - The debug types that the caller can use.
Returns:
An array of Debug objects.

getDebugTypes

public DebugType[] getDebugTypes()
Get the debug types that this module supports.

Specified by:
getDebugTypes in class Module
Returns:
An array of DebugType objects.

getMoves

public RatedMove[] getMoves()
Get the rated moves for this module.

Specified by:
getMoves in interface ModuleInterface
Specified by:
getMoves in class Module
Returns:
An array of RatedMove objects.

getRequiredModuleList

public ModuleType[] getRequiredModuleList()
Get the modules that this module requires.

Specified by:
getRequiredModuleList in class Module
Returns:
An array of ModuleType objects.

makeMove

public void makeMove(Move move,
                     Module[] modules)
Update this module with the move. This module doesn't do anything on a move being made, except for clearing out some variables set in generateMove().

Specified by:
makeMove in class Module
Parameters:
move - The last move made.
modules - The modules that this module requires.

clone

public Object clone()
Override the Object.clone() method.

Specified by:
clone in interface ModuleInterface
Overrides:
clone in class Module
Returns:
A RandomImpl object which is a clone of this one.