org.moyoman.module.groups
Interface Groups

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

public interface Groups
extends ModuleInterface

A class that implements the Groups interface is responsible for maintaining a list of the groups on the board, where a group is defined as the maximal collection of stones of the same color that are connected horizontally or vertically, and so would be captured as one unit.

This interface represents the collection of groups. The SingleGroup interface represents a single group.

See Also:
SingleGroup

Field Summary
static short ADD
           
static short COMBINE
           
static short SUICIDE
           
static short UPDATE
           
 
Method Summary
 SingleGroup[] getCapturedSingleGroups()
          Return SingleGroup objects that have been removed because of prisoner captures.
 SingleGroup[] getCombinedSingleGroups()
          Get the SingleGroup objects that were combined.
 SingleGroup getNewSingleGroup()
          Get the new SingleGroup object which contains the last move.
 SingleGroup getSingleGroup(Stone stone)
          Get the SingleGroup object to which this stone belongs.
 SingleGroup[] getSingleGroups()
          Get all of the groups on the board.
 SingleGroup[] getSuicidedSingleGroups()
          Return all SingleGroup objects that died as a result of suicide.
 short getTotalSingleGroups()
          Get the total number of groups on the board.
 SingleGroup getUpdatedSingleGroup()
          Get the updated SingleGroup object which contains the last move.
 short status()
          Return the status of the last move made.
 boolean wereGroupsCaptured()
          Return whether any groups were captured by the last move.
 
Methods inherited from interface org.moyoman.module.ModuleInterface
clone, getMoves, getScheduler
 

Field Detail

ADD

public static final short ADD
See Also:
Constant Field Values

UPDATE

public static final short UPDATE
See Also:
Constant Field Values

COMBINE

public static final short COMBINE
See Also:
Constant Field Values

SUICIDE

public static final short 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 group to be created.
  2. Updated an existing group.
  3. Combined two or more existing groups.
  4. Was a suicide.

The status value is independent of whether any stones were captured by the last move.

Returns:
The status.

wereGroupsCaptured

public boolean wereGroupsCaptured()
Return whether any groups were captured by the last move.


getSingleGroups

public SingleGroup[] getSingleGroups()
Get all of the groups on the board.

Returns:
An array of SingleGroup objects, each of which represents one group.

getSingleGroup

public SingleGroup getSingleGroup(Stone stone)
                           throws NoSuchDataException
Get the SingleGroup object to which this stone belongs.

Parameters:
stone - The stone which is part of the single group.
Returns:
The SingleGroup object which contains the stone.
Throws:
NoSuchDataException - Thrown if the stone is not on the board.

getNewSingleGroup

public SingleGroup getNewSingleGroup()
                              throws NoSuchDataException
Get the new SingleGroup object which contains the last move. This assumes that the last move caused a new SingleGroup object to be created.

Returns:
The SingleGroup object which contains the last move.
Throws:
NoSuchDataException - Thrown if status() does not return ADD.

getUpdatedSingleGroup

public SingleGroup getUpdatedSingleGroup()
                                  throws NoSuchDataException
Get the updated SingleGroup object which contains the last move. This assumes that the last move caused an existing SingleGroup object to be updated.

Returns:
The SingleGroup object which contains the last move.
Throws:
NoSuchDataException - Thrown if status() does not return UPDATE.

getCombinedSingleGroups

public SingleGroup[] getCombinedSingleGroups()
                                      throws NoSuchDataException
Get the SingleGroup objects that were combined. If the last move caused multiple SingleGroup objects to be combined into one, then they are returned. Otherwise, an array of size 0 is returned.

Returns:
An array of SingleGroup objects.
Throws:
NoSuchDataException - Thrown if status() does not return COMBINE.

getSuicidedSingleGroups

public SingleGroup[] getSuicidedSingleGroups()
                                      throws NoSuchDataException
Return all SingleGroup objects that died as a result of suicide. If Board.didSuicideOccur() returns false, then a NoSuchDataException is thrown.

Returns:
An array of SingleGroup objects.
Throws:
NoSuchDataException - Thrown if Board.didSuicideOccur() returns false.

getTotalSingleGroups

public short getTotalSingleGroups()
Get the total number of groups on the board.

Returns:
The total number of groups on the board.

getCapturedSingleGroups

public SingleGroup[] getCapturedSingleGroups()
Return SingleGroup objects that have been removed because of prisoner captures.

Returns:
An array of SingleGroup objects that were present before the last move, but were removed as a result of stones being captured.