org.moyoman.module.dame.dameimpl
Class DameImpl

java.lang.Object
  |
  +--org.moyoman.module.Module
        |
        +--org.moyoman.module.dame.dameimpl.DameImpl
All Implemented Interfaces:
Cloneable, Component, Dame, ModuleInterface, Serializable

public class DameImpl
extends Module
implements Dame

This module implements the Dame interface. Currently, the algorithm is fairly simple, and only empty points which are adjacent to both black and white stones and are legal moves for the current side are identified. In the future, life and death issues will need to be taken into account.

Author:
Urban Hafner
See Also:
Serialized Form

Field Summary
private  HashSet dame
          The dame points.
private static DebugType[] dt
          The debug types that this module supports.
private static ModuleType[] mt
          The modules upon which this module depends.
 
Fields inherited from class org.moyoman.module.Module
 
Constructor Summary
DameImpl(GameId id, ModuleName name)
          Create a DameImpl object.
 
Method Summary
 boolean canPointBePlayed(Point pt)
          Checks if the given dame Point pt can be played.
 Object clone()
          Clone the module.
 void generateMove(Module[] modules)
          Compute all dame points.
 Set getDamePoints()
          Returns all dame points on the board.
 Debug[] getDebugInformation(DebugType[] types)
          Return the debug information for this module.
 DebugType[] getDebugTypes()
          Get the debug types that this module supports.
 RatedMove[] getMoves()
          Returns an empty array as dame points are by definition not worth playing.
 ModuleType[] getRequiredModuleList()
          Get the module types used by this module.
 boolean isDamePoint(Point pt)
          Checks if the given Point pt is a dame point.
private  boolean isDamePointHelper(Stone st, Board board)
          Computes if the given point is dame.
 void makeMove(Move move, Module[] modules)
          Invalidates the dame points that were computed for the previous 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

mt

private static ModuleType[] mt
The modules upon which this module depends.


dt

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


dame

private HashSet dame
The dame points.

Constructor Detail

DameImpl

public DameImpl(GameId id,
                ModuleName name)
         throws InternalErrorException
Create a DameImpl object.

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

isDamePointHelper

private boolean isDamePointHelper(Stone st,
                                  Board board)
Computes if the given point is dame. If it is false will be returned.

Parameters:
st - The point that we are looking at.

isDamePoint

public boolean isDamePoint(Point pt)
Checks if the given Point pt is a dame point.

Specified by:
isDamePoint in interface Dame
Parameters:
pt - The point in question.
Returns:
true if the point is a dame point, or false.

canPointBePlayed

public boolean canPointBePlayed(Point pt)
                         throws IllegalArgumentException
Checks if the given dame Point pt can be played.

Specified by:
canPointBePlayed in interface Dame
Parameters:
pt - The dame point in question.
Returns:
true if the point can be played, or false.
Throws:
IllegalArgumentException - Thrown if the point is not a dame point.

getDamePoints

public Set getDamePoints()
Returns all dame points on the board.

Specified by:
getDamePoints in interface Dame
Returns:
A Set containing Point objects.

generateMove

public void generateMove(Module[] modules)
                  throws InternalErrorException
Compute all dame points.

Specified by:
generateMove in class Module
Parameters:
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

getDebugInformation

public Debug[] getDebugInformation(DebugType[] types)
Description copied from class: Module
Return the debug information for this module.

Specified by:
getDebugInformation in class Module
Parameters:
types - The debug types that the caller knows how to handle.
Returns:
The debug information that this module supports.

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()
Returns an empty array as dame points are by definition not worth playing.

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

getRequiredModuleList

public ModuleType[] getRequiredModuleList()
Get the module types used by this module.

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

makeMove

public void makeMove(Move move,
                     Module[] modules)
              throws IllegalMoveException,
                     InternalErrorException
Invalidates the dame points that were computed for the previous move.

Specified by:
makeMove in class Module
Parameters:
move - The move that was just made.
modules - The modules that this method needs to perform its job.
IllegalMoveException
InternalErrorException

clone

public Object clone()
Description copied from interface: ModuleInterface
Clone the module. This method overrides the one in Object. Cloning modules is an important requirement for the system to function correctly. The derived class of Module must override this method. It may be as straightforward as calling super.clone(). Consult any Java textbook for more details. If you are not sure, ask for help.

Specified by:
clone in interface ModuleInterface
Overrides:
clone in class Module
Returns:
The cloned Module object.