org.moyoman.module.tactics.simpletactics
Class SimpleTactics

java.lang.Object
  |
  +--org.moyoman.module.Module
        |
        +--org.moyoman.module.tactics.simpletactics.SimpleTactics
All Implemented Interfaces:
Cloneable, Component, ModuleInterface, Serializable, Tactics

public class SimpleTactics
extends Module
implements Tactics

This module implements the Endgame interface. It is responsible for finding sequences of moves at the end of the game.

See Also:
Serialized Form

Field Summary
private  Color currentColor
           
private static DebugType[] dt
          The debug types that this module supports.
private  boolean isGenerated
          This flag is used to determine when to clear variables set by generateMove().
private  Board lastBoard
          The last board obtained from generateMove().
private  Groups lastGroups
          The last groups obtained from generateMove().
private  MoveDescriptorForest mdf
          The MoveDescriptorForest object containing sequences of moves.
private  ModuleType[] mt
          The modules that this module requires.
private  RatedMove[] rm
          The moves that were rated by this module.
private  boolean sequenceFlag
          This flag is used to determine if a call to getSequences() is valid.
 
Fields inherited from class org.moyoman.module.Module
 
Fields inherited from interface org.moyoman.module.tactics.Tactics
CONFIDENCE
 
Constructor Summary
SimpleTactics(GameId id, ModuleName name)
          Create the SimpleTactics object.
 
Method Summary
 Object clone()
          Clone the module.
private  void generateMDF()
          Generate the MoveDescriptorForest object describing sequences of moves.
 void generateMove(Module[] modules)
          Generate the move for this module.
private  void generateRatedMoves(Board board, Groups groups)
          Generate moves based on liberties.
 MoveDescriptorForest getCurrentPlayerKoThreats()
          Get sequences of moves where the current player makes the first two moves.
 MoveDescriptorForest getCurrentPlayerSequences()
          Get sequences of tactical moves for the current player.
 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.
 MoveDescriptorForest getOpponentPlayerKoThreats()
          Get sequences of moves where the opponent player makes the first two moves.
 MoveDescriptorForest getOpponentPlayerSequences()
          Get sequences of tactical moves if the opponent plays first.
 ModuleType[] getRequiredModuleList()
          Return the modules that this module requires to perform its task.
 boolean isMoveUrgent(SingleGroup sg)
          Determine if the group is stable, or if another move is required.
 boolean isMoveUrgent(SingleLooseGroup slg)
          Determine if the loose group is stable, or if another move is required.
 void makeMove(Move move, Module[] modules)
          Update the internal data structures of this module with the new move.
 void setImportantStones(Stone[] stones)
          Currently, SimpleTactics does nothing with this information.
 
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.


mt

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


rm

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


lastBoard

private Board lastBoard
The last board obtained from generateMove().


lastGroups

private Groups lastGroups
The last groups obtained from generateMove().


mdf

private MoveDescriptorForest mdf
The MoveDescriptorForest object containing sequences of moves.


isGenerated

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


sequenceFlag

private boolean sequenceFlag
This flag is used to determine if a call to getSequences() is valid.


currentColor

private Color currentColor
Constructor Detail

SimpleTactics

public SimpleTactics(GameId id,
                     ModuleName name)
              throws InternalErrorException
Create the SimpleTactics 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

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.

generateRatedMoves

private void generateRatedMoves(Board board,
                                Groups groups)
Generate moves based on liberties. The rating is dependent on whether the move does each of the following:
  1. Captures an opponents stone.
  2. Saves a friendly stone from capture.
  3. Increases the liberties for a friendly group with less than 5 liberties.

Parameters:
board - The Board module.
groups - The Groups module.

generateMDF

private void generateMDF()
Generate the MoveDescriptorForest object describing sequences of moves.


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. Note that this method is called both when the client makes a move, and when the server makes a 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.

getCurrentPlayerSequences

public MoveDescriptorForest getCurrentPlayerSequences()
                                               throws NoSuchDataException
Get sequences of tactical moves for the current player. The sequences are not considered to be equally good. Use the getMoves() method to determine which move this module considers to be best.

Specified by:
getCurrentPlayerSequences in interface Tactics
Returns:
A MoveDescriptorForest object which contains sequences of moves for tactical play.
Throws:
NoSuchDataException - Thrown if the information is not available.

getCurrentPlayerKoThreats

public MoveDescriptorForest getCurrentPlayerKoThreats()
                                               throws NoSuchDataException
Description copied from interface: Tactics
Get sequences of moves where the current player makes the first two moves.

Specified by:
getCurrentPlayerKoThreats in interface Tactics
Returns:
A MoveDescriptorForest, which describes various sequences of moves where the current player gets the first two moves. The first move is probably not rated very highly, but would be a good ko threat.
NoSuchDataException

getOpponentPlayerKoThreats

public MoveDescriptorForest getOpponentPlayerKoThreats()
                                                throws NoSuchDataException
Description copied from interface: Tactics
Get sequences of moves where the opponent player makes the first two moves.

Specified by:
getOpponentPlayerKoThreats in interface Tactics
Returns:
A MoveDescriptorForest, which describes various sequences of moves where the opponent player gets the first two moves. The first move is probably not rated very highly, but would be a good ko threat.
NoSuchDataException

getOpponentPlayerSequences

public MoveDescriptorForest getOpponentPlayerSequences()
                                                throws NoSuchDataException
Get sequences of tactical moves if the opponent plays first. The sequences are not considered to be equally good. Use the getMoves() method to determine which move this module considers to be best.

Specified by:
getOpponentPlayerSequences in interface Tactics
Returns:
A MoveDescriptorForest object which contains sequences of moves for tactical play.
Throws:
NoSuchDataException - Thrown if the information is not available.

setImportantStones

public void setImportantStones(Stone[] stones)
Currently, SimpleTactics does nothing with this information.

Specified by:
setImportantStones in interface Tactics
Parameters:
stones - The stones which are important.

isMoveUrgent

public boolean isMoveUrgent(SingleGroup sg)
Description copied from interface: Tactics
Determine if the group is stable, or if another move is required.

Specified by:
isMoveUrgent in interface Tactics
Parameters:
sg - The group in question.
Returns:
true if another move is required, or false.

isMoveUrgent

public boolean isMoveUrgent(SingleLooseGroup slg)
Description copied from interface: Tactics
Determine if the loose group is stable, or if another move is required.

Specified by:
isMoveUrgent in interface Tactics
Parameters:
slg - The loose group in question.
Returns:
true if another move is required, or false.

clone

public Object clone()
Clone the module.

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