org.moyoman.module.fuseki.igofuseki
Class IgoFuseki

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

public class IgoFuseki
extends Module
implements Fuseki

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

Author:
MingHuang Cheng
See Also:
Serialized Form

Field Summary
private  int absLine
          value of the absolute lines on board.
private  int[] absTate
          info of the absolute vertical line value.
private  int[] absYoko
          info of the absolute horizontal line vlaue.
private  int[] absYokoTate
          info of the absolute line value.
private  int actCnt
          convinent variable.
(package private) static int AKI
          Value of the empty point.
private  int boardSize
          Size of the board, the value maybe is always 19.
private  int[] col
          Color info of the board (AKI/KURO/SIRO/EDGE).
private  boolean comKuro
          True if com play at first.
private  int d1
          variables to access neighbors.
private  int d11
          variables to access neighbors.
private  int d111
          variables to access neighbors.
private  int d117
          variables to access neighbors.
private  int d118
          variables to access neighbors.
private  int d17
          variables to access neighbors.
private  int d18
          variables to access neighbors.
private  int d2
          variables to access neighbors.
private  int d22
          variables to access neighbors.
private  int d222
          variables to access neighbors.
private  int d225
          variables to access neighbors.
private  int d226
          variables to access neighbors.
private  int d25
          variables to access neighbors.
private  int d26
          variables to access neighbors.
private  int d3
          variables to access neighbors.
private  int d33
          variables to access neighbors.
private  int d333
          variables to access neighbors.
private  int d336
          variables to access neighbors.
private  int d338
          variables to access neighbors.
private  int d36
          variables to access neighbors.
private  int d38
          variables to access neighbors.
private  int d4
          variables to access neighbors.
private  int d44
          variables to access neighbors.
private  int d444
          variables to access neighbors.
private  int d445
          variables to access neighbors.
private  int d447
          variables to access neighbors.
private  int d45
          variables to access neighbors.
private  int d47
          variables to access neighbors.
private  int d5
          variables to access neighbors.
private  int d55
          variables to access neighbors.
private  int d555
          variables to access neighbors.
private  int d6
          variables to access neighbors.
private  int d66
          variables to access neighbors.
private  int d666
          variables to access neighbors.
private  int d7
          variables to access neighbors.
private  int d77
          variables to access neighbors.
private  int d777
          variables to access neighbors.
private  int d8
          variables to access neighbors.
private  int d88
          variables to access neighbors.
private  int d888
          variables to access neighbors.
private  int dFb
           
private  int dHai
           
private static DebugType[] dt
          The debug types that this module supports.
private  boolean[] ed
          Array for proc.
(package private) static int EDGE
          Value of the boundary line.
(package private) static int EDGE_M
          Value of the boundary line for group.
private  int[][] gen
          Index to access left-top corner.
private  int h1
           
private  int h2
           
private  int h3
           
private  int h4
           
private  int haiti
          Count of stones put in advance.
private  int[][] his
          Index to access left-bottom corner.
(package private) static int IRO_KEI
          Value of color exchange.
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  int[][][] jSeki
          Array of JoSeki pattern data.
private  int kCnt
           
private  int[] kd
          info of the Stone's liberties.
(package private) static int KURO
          Value of the black stone.
private  boolean kuroSaki
          True if the first move is black.
private  int[] md
          info of the group.
private  int[][] mis
          Index to access right-bottom coner.
private  int[][] miu
          Index to access right-top corner.
private  int[] moves
          Position of moves in the game.
private  ModuleType[] mt
          The modules that this module requires.
private  int patCnt
           
private  int pin
           
private  int posLimit
          index of the active limit.
private  int posStart
          index of the first active point.
private  RatedMove[] rm
          The moves that were rated by this module.
(package private) static int SIRO
          Value of the white stone.
private  int sizeBlk
          convinent variable.
private  int sizeHan
          convinent variable.
private  int sizeP1
          convinent variable.
private  int tanMe
           
private  int tanOp
           
private  int[] tate
          info of the vertical line value.
private  int[] td
          info of the block.
private  int tekazu
          Count of moves in the game.
private  int tenCnt
          Total count of the points.
private  int[] yoko
          info of the horizontal line value.
private  int[][][] ySumi
          Array of AllBoard pattern data.
 
Fields inherited from class org.moyoman.module.Module
 
Fields inherited from interface org.moyoman.module.fuseki.Fuseki
CONFIDENCE
 
Constructor Summary
IgoFuseki(GameId id, ModuleName name)
          Create the IgoFuseki object.
 
Method Summary
private  void addCornerMoves(int pos, VecInt vec)
          add moves in the empty corner.
private  boolean addRated(short moveNumber, Color color, VecInt vec)
          Return true if has moves to add to rm.
private  int arrIndex(String id)
          Return the index of an array.
private  int ccTable(char c1, char c2)
          return positon from a move data.
private  int ccTable(String str)
          return the positon of a move data.
private  void clearColor()
          Clear color data.
 Object clone()
          Clone the module.
private  void datMatch1(int[] arr, VecInt vec)
          Serach for pattern moves of 4 corner.
private  void dMatch2(int[] arr, VecInt vec)
          Search for pattern moves of corner.
private  boolean empty(int pos)
          Return true if the position is empty.
private  boolean empty4(int pos)
          Return true if the 4 neighbors are empty.
private  boolean empty8(int pos)
          Return true if the 8 neighbors is empty.
 void generateMove(Module[] modules)
          Generate the move for this module.
private  boolean getCornerMoves(short moveNumber, Color color)
          Get rated 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.
 ModuleType[] getRequiredModuleList()
          Return the modules that this module requires to perform its task.
private  void igoInit()
          Initialize variables.
private  int igoPos(int moX, int moY)
          Return the position of Igo from Moyoman's (X,Y) coordinate.
private  boolean jMatch(short moveNumber, Color color)
          Get rated moves from JoSeki patterns.
private  void jMatch1(int[][] a, VecInt vec)
          Serach for moves of JoSeki pattern.
private  void loadPattern()
          Load patterns
private  boolean lookAki(short moveNumber, Color color)
          Get rated moves from empty area.
private  void lookAki2(VecInt vec)
           
 void makeMove(Move move, Module[] modules)
          Update the internal data structures of this module with the new move.
private  int moyaX(int pos)
          Return the horizontal value from a position of Igo.
private  int moyaY(int pos)
          Return the vertical value from a position of Igo.
private  void setBoardSize(int size)
          set the size of board and related variables.
private  void setGameData(Board board)
          Set the game's data.
private  void setHan(int s1, int s2, PatVec pt)
          set boundary of the pattern.
private  void setJseki(String id, String str)
          set the data of JoSeki.
private  void setPatt(String id, String str)
          set the data of 4-corner patterns.
private  void setPattern(String str)
          Set the patterns.
private  void setSub(int m, boolean flag, PatVec pt)
          set sub array of the pattern.
private  boolean sumiMatch(short moveNumber, Color color, int index)
          Get rated moves from 4-corner patterns.
 
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.


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.


AKI

static final int AKI
Value of the empty point.

See Also:
Constant Field Values

KURO

static final int KURO
Value of the black stone.

See Also:
Constant Field Values

SIRO

static final int SIRO
Value of the white stone.

See Also:
Constant Field Values

EDGE

static final int EDGE
Value of the boundary line.

See Also:
Constant Field Values

EDGE_M

static final int EDGE_M
Value of the boundary line for group.

See Also:
Constant Field Values

IRO_KEI

static final int IRO_KEI
Value of color exchange. (color^IRO_KEI ==> KURO : SIRO)

See Also:
Constant Field Values

boardSize

private int boardSize
Size of the board, the value maybe is always 19.


col

private int[] col
Color info of the board (AKI/KURO/SIRO/EDGE).


ed

private boolean[] ed
Array for proc.


moves

private int[] moves
Position of moves in the game. first move -> moves[1]


tekazu

private int tekazu
Count of moves in the game.


haiti

private int haiti
Count of stones put in advance.


kuroSaki

private boolean kuroSaki
True if the first move is black.


comKuro

private boolean comKuro
True if com play at first.


absLine

private int absLine
value of the absolute lines on board.


tenCnt

private int tenCnt
Total count of the points.


posStart

private int posStart
index of the first active point.


posLimit

private int posLimit
index of the active limit.


d1

private int d1
variables to access neighbors.


d2

private int d2
variables to access neighbors.


d3

private int d3
variables to access neighbors.


d4

private int d4
variables to access neighbors.


d5

private int d5
variables to access neighbors.


d6

private int d6
variables to access neighbors.


d7

private int d7
variables to access neighbors.


d8

private int d8
variables to access neighbors.


d11

private int d11
variables to access neighbors.


d22

private int d22
variables to access neighbors.


d33

private int d33
variables to access neighbors.


d44

private int d44
variables to access neighbors.


d17

private int d17
variables to access neighbors.


d18

private int d18
variables to access neighbors.


d25

private int d25
variables to access neighbors.


d26

private int d26
variables to access neighbors.


d36

private int d36
variables to access neighbors.


d38

private int d38
variables to access neighbors.


d45

private int d45
variables to access neighbors.


d47

private int d47
variables to access neighbors.


d55

private int d55
variables to access neighbors.


d66

private int d66
variables to access neighbors.


d77

private int d77
variables to access neighbors.


d88

private int d88
variables to access neighbors.


d111

private int d111
variables to access neighbors.


d222

private int d222
variables to access neighbors.


d333

private int d333
variables to access neighbors.


d444

private int d444
variables to access neighbors.


d117

private int d117
variables to access neighbors.


d118

private int d118
variables to access neighbors.


d225

private int d225
variables to access neighbors.


d226

private int d226
variables to access neighbors.


d336

private int d336
variables to access neighbors.


d338

private int d338
variables to access neighbors.


d445

private int d445
variables to access neighbors.


d447

private int d447
variables to access neighbors.


d555

private int d555
variables to access neighbors.


d666

private int d666
variables to access neighbors.


d777

private int d777
variables to access neighbors.


d888

private int d888
variables to access neighbors.


kd

private int[] kd
info of the Stone's liberties.


td

private int[] td
info of the block.


md

private int[] md
info of the group.


yoko

private int[] yoko
info of the horizontal line value.


tate

private int[] tate
info of the vertical line value.


absYoko

private int[] absYoko
info of the absolute horizontal line vlaue.


absTate

private int[] absTate
info of the absolute vertical line value.


absYokoTate

private int[] absYokoTate
info of the absolute line value.


sizeP1

private int sizeP1
convinent variable.


sizeHan

private int sizeHan
convinent variable.


sizeBlk

private int sizeBlk
convinent variable.


actCnt

private int actCnt
convinent variable.


gen

private int[][] gen
Index to access left-top corner.


his

private int[][] his
Index to access left-bottom corner.


miu

private int[][] miu
Index to access right-top corner.


mis

private int[][] mis
Index to access right-bottom coner.


jSeki

private int[][][] jSeki
Array of JoSeki pattern data.


ySumi

private int[][][] ySumi
Array of AllBoard pattern data.


h1

private int h1

h2

private int h2

h3

private int h3

h4

private int h4

tanOp

private int tanOp

tanMe

private int tanMe

dFb

private int dFb

dHai

private int dHai

pin

private int pin

patCnt

private int patCnt

kCnt

private int kCnt
Constructor Detail

IgoFuseki

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

getCornerMoves

private boolean getCornerMoves(short moveNumber,
                               Color color)
Get rated moves in empty corners.

Parameters:
moveNumber - the number of the next move.
color - The color of the side to move next.
Returns:
true if find corner moves.

addCornerMoves

private void addCornerMoves(int pos,
                            VecInt vec)
add moves in the empty corner.

Parameters:
pos - Position of the corner star.
vec - Vector to store the 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. 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:
A IgoFuseki object which is a clone of this one.

setGameData

private void setGameData(Board board)
Set the game's data.

Parameters:
board - The Board module.

clearColor

private void clearColor()
Clear color data.


setBoardSize

private void setBoardSize(int size)
set the size of board and related variables.

Parameters:
size - Size of the Board.

igoInit

private void igoInit()
Initialize variables.


empty

private boolean empty(int pos)
Return true if the position is empty.

Parameters:
pos - Index of the position.

empty4

private boolean empty4(int pos)
Return true if the 4 neighbors are empty.

Parameters:
pos - Index of the position.

empty8

private boolean empty8(int pos)
Return true if the 8 neighbors is empty.

Parameters:
pos - Index of the Position.

moyaX

private int moyaX(int pos)
Return the horizontal value from a position of Igo.

Parameters:
pos - Index of the Position.

moyaY

private int moyaY(int pos)
Return the vertical value from a position of Igo.

Parameters:
pos - Position of Igo.

igoPos

private int igoPos(int moX,
                   int moY)
Return the position of Igo from Moyoman's (X,Y) coordinate.

Parameters:
moX - horizontal value of the Moyoman.
moY - vertical value of the Moyoman.

loadPattern

private void loadPattern()
Load patterns


setPattern

private void setPattern(String str)
Set the patterns.

Parameters:
str - Pattern data.

setJseki

private void setJseki(String id,
                      String str)
set the data of JoSeki.

Parameters:
id - ID of the patterns.
str - Data of the patterns.

setPatt

private void setPatt(String id,
                     String str)
set the data of 4-corner patterns.

Parameters:
id - ID of the patterns.
str - Data of the patterns.

arrIndex

private int arrIndex(String id)
Return the index of an array.

Parameters:
id - ID of the pattern.

setHan

private void setHan(int s1,
                    int s2,
                    PatVec pt)
set boundary of the pattern.

Parameters:
s1 - one of the limit position.
s2 - one of the limit position.
pt - pattern obj.

setSub

private void setSub(int m,
                    boolean flag,
                    PatVec pt)
set sub array of the pattern.

Parameters:
m - Target position.
flag - Flag for pattenr type.
pt - Pattern obj.

ccTable

private int ccTable(char c1,
                    char c2)
return positon from a move data.

Parameters:
c1 - Char data of horizontal.
c2 - Char data of vertical.

ccTable

private int ccTable(String str)
return the positon of a move data.

Parameters:
str - data of the position

addRated

private boolean addRated(short moveNumber,
                         Color color,
                         VecInt vec)
Return true if has moves to add to rm.

Parameters:
moveNumber - the number of the next move.
color - The color of the side to move next.
vec - Vector to store moves.

jMatch

private boolean jMatch(short moveNumber,
                       Color color)
Get rated moves from JoSeki patterns.

Parameters:
moveNumber - the number of the next move.
color - The color of the side to move next.
Returns:
true if find Joseki patterns.

jMatch1

private void jMatch1(int[][] a,
                     VecInt vec)
Serach for moves of JoSeki pattern.

Parameters:
a - Array of pattern data
vec - Vector to store the matched moves.

datMatch1

private void datMatch1(int[] arr,
                       VecInt vec)
Serach for pattern moves of 4 corner.

Parameters:
arr - Array of pattern data
vec - Vector to store the matched moves.

sumiMatch

private boolean sumiMatch(short moveNumber,
                          Color color,
                          int index)
Get rated moves from 4-corner patterns.

Parameters:
moveNumber - the number of the next move.
color - The color of the side to move next.
index - Index of the pattern.
Returns:
true if find 4-corner patterns.

dMatch2

private void dMatch2(int[] arr,
                     VecInt vec)
Search for pattern moves of corner.

Parameters:
arr - Array of pattern data
vec - Vector to store the matched moves.

lookAki

private boolean lookAki(short moveNumber,
                        Color color)
Get rated moves from empty area.

Parameters:
moveNumber - the number of the next move.
color - The color of the side to move next.
Returns:
true if find moves from empty area.

lookAki2

private void lookAki2(VecInt vec)