org.moyoman.module.geometry.geometryimpl
Class GeometryMoveGenerator

java.lang.Object
  |
  +--org.moyoman.module.geometry.geometryimpl.GeometryMoveGenerator
All Implemented Interfaces:
Serializable

class GeometryMoveGenerator
extends Object
implements Serializable

This class is responsible for generating moves based on the geometric analysis of the board.


Field Summary
protected  float CONFIDENCE
           
private  int friendlyGroupNum
          The total number of friendly groups.
protected static int MAX_GROUPS
          The maximum number of groups of the same color that can safely live.
protected  short moveNumber
          The number of the move to be made next.
private  boolean newFlag
          Only call NewGroupMoveGenerator if flag is true.
private  int opponentGroupNum
          The total number of opponents group.
 
Constructor Summary
(package private) GeometryMoveGenerator()
           
 
Method Summary
private  void addMoves(ArrayList al, RatedMove[] rm)
          Put the moves from the RatedMove array into the ArrayList.
private  int calculateTotalGroups(Color col, LooseGroups lg, GeometryImpl geo)
          Get the total number of groups of a given color.
private  void combineMoves(ArrayList al)
          Combine all of the ratings for a given move into one rating.
protected  Set getBorderPoints(Board b, GeometryImpl geo, LooseGroups lg, Color color, Point[] points)
          Return a subset of the points which are on the border of two groups of opposite color.
protected  int getDistance(Point pt1, Point pt2)
          Return the square of the euclidean distance between the two points.
protected  RatedMove[] getMoves(Board b, LooseGroups lg, GeometryImpl geo)
          Get the rated moves.
protected  Set getPointsInConvexHullWithEdgePoints(LooseGroups lg, GeometryImpl geo)
          Get the points inside of the convex hull with associated edge points.
protected  RatedMove getRatedMove(Stone st, float val)
          Create a RatedMove object from teh stone and rating.
protected  int getTotalFriendlyGroups()
          Get the total number of groups of the color to move next.
protected  int getTotalOpponentGroups()
          Get the total number of groups of the opponent of the player to move next.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_GROUPS

protected static final int MAX_GROUPS
The maximum number of groups of the same color that can safely live.

See Also:
Constant Field Values

moveNumber

protected short moveNumber
The number of the move to be made next.


friendlyGroupNum

private int friendlyGroupNum
The total number of friendly groups.


opponentGroupNum

private int opponentGroupNum
The total number of opponents group.


newFlag

private boolean newFlag
Only call NewGroupMoveGenerator if flag is true.


CONFIDENCE

protected final float CONFIDENCE
See Also:
Constant Field Values
Constructor Detail

GeometryMoveGenerator

GeometryMoveGenerator()
Method Detail

getMoves

protected RatedMove[] getMoves(Board b,
                               LooseGroups lg,
                               GeometryImpl geo)
Get the rated moves.

Parameters:
b - The Board module.
lg - The LooseGroups module.
geo - The GeometryImpl module.
Returns:
An array of RatedMove objects, which are the recommended moves.

addMoves

private void addMoves(ArrayList al,
                      RatedMove[] rm)
Put the moves from the RatedMove array into the ArrayList.

Parameters:
rm - The array containing the rated moves.
al - The ArrayList to add the moves to.

combineMoves

private void combineMoves(ArrayList al)
Combine all of the ratings for a given move into one rating. The ratings also need to be kept within the range of -1.0 to 1.0.

Parameters:
al - An ArrayList containing RatedMove objects, some of which might be for the same move.

getRatedMove

protected RatedMove getRatedMove(Stone st,
                                 float val)
Create a RatedMove object from teh stone and rating.

Parameters:
st - The Stone to be rated.
val - The rating of the move.
Returns:
A RatedMove object.

getDistance

protected int getDistance(Point pt1,
                          Point pt2)
Return the square of the euclidean distance between the two points.

Parameters:
pt1 - One of the points.
pt2 - The other point.
Returns:
The square of the distance.

getBorderPoints

protected Set getBorderPoints(Board b,
                              GeometryImpl geo,
                              LooseGroups lg,
                              Color color,
                              Point[] points)
Return a subset of the points which are on the border of two groups of opposite color.

Parameters:
b - The Board module.
geo - The GeometryImpl module.
lg - The LooseGroups module.
color - The color of the player to move.
points - The points being considered.
Returns:
A Set which contains a subset of the points in the points parameter.

getPointsInConvexHullWithEdgePoints

protected Set getPointsInConvexHullWithEdgePoints(LooseGroups lg,
                                                  GeometryImpl geo)
Get the points inside of the convex hull with associated edge points.

Parameters:
lg - The LooseGroups module.
geo - The GeometryImpl module.
Returns:
A Set containing points which are inside the convex hull.

calculateTotalGroups

private int calculateTotalGroups(Color col,
                                 LooseGroups lg,
                                 GeometryImpl geo)
Get the total number of groups of a given color. If the group is only nearest to a few empty points, then it is not counted. Obviously, this crude estimate may not be accurate past a certain stage in the game, but it should be less important at that time.

Parameters:
col - The color of groups being counted.
lg - The LooseGroups module.
geo - The GeometryImpl module.
Returns:
The number of groups of the given color.

getTotalFriendlyGroups

protected int getTotalFriendlyGroups()
Get the total number of groups of the color to move next.

Returns:
The number of groups of the given color.

getTotalOpponentGroups

protected int getTotalOpponentGroups()
Get the total number of groups of the opponent of the player to move next.

Returns:
The number of groups of the given color.