|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.debug.Debug | +--org.moyoman.debug.Aggregate
This class represents groups of stones and their relations. A stone is assigned to a group, but there are a number of options beyond that. Stones within a group can also be assigned to a subgroup, so if groups of one module are grouped together into a single group in a succeeding module, both the group and subgroup can be indicated. An example is that each subgroup would be stones that are captures as a unit, while the group are an aggregate of units that act as a group. For example, a three space extension from a two stone wall would have three stones in the same group, but two subgroups.
Pairs of groups can be related by either empty points, stones
not in either group, or without any other points or stones.
It is an error to try to relate the same two groups in more than
one way. If this needs to be done, then there should be a separate
Aggregate object for each relation.
As an example of a relation by points, if black and white each
want to extend from a shimari to the same points, then those
points would relate the group of the black and white shimaris.
As an example of a relation by stones, if certain moves would cause
two groups of the same color to become one group, then those stones
would relate the two groups.
As an example of a relation without points or stones, groups
which are spatially adjacent would be related this way.
Subsets of a group can be selected as special, for example the cutting stones in a group of stones.
Field Summary | |
private ArrayList |
groups
Each element is an ArrayList containing Stone objects. |
private static short |
NONE
Value returned by getRelationType if the two groups are not related. |
private static short |
POINTS
Value returned by getRelationType if the two groups are related by points. |
private ArrayList |
relateGroups
Each element is an IntPair object. |
private HashMap |
relateGroupsByPoints
The keys are IntPair objects, and the values are an array of Point objects. |
private HashMap |
relateGroupsByStones
The keys are IntPair objects, and the values are an array of Stone objects. |
private ArrayList |
special
Each element is a Stone object. |
private static short |
STONES
Value returned by getRelationType if the two groups are related by stones. |
private int[] |
subgroupCount
The index is the group number, the value is the number of subgroups. |
private HashMap |
subgroups
Element key is a Stone object, each value is a String object. |
private static short |
WITHOUT_POINTS_OR_STONES
Value returned by getRelationType if the two groups are related without points or stones. |
Fields inherited from class org.moyoman.debug.Debug |
|
Constructor Summary | |
Aggregate(String h)
Create a new Aggregate object. |
Method Summary | |
int |
addGroup(Stone[] stones)
Add a group of stones. |
Stone[] |
getGroupStones(int group)
Return the stones in a particular group. |
Point[] |
getRelatingPoints(IntPair ip)
Get the points which relate the two groups. |
Stone[] |
getRelatingStone(IntPair ip)
Get the stones which relate the two groups. |
IntPair[] |
getRelations()
Get all of the relations without points or stones. |
IntPair[] |
getRelationsByPoints()
Get all of the relations through points. |
IntPair[] |
getRelationsByStones()
Get all of the relations through stones. |
short |
getRelationType(IntPair ip)
Returns information on how the groups are related. |
int |
getSubgroup(Stone st)
Return the subgroup for the stone. |
int |
getTotalGroups()
Return the total number of groups. |
int |
getTotalSubgroups(int group)
Get the total number of subgroups for the given group. |
DebugType |
getType()
Get the type of this debug object. |
boolean |
hasSubgroup(Stone st)
Determine if the stone is in a subgroup. |
boolean |
isSpecial(Stone st)
Determine if the stone is marked as special. |
static void |
main(String[] args)
This method is used for unit testing. |
void |
relateGroups(int group1,
int group2)
Relate two groups without any points or stones. |
void |
relateGroups(int group1,
int group2,
Point[] points)
Relate two groups through a set of points. |
void |
relateGroups(int group1,
int group2,
Stone[] stones)
Relate two groups through a set of stones. |
void |
setSpecial(Stone st)
Set the special status of the stone. |
int |
setSubgroup(int group,
Stone[] stones)
Set the subgroup for a set of stones. |
String |
toString()
Return a String representation of the object. |
private void |
validateIntPairUnrelated(IntPair ip)
Verify that the two groups are not already related. |
private boolean |
validateStoneGroup(int group,
Stone st)
Determine if the stone is in the specified group. |
Methods inherited from class org.moyoman.debug.Debug |
getHeaderType |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final short NONE
private static final short WITHOUT_POINTS_OR_STONES
private static final short POINTS
private static final short STONES
private ArrayList groups
private HashMap subgroups
private int[] subgroupCount
private ArrayList relateGroups
private HashMap relateGroupsByPoints
private HashMap relateGroupsByStones
private ArrayList special
Constructor Detail |
public Aggregate(String h)
h
- The header.Method Detail |
public static void main(String[] args)
public int addGroup(Stone[] stones)
stones
- An array of stones that are one group.
public int setSubgroup(int group, Stone[] stones) throws IndexOutOfBoundsException, InconsistentStateException
group
- - The group number.stones
- - The stones that are part of the subgroup.
IndexOutOfBoundsException
- Thrown if the group number
is invalid.
InconsistentStateException
- Thrown if any of the
stones are not in the specified group.private boolean validateStoneGroup(int group, Stone st) throws IndexOutOfBoundsException
group
- - The group to which the stone should belong.st
- - The stone being checked.
IndexOutOfBoundsException
- Thrown if the group number
is invalid.public Stone[] getGroupStones(int group) throws IndexOutOfBoundsException
group
- The group number.
IndexOutOfBoundsException
- Thrown if the group number
is invalid.public boolean hasSubgroup(Stone st)
st
- - The stone being checked.
public int getSubgroup(Stone st) throws NoSuchDataException
st
- - The stone in question.
NoSuchDataException
- Thrown if the hasSubgroup
returns false.public int getTotalGroups()
public int getTotalSubgroups(int group) throws IndexOutOfBoundsException
group
- - The group being checked.
IndexOutOfBoundsException
- Thrown if the group number
is invalid.private void validateIntPairUnrelated(IntPair ip) throws InconsistentStateException
ip
- - The IntPair object representing the two groups.
InconsistentStateException
- Thrown if the two groups
are already related.public void relateGroups(int group1, int group2) throws IndexOutOfBoundsException, InconsistentStateException
group1
- - The number of the first group.group2
- - The number of the second group.
IndexOutOfBoundsException
- - Thrown if either
of the two group numbers are invalid.
InconsistentStateException
- Thrown if the groups
are already related.public void relateGroups(int group1, int group2, Stone[] stones) throws IndexOutOfBoundsException, InconsistentStateException
group1
- - The number of the first group.group2
- - The number of the second group.stones
- - The stones relating the two groups.
IndexOutOfBoundsException
- - Thrown if either
of the two group numbers are invalid.
InconsistentStateException
- Thrown if the groups
are already related.public void relateGroups(int group1, int group2, Point[] points) throws IndexOutOfBoundsException, InconsistentStateException
group1
- - The number of the first group.group2
- - The number of the second group.points
- - The points relating the two groups.
IndexOutOfBoundsException
- - Thrown if either
of the two group numbers are invalid.
InconsistentStateException
- Thrown if the groups
are already related.public IntPair[] getRelations()
public IntPair[] getRelationsByPoints()
public IntPair[] getRelationsByStones()
public short getRelationType(IntPair ip)
ip
- The IntPair object which specifies the two groups.
public Point[] getRelatingPoints(IntPair ip) throws NoSuchDataException
ip
- - The two groups which are related.
NoSuchDataException
- - Thrown if the two
groups are not related by points.public Stone[] getRelatingStone(IntPair ip) throws NoSuchDataException
ip
- - The two groups which are related.
NoSuchDataException
- - Thrown if the two
groups are not related by stones.public void setSpecial(Stone st)
st
- The stone to be marked as special.public boolean isSpecial(Stone st)
st
- - The stone in question.
public String toString()
toString
in class Object
public DebugType getType()
getType
in class Debug
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |