org.moyoman.module.fuseki.simplefuseki
Class SimpleFuseki

java.lang.Object
  |
  +--org.moyoman.module.Module
        |
        +--org.moyoman.module.fuseki.simplefuseki.SimpleFuseki
All Implemented Interfaces:
Cloneable, Component, Fuseki, ModuleInterface, Serializable

public class SimpleFuseki
extends Module
implements Fuseki

This module implements the Fuseki interface. It is responsible for evaluating moves in the opening.

See Also:
Serialized Form

Field Summary
private static DebugType[] dt
          The debug types that this module supports.
private  boolean isFusekiOver
          If set, then no more work remains to be done by this module.
private  boolean isGenerated
          This flag is used to determine when to clear variables set by generateMove().
private  ModuleType[] mt
          The modules that this module requires.
private static HashMap points
          The key is a Point object, and the value is an ArrayList containing Point objects.
private  RatedMove[] rm
          The moves that were rated by this module.
 
Fields inherited from class org.moyoman.module.Module
 
Fields inherited from interface org.moyoman.module.fuseki.Fuseki
CONFIDENCE
 
Constructor Summary
SimpleFuseki(GameId id, ModuleName name)
          Create the SimpleFuseki object.
 
Method Summary
private  void addCornerMoves(short moveNumber, Color color, Point pt, Set set)
          Rate different corner moves in the empty corner.
private static void addPoint(Point pt1, Point pt2)
          Add a pair of points into the points HashMap.
 Object clone()
          Clone the module.
 void generateMove(Module[] modules)
          Generate the move for this module.
private  HashSet getCornerMoves(short moveNumber, Color color, Geometry geo)
          Get rated moves for all moves in empty corners.
 Debug[] getDebugInformation(DebugType[] types)
          Return the debug information for this module.
 DebugType[] getDebugTypes()
          Return the types of debug information that this module supports.
 RatedMove[] getMoves()
          Return the moves generated by the module.
private  RatedMove getRatedMove(Point pt, Board board)
          Create a RatedMove object from a point.
 ModuleType[] getRequiredModuleList()
          Return the modules that this module requires to perform its task.
private  void getShimaris(Board board, Set moves)
          Find any moves which would make shimaris, and rate them.
private  void getSideExtensions(Board board, Geometry geo, Set moves)
          Find good points along the side, and add the rated moves to the set..
private  boolean isEmpty(Board board, int distance, Point pt)
          Determine if the specified corner is empty except for the single point.
 void makeMove(Move move, Module[] modules)
          Update the internal data structures of this module with the new move.
private static void setPoints()
          Read in the shimari combinations from the data file and set the points HashMap.
 
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

dt

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


points

private static HashMap points
The key is a Point object, and the value is an ArrayList containing Point objects.


mt

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


rm

private RatedMove[] rm
The moves that were rated by this module.


isGenerated

private boolean isGenerated
This flag is used to determine when to clear variables set by generateMove().


isFusekiOver

private boolean isFusekiOver
If set, then no more work remains to be done by this module.

Constructor Detail

SimpleFuseki

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

Parameters:
id - The id of the game.
name - The name of this module.
Throws:
InternalErrorException - Thrown if the operation fails for any reason.
Method Detail

setPoints

private static void setPoints()
Read in the shimari combinations from the data file and set the points HashMap.


addPoint

private static void addPoint(Point pt1,
                             Point pt2)
Add a pair of points into the points HashMap.

Parameters:
pt1 - The key
pt2 - The value, which is placed in an ArrayList.

generateMove

public void generateMove(Module[] modules)
Generate the move for this module. The side effect of calling this method is that an array of RatedMove objects is stored which is returned by the getMoves() method.

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.

getShimaris

private void getShimaris(Board board,
                         Set moves)
Find any moves which would make shimaris, and rate them.

Parameters:
board - The Board module.
moves - The new rated moves are added to this Set.

isEmpty

private boolean isEmpty(Board board,
                        int distance,
                        Point pt)
Determine if the specified corner is empty except for the single point.

Parameters:
board - The Board module.
distance - The number of rows and columns to check out from the corner.
pt - The single point that is allowed to contain a stone.
Returns:
true if the corner is empty except for the single stone, or false.

getRatedMove

private RatedMove getRatedMove(Point pt,
                               Board board)
Create a RatedMove object from a point.

Parameters:
pt - The point to be made into a rated move.
board - The Board module.
Returns:
A RatedMove object for the given point.

getSideExtensions

private void getSideExtensions(Board board,
                               Geometry geo,
                               Set moves)
Find good points along the side, and add the rated moves to the set.. A point is considered to be good if it is on the third line just below the star point, and has room for a two space extension in either direction.

Parameters:
board - The Board module.
geo - The Geometry module.
moves - The Set to which the rated moves are to be added.

getCornerMoves

private HashSet getCornerMoves(short moveNumber,
                               Color color,
                               Geometry geo)
Get rated moves for all moves in empty corners.

Parameters:
moveNumber - the number of the next move.
color - The color of the side to move next.
geo - The Geometry module.
Returns:
A HashSet containing RatedMoves objects representing corner moves.

addCornerMoves

private void addCornerMoves(short moveNumber,
                            Color color,
                            Point pt,
                            Set set)
Rate different corner moves in the empty corner. Note that this is a very simple algorithm. The 3 - 3, 3 - 4, 4 - 4, and 4 - 5 points all get the top rating.

Parameters:
moveNumber - The number of the next move.
color - The color of the next move.
pt - The corner point
set - The set to which is to be added the RatedMove objects.

getDebugInformation

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

Specified by:
getDebugInformation in class Module
Parameters:
types - Only return a subset of the debug types in this array.
Returns:
The debug information that this module supports.

getDebugTypes

public DebugType[] getDebugTypes()
Return the types of debug information that this module supports.

Specified by:
getDebugTypes in class Module
Returns:
The types of debug information that this module supports.

getMoves

public RatedMove[] getMoves()
Return the moves generated by the module. Note that both good and bad moves can be returned.

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

getRequiredModuleList

public ModuleType[] getRequiredModuleList()
Return the modules that this module requires to perform its task.

Specified by:
getRequiredModuleList in class Module
Returns:
An array of module types that the module requires.

makeMove

public void makeMove(Move move,
                     Module[] modules)
Update the internal data structures of this module with the new move. This module is stateless, so minimal work is done here.

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.

clone

public Object clone()
Clone the module.

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