org.moyoman.module.geometry.geometryimpl
Class ExpandGroupMoveGenerator

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

class ExpandGroupMoveGenerator
extends Object
implements GeometryStrategy

This class rates various moves which expand existing groups. It is responsible for determining whether to expand existing groups as well as which rating particular moves.


Field Summary
private static int MAX_HOLES
           
 
Constructor Summary
(package private) ExpandGroupMoveGenerator()
           
 
Method Summary
private  boolean boundingBoxClear(Board b, Stone st1, Stone st2)
          Check the rectangular box formed by the two stones for opponents stones.
private  boolean closeEnough(Point pt1, Point pt2, GeometryImpl geo, int totalNum, int oppNum, int maxGroups)
          Determine if the two points are close enough.
protected  RatedMove[] evaluate(Board b, LooseGroups l, GeometryImpl geo, GeometryMoveGenerator gmg, Stone[] stones)
          Rate the possible moves.
private  Stone[] filter(Board b, LooseGroups l, GeometryImpl geo, GeometryMoveGenerator gmg)
          Find possible good moves to evaluate.
private  void getAllGroupPoints(Board b, ArrayList closestal, SingleLooseGroup slg, Point pt, Set points, Set holes)
          Find all empty points which are holes in the wall of stones around an area.
 RatedMove[] getMoves(Board board, LooseGroups lg, GeometryImpl geo, GeometryMoveGenerator gmg)
          Get the rated moves for expanding groups.
private  short getNewPointTotal(Stone st, Board b, GeometryImpl geo)
          Find the total number of empty points closest to this stone which were closest to the opponent.
private  void plugHoles(Board b, Geometry geo, LooseGroups l, HashMap moves)
          Find groups that are almost surrounding an area, and rate moves that close them off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_HOLES

private static final int MAX_HOLES
See Also:
Constant Field Values
Constructor Detail

ExpandGroupMoveGenerator

ExpandGroupMoveGenerator()
Method Detail

getMoves

public RatedMove[] getMoves(Board board,
                            LooseGroups lg,
                            GeometryImpl geo,
                            GeometryMoveGenerator gmg)
Get the rated moves for expanding groups.

Specified by:
getMoves in interface GeometryStrategy
Parameters:
board - The Board module.
lg - The LooseGroups module.
geo - The GeometryImpl module.
gmg - The GeometryMoveGenerator object.
Returns:
An array of RatedMove objects.

filter

private Stone[] filter(Board b,
                       LooseGroups l,
                       GeometryImpl geo,
                       GeometryMoveGenerator gmg)
Find possible good moves to evaluate.

Parameters:
l - The LooseGroups module.
geo - The GeometryImpl module.
gmg - The GeometryMoveGenerator object.
Returns:
An array of Stone objects.

evaluate

protected RatedMove[] evaluate(Board b,
                               LooseGroups l,
                               GeometryImpl geo,
                               GeometryMoveGenerator gmg,
                               Stone[] stones)
Rate the possible moves.

Parameters:
b - The Board module.
l - The LooseGroups module.
geo - The GeometryImpl module.
stones - The possible moves to evaluate.
Returns:
An array of RatedMove objects.

plugHoles

private void plugHoles(Board b,
                       Geometry geo,
                       LooseGroups l,
                       HashMap moves)
Find groups that are almost surrounding an area, and rate moves that close them off.

Parameters:
b - The Board module.
geo - The GeometryImpl module.
l - The LooseGroups module.
moves - The key is a Stone, and the value is a RatedMove object.

getAllGroupPoints

private void getAllGroupPoints(Board b,
                               ArrayList closestal,
                               SingleLooseGroup slg,
                               Point pt,
                               Set points,
                               Set holes)
Find all empty points which are holes in the wall of stones around an area. For all of the points closest to this loose group, all adjacent empty points are examined recursively. Any empty points which are found which are not closest to this loose group are considered to be holes. This is a recursive algorithm, where the points variable contains all of the points already examined.

Parameters:
b - The Board module.
closestal - An ArrayList, each member of which is a Point object.
slg - The loose group in question.
pt - The point currently being examined.
points - Each member of this set is a point which has already been examined.
holes - Each member of this set is a Point which is a hole that has been found.

getNewPointTotal

private short getNewPointTotal(Stone st,
                               Board b,
                               GeometryImpl geo)
Find the total number of empty points closest to this stone which were closest to the opponent.

Parameters:
st - The stone in question.
b - The Board module.
geo - The GeometryImpl module.
Returns:
The number of formerly enemy points closest to this stone.

closeEnough

private boolean closeEnough(Point pt1,
                            Point pt2,
                            GeometryImpl geo,
                            int totalNum,
                            int oppNum,
                            int maxGroups)
Determine if the two points are close enough. The definition of close enough depends on the number of opponents groups.

Parameters:
pt1 - One of the points.
pt2 - The other point.
geo - The GeometryImpl module.
totalNum - The number of friendly loose groups.
oppNum - The number of opponents loose groups.
maxGroups - The maximum number of groups that are safe.
Returns:
true if the two points are close enough, or false.

boundingBoxClear

private boolean boundingBoxClear(Board b,
                                 Stone st1,
                                 Stone st2)
Check the rectangular box formed by the two stones for opponents stones.

Parameters:
b - The Board module.
st1 - One of the stones.
st2 - The other stone.
Returns:
true if the bounding box is empty of opponents stones, or false.