|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.module.Module | +--org.moyoman.module.loosegroups.simplelgimpl.LGImpl
This class is responsible for assigning stones to a loose group. Each stone on the board is a member of exactly one loose group. The total number of loose groups is less than or equal to the number of groups. Any two stones that are in the same group are also in the same loose group.
Field Summary | |
private Board |
board
The Board object with the current state of the board. |
private ArrayList |
combinedGroups
Contains SingleLooseGroup objects which were combined on the current move into one. |
private ClosestPoints |
cp
The ClosestPoints class is used to help determine which groups are in the same loose group. |
private static DebugType[] |
dt
The debug types that this module produces. |
private static HashMap |
edgePoints
The key is a Long returned by Zobrist, and the value is a Point array. |
private ArrayList |
fullyCapturedGroups
Contains SingleLooseGroups which were entirely captured by the last move. |
private boolean |
groupsCaptured
This is true if at least one loose group was entirely captured on the last move. |
private boolean |
groupsSplit
If any loose groups were split into two or more loose groups on the last move, this is true. |
private Color |
moveColor
The color of the player to move. |
private short |
moveNumber
The number of the next move. |
private short |
moveStatus
One of the LooseGroups constants ADD, UPDATE, or COMBINE. |
private ModuleType[] |
mt
The module types that this module is dependent on. |
private SingleLGImpl |
newGroup
If status() returns ADD, then this is the new group. |
private ArrayList |
partiallyCapturedGroups
Contains SingleLooseGroups which had some stones captured from them by the last move. |
private ArrayList |
ratedMoves
The RatedMove objects created by generateMove(). |
private ArrayList |
slggroups
Each element is a SingleLooseGroup object. |
private ArrayList |
splitGroups
If groupsSplit is true, then this contains SingleLooseGroup objects after splitting. |
private SingleLGImpl |
updatedGroup
If status() returns UPDATE then this is the updated group. |
Fields inherited from class org.moyoman.module.Module |
|
Fields inherited from interface org.moyoman.module.loosegroups.LooseGroups |
ADD, COMBINE, SUICIDE, UPDATE |
Constructor Summary | |
LGImpl(GameId id,
ModuleName name)
Create the LGImpl object. |
Method Summary | |
private boolean |
checkEmptyPoints(ClosestPoints cpts,
ArrayList al,
Color col,
ClosestPointGroup cpg1,
ClosestPointGroup cpg2)
Determine if there are any opponents stones preventing the two groups from combining. |
private void |
checkOpponentsLooseGroups(Stone stone,
ClosestPointGroup cpg,
Groups groups,
Board board)
Split opponents groups adjacent to the current loose group if necessary. |
private boolean |
checkPonnuki(Point center,
Color color,
Board board)
Determine if at least three sides of a ponnuki of the given color exist around the center point. |
Object |
clone()
Override the Object.clone() method. |
private void |
combineAdjacentGroupsIfPossible(ClosestPointGroup[] adjgroups,
Board board,
Groups groups)
Combine as many of the candidate groups as possible. |
private void |
combineAdjacentGroupsIfPossible(ClosestPointGroup currcpg,
Board board,
Groups groups)
Attempt to combine any friendly groups adjacent to the group containing the last stone. |
private void |
combineGroups(SingleLGImpl[] grp)
Combine the single loose groups into one loose group. |
private void |
combineGroups(SingleLGImpl g1,
SingleLGImpl g2)
Combine the two SingleLooseGroups into one. |
private ClosestPointGroup[] |
combinePairs(ClosestPoints cpts,
ArrayList al,
Board board,
Groups groups)
Combine the ClosestPointGroups as much as possible based on criteria for loose groups. |
void |
generateMove(Module[] modules)
Generate moves for the loose group module. |
Point[] |
getAssociatedEdgePoints(SingleLooseGroup slg)
Get the edge points for the given loose group. |
SingleLooseGroup[] |
getCombinedSingleLooseGroups()
Return the loose groups that were combined into a single loose group. |
Debug[] |
getDebugInformation(DebugType[] types)
Get the debug information for this module. |
DebugType[] |
getDebugTypes()
Get the debug types that this module produces. |
RatedMove[] |
getMoves()
Get the rated moves that this module creates. |
SingleLooseGroup |
getNewSingleLooseGroup()
Get the new loose group that contains the last move made. |
ModuleType[] |
getRequiredModuleList()
Get the module types that this module requires. |
SingleLooseGroup |
getSingleLooseGroup(SingleGroup sg)
Get the loose group which contains the single group. |
SingleLooseGroup |
getSingleLooseGroup(Stone stone)
Get the loose group which contains the stone. |
SingleLooseGroup[] |
getSingleLooseGroups()
This method returns all of the loose groups. |
SingleLooseGroup[] |
getSingleLooseGroupsFullyCaptured()
Return loose groups that were completely captured on the last move. |
SingleLooseGroup[] |
getSingleLooseGroupsPartiallyCaptured()
Return loose groups that were partially captured on the last move. |
SingleLooseGroup[] |
getSplitLooseGroups()
Get the loose groups that were split by the last move. |
private StoneDistance[] |
getStoneDistances(Stone[] s1,
Stone[] s2)
Get the distances between any two pair of stones. |
SingleLooseGroup[] |
getSuicidedSingleLooseGroups()
Return the loose groups that were removed because of suicide. |
SingleLooseGroup |
getUpdatedSingleLooseGroup()
Get the loose group that contains the last move made. |
private boolean |
isSameLooseGroup(ClosestPointGroup cpg1,
ClosestPointGroup cpg2,
Board board)
Determine if the two groups should be part of the same loose group. |
private boolean |
isSameLooseGroup(ClosestPoints cpts,
ClosestPointGroup cpg1,
ClosestPointGroup cpg2,
Board board)
Determine if the two groups should be part of the same loose group. |
void |
makeMove(Move move,
Module[] modules)
Update the internal data structures with the last move. |
private boolean |
process3JumpCase(Stone tent1,
Stone tent2,
int index,
StoneDistance[] sdarr,
ArrayList lgstones)
Determine if the two groups form a three space extension from a two stone wall. |
private void |
removeGroup(SingleLGImpl slg)
Remove the group from the list of loose groups. |
private SingleLGImpl[] |
splitGroupIfNecessary(Stone stone,
SingleLGImpl candidate,
Groups groups,
Board board)
Determine if the given loose group should be split up based on the last move. |
short |
status()
Return the status of the last move made. |
String |
toString()
Get a String representation of the object. |
private void |
updatePartialAndFullCaptureSLG(SingleGroup[] sg)
Update the list of groups that were fully or partially captured. |
boolean |
wasLooseGroupSplit()
Determine if a loose group was split on the last move. |
boolean |
wereGroupsCaptured()
Determine if a loose group was completely captured on the last 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, wait, wait, wait |
Methods inherited from interface org.moyoman.module.ModuleInterface |
getScheduler |
Field Detail |
private static DebugType[] dt
private ModuleType[] mt
private short moveNumber
private Color moveColor
private ArrayList slggroups
private ClosestPoints cp
private Board board
private ArrayList ratedMoves
private short moveStatus
private boolean groupsSplit
private boolean groupsCaptured
private SingleLGImpl newGroup
private SingleLGImpl updatedGroup
private ArrayList splitGroups
private ArrayList combinedGroups
private ArrayList partiallyCapturedGroups
private ArrayList fullyCapturedGroups
private static HashMap edgePoints
Constructor Detail |
public LGImpl(GameId id, ModuleName name) throws InternalErrorException
id
- The game id.name
- The ModuleName of this module.
InternalErrorException
- Thrown if the create fails for any reason.Method Detail |
public short status()
The status is independent of whether any stones were captured on the last move.
status
in interface LooseGroups
public boolean wasLooseGroupSplit()
wasLooseGroupSplit
in interface LooseGroups
public boolean wereGroupsCaptured()
wereGroupsCaptured
in interface LooseGroups
public SingleLooseGroup[] getSplitLooseGroups()
getSplitLooseGroups
in interface LooseGroups
public SingleLooseGroup[] getSingleLooseGroups()
getSingleLooseGroups
in interface LooseGroups
public SingleLooseGroup getSingleLooseGroup(SingleGroup sg) throws NoSuchDataException
getSingleLooseGroup
in interface LooseGroups
sg
- The group in question.
NoSuchDataException
- Thrown if the loose group cannot be found.public SingleLooseGroup getSingleLooseGroup(Stone stone) throws NoSuchDataException
getSingleLooseGroup
in interface LooseGroups
stone
- The stone in question.
NoSuchDataException
- Thrown if the loose group cannot be found.public SingleLooseGroup[] getSingleLooseGroupsPartiallyCaptured()
getSingleLooseGroupsPartiallyCaptured
in interface LooseGroups
public SingleLooseGroup[] getSingleLooseGroupsFullyCaptured()
getSingleLooseGroupsFullyCaptured
in interface LooseGroups
public SingleLooseGroup getNewSingleLooseGroup() throws NoSuchDataException
getNewSingleLooseGroup
in interface LooseGroups
NoSuchDataException
- Thrown if the last move did not
case a new loose group to be created.public SingleLooseGroup getUpdatedSingleLooseGroup() throws NoSuchDataException
getUpdatedSingleLooseGroup
in interface LooseGroups
NoSuchDataException
- Thrown if the last move did not
add a stone to an existing loose group.public SingleLooseGroup[] getCombinedSingleLooseGroups() throws NoSuchDataException
getCombinedSingleLooseGroups
in interface LooseGroups
NoSuchDataException
- Thrown if the last move did not
cause two or more existing loose groups to be combined.public SingleLooseGroup[] getSuicidedSingleLooseGroups() throws NoSuchDataException
getSuicidedSingleLooseGroups
in interface LooseGroups
NoSuchDataException
- Thrown if the last move did not
result in suicide.private void removeGroup(SingleLGImpl slg)
slg
- The loose group to be removed.public void generateMove(Module[] modules)
generateMove
in class Module
modules
- - The modules which this module needs in order
to make its move.public Debug[] getDebugInformation(DebugType[] types)
getDebugInformation
in class Module
types
- The debug types that the caller can handle.
public DebugType[] getDebugTypes()
getDebugTypes
in class Module
public RatedMove[] getMoves()
getMoves
in interface ModuleInterface
getMoves
in class Module
public ModuleType[] getRequiredModuleList()
getRequiredModuleList
in class Module
public void makeMove(Move move, Module[] modules) throws InternalErrorException
makeMove
in class Module
move
- The move that was made.modules
- Modules that this module uses.
InternalErrorException
- Thrown if the operation fails for any reason.private void updatePartialAndFullCaptureSLG(SingleGroup[] sg) throws InternalErrorException
sg
- An array of SingleGroup objects that were captured on the last move.
InternalErrorException
- Thrown if the operation fails for any reason.private void combineAdjacentGroupsIfPossible(ClosestPointGroup currcpg, Board board, Groups groups) throws InternalErrorException
currcpg
- The ClosestPointGroup which contains the last move.board
- The Board module.groups
- The Groups module.
InternalErrorException
- Thrown is an error occurred for any reason.private void combineAdjacentGroupsIfPossible(ClosestPointGroup[] adjgroups, Board board, Groups groups) throws InternalErrorException
adjgroups
- An array of ClosestPointGroup objects corresponding to the SingleLooseGroups.board
- The Board module.
InternalErrorException
- Thrown if the operation fails for any reason.private void combineGroups(SingleLGImpl[] grp)
grp
- An array of SingleLGImpl groups to be combined into one.private void combineGroups(SingleLGImpl g1, SingleLGImpl g2)
g1
- - The SingleLooseGroup to hold the results of the combination.g2
- - The SingleLooseGroup to be removed.private boolean isSameLooseGroup(ClosestPointGroup cpg1, ClosestPointGroup cpg2, Board board)
cpg1
- - One of the ClosestPointGroup objects.cpg2
- - The other ClosestPointGroup object.board
- - The Board module.
private boolean isSameLooseGroup(ClosestPoints cpts, ClosestPointGroup cpg1, ClosestPointGroup cpg2, Board board)
This method takes a ClosestPoints object as a parameter so that it can work on different board configurations than the one with the current move.
cpts
- - The ClosestPoints object.cpg1
- - One of the ClosestPointGroup objects.cpg2
- - The other ClosestPointGroup object.board
- - The Board module.
private boolean process3JumpCase(Stone tent1, Stone tent2, int index, StoneDistance[] sdarr, ArrayList lgstones)
tent1
- The tentative stone from the first group.index
- The index to start searching the sorted sdarr array at.sdarr
- The sorted array of StoneDistance objects.lgstones
- The ArrayList to add the three stones to if they are present.
private boolean checkPonnuki(Point center, Color color, Board board)
center
- The point around which the ponnuki would exist.color
- The color of the side for which the ponnuki is being checked.board
- The Board module.
private boolean checkEmptyPoints(ClosestPoints cpts, ArrayList al, Color col, ClosestPointGroup cpg1, ClosestPointGroup cpg2)
cpts
- - The ClosestPoints variable which contains all of the groups.al
- - The stones between which the empty points are being checked.col
- - The color of the groups being checked.cpg1
- - The first group being checked.cpg2
- - The other group being checked.
private StoneDistance[] getStoneDistances(Stone[] s1, Stone[] s2)
s1
- - An array of stones.s2
- - A second array of stones.
private void checkOpponentsLooseGroups(Stone stone, ClosestPointGroup cpg, Groups groups, Board board) throws InternalErrorException
stone
- - The last move made.cpg
- - The ClosestPointGroup object which contains the stone.
InternalErrorException
private SingleLGImpl[] splitGroupIfNecessary(Stone stone, SingleLGImpl candidate, Groups groups, Board board) throws InternalErrorException
stone
- The last move played.candidate
- The loose group in question.groups
- The Groups module.board
- The Board module.
InternalErrorException
- Thrown if the operation fails for any reason.private ClosestPointGroup[] combinePairs(ClosestPoints cpts, ArrayList al, Board board, Groups groups) throws InternalErrorException
cpts
- The appropriate ClosestPoints object.al
- Each element is a ClosestPointGroup objects.board
- The Board module.groups
- The Groups module.
InternalErrorException
- Thrown if the operation fails for any reason.public Point[] getAssociatedEdgePoints(SingleLooseGroup slg)
getAssociatedEdgePoints
in interface LooseGroups
slg
- The loose group in question.
public String toString()
toString
in class Object
public Object clone()
clone
in interface ModuleInterface
clone
in class Module
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |