org.moyoman.module.loosegroups
Interface LooseGroups

All Superinterfaces:
Cloneable, ModuleInterface, Serializable
All Known Implementing Classes:
LGImpl

public interface LooseGroups
extends ModuleInterface

A class that implements this interface 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
static short ADD
          A new loose group was created as a result of the last move.
static short COMBINE
          The last move caused two or more loose groups to be combined into one.
static short SUICIDE
          The last move was a suicide.
static short UPDATE
          The last move caused an existing loose group to be updated.
 
Method Summary
 Point[] getAssociatedEdgePoints(SingleLooseGroup slg)
          Determine if any empty points on the edge of the board are associated with this loose group.
 SingleLooseGroup[] getCombinedSingleLooseGroups()
          Return the loose groups that were combined into a single loose group.
 SingleLooseGroup getNewSingleLooseGroup()
          Get the new loose group created by the last move made.
 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()
          Return the loose groups that before the last move were part of one loose group.
 SingleLooseGroup[] getSuicidedSingleLooseGroups()
          Get the SingleLooseGroup objects which died as a result of suicide.
 SingleLooseGroup getUpdatedSingleLooseGroup()
          Get the loose group that contains the last move made.
 short status()
          Return the status of the last move made.
 boolean wasLooseGroupSplit()
          Return whether any loose groups were split by the last move.
 boolean wereGroupsCaptured()
          Return whether the last move caused the capture of any loose groups.
 
Methods inherited from interface org.moyoman.module.ModuleInterface
clone, getMoves, getScheduler
 

Field Detail

ADD

public static final short ADD
A new loose group was created as a result of the last move.

See Also:
Constant Field Values

UPDATE

public static final short UPDATE
The last move caused an existing loose group to be updated.

See Also:
Constant Field Values

COMBINE

public static final short COMBINE
The last move caused two or more loose groups to be combined into one.

See Also:
Constant Field Values

SUICIDE

public static final short SUICIDE
The last move was a suicide.

See Also:
Constant Field Values
Method Detail

status

public short status()
Return the status of the last move made. The status is one of four constants indicating that the last move either:
  1. Caused a new loose group to be created.
  2. Updated an existing loose group
  3. Combined two or more existing loose groups.
  4. Was a suicide which caused the removal of the stone played.

The status is not dependent on whether any stones were captured.

Returns:
The status.

wereGroupsCaptured

public boolean wereGroupsCaptured()
Return whether the last move caused the capture of any loose groups. This is true if the entire loose group is captured, but false if only a part of the loose group is captured. The value of this is independent of the value of status().

Returns:
true if any loose groups were captured, or false.

wasLooseGroupSplit

public boolean wasLooseGroupSplit()
Return whether any loose groups were split by the last move. It is possible that a stone that is place as part of a new or existing loose group could cause one of the opponents loose groups to be split into two or more loose groups. The value of this is independent of the value of status() and wereGroupsCaptured().

Returns:
true if a loose group was split into multiple loose groups by the last move.

getSplitLooseGroups

public SingleLooseGroup[] getSplitLooseGroups()
                                       throws NoSuchDataException
Return the loose groups that before the last move were part of one loose group. This method is returning the current LooseGroup objects that prior to the last move were all part of one LooseGroup object.

Returns:
An array of SingleLooseGroup objects.
Throws:
NoSuchDataException - Thrown if wasLooseGroupSplit() is false.

getSingleLooseGroups

public SingleLooseGroup[] getSingleLooseGroups()
This method returns all of the loose groups.

Returns:
An array of SingleLooseGroup objects.

getSingleLooseGroup

public SingleLooseGroup getSingleLooseGroup(SingleGroup sg)
                                     throws Exception
Get the loose group which contains the single group.

Parameters:
sg - The group in question.
Returns:
The SingleLooseGroup object which contains the single group.
Exception

getSingleLooseGroup

public SingleLooseGroup getSingleLooseGroup(Stone stone)
                                     throws Exception
Get the loose group which contains the stone.

Parameters:
stone - The stone in question.
Returns:
The SingleLooseGroup object which contains the stone.
Exception

getSingleLooseGroupsPartiallyCaptured

public SingleLooseGroup[] getSingleLooseGroupsPartiallyCaptured()
Return loose groups that were partially captured on the last move. The groups are as they were before capture, containing some SingleGroup objects that were captured, and some that are still present. Most likely, the size of the array returned will never be larger than 1, but an array is returned instead of a single object because there might be a few exceptional cases.

Returns:
An array of SingleLooseGroup objects.

getSingleLooseGroupsFullyCaptured

public SingleLooseGroup[] getSingleLooseGroupsFullyCaptured()
Return loose groups that were completely captured on the last move. The set of SingleLooseGroup objects returned by this method and getSingleLooseGroupsPartiallyCaptured() are disjoint.

Returns:
An array of SingleLooseGroup objects.

getNewSingleLooseGroup

public SingleLooseGroup getNewSingleLooseGroup()
                                        throws NoSuchDataException
Get the new loose group created by the last move made.

Returns:
a SingleLooseGroup object.
Throws:
NoSuchDataException - Thrown if status() != ADD.

getUpdatedSingleLooseGroup

public SingleLooseGroup getUpdatedSingleLooseGroup()
                                            throws NoSuchDataException
Get the loose group that contains the last move made.

Returns:
a SingleLooseGroup object.
Throws:
NoSuchDataException - Thrown if status() != UPDATE.

getCombinedSingleLooseGroups

public SingleLooseGroup[] getCombinedSingleLooseGroups()
                                                throws NoSuchDataException
Return the loose groups that were combined into a single loose group. This method is returning the loose groups from the previous move that are now all one loose group. So, none of the loose groups returned by this method will contain the stone that is the current move.

This array will not contain any entries unless the last move caused two or more loose groups to be combined into one loose group.

Returns:
An array of SingleLooseGroup objects.
Throws:
NoSuchDataException - Thrown if status() != COMBINE.

getSuicidedSingleLooseGroups

public SingleLooseGroup[] getSuicidedSingleLooseGroups()
                                                throws NoSuchDataException
Get the SingleLooseGroup objects which died as a result of suicide.

Returns:
An array of SingleLooseGroup object which were the groups removed.
Throws:
NoSuchDataException - Thrown if status() != SUICIDE.

getAssociatedEdgePoints

public Point[] getAssociatedEdgePoints(SingleLooseGroup slg)
Determine if any empty points on the edge of the board are associated with this loose group. One can think of loose groups as having implicit stones on the edge of the board. For example, if there is a loose group consisting of a two space extension on the third line from another stone on the third line with no other stones in the vicinity, then one could think of there being two implicit stones on the first line directly below each of the actual stones. One could then draw a rectangle with four empty points inside as a first very crude attempt at identifying territory.

Obviously, it is not straightforward when to include these implicit points and when not to. The rule here is that for each stone in the loose group, consider each empty point on the horizontal and vertical edges of the board closest to that stone which is connected to it by a straight line. If there was a stone of the same color on that empty point, would it be part of the same loose group? If the answer is yes, then it is considered to be an associated edge point. This method returns all of those points. The maximum number of these points is twice the number of stones. For example, a single stone in the corner on the star point would have two associated edge points, and the rectangle formed by these three points and the corner would contain 9 empty points.

Parameters:
slg - The loose group in question.
Returns:
An array of Point objects.