org.moyoman.module.geometry.geometryimpl
Class NewGroupMoveGenerator

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

class NewGroupMoveGenerator
extends Object
implements GeometryStrategy

This class rates various moves that create a new group. Responsibilities of this class include determining whether new groups should be formed as well as which moves to make in creating new groups.


Field Summary
private static short CENTER
          Symbolic constant referring to the center.
private static short CORNER
          Symbolic constant referring to the corner.
private  GeometryMoveGenerator gmg
           
private static short SIDE
          Symbolic constant referring to the side.
 
Constructor Summary
(package private) NewGroupMoveGenerator()
           
 
Method Summary
private  int computeDistance(Stone st, SingleLooseGroup slg)
          Find the square of the distance to the closest stone in the group from the given stone.
protected  RatedMove[] evaluate(Board b, LooseGroups l, GeometryImpl geo, Stone[] stones)
          Evaluate the possible moves.
private  Stone[] filter(Board b, LooseGroups l, Geometry geo)
          Find possible moves which are not obviously bad.
 RatedMove[] getMoves(Board b, LooseGroups l, GeometryImpl geo, GeometryMoveGenerator gmg)
          Get the rated moves.
private  short getStatus(Stone st, int distance)
          Determine whether the stone is closest to the corner, side or center.
private  boolean tooClose(Point pt1, Point pt2)
          Determine if the two points are less than a two space extension apart.
private  boolean wasOpponentWeakened(Geometry geo, Stone st)
          Determine if the given move weakens any opponents groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CORNER

private static final short CORNER
Symbolic constant referring to the corner.

See Also:
Constant Field Values

SIDE

private static final short SIDE
Symbolic constant referring to the side.

See Also:
Constant Field Values

CENTER

private static final short CENTER
Symbolic constant referring to the center.

See Also:
Constant Field Values

gmg

private GeometryMoveGenerator gmg
Constructor Detail

NewGroupMoveGenerator

NewGroupMoveGenerator()
Method Detail

getMoves

public RatedMove[] getMoves(Board b,
                            LooseGroups l,
                            GeometryImpl geo,
                            GeometryMoveGenerator gmg)
Get the rated moves.

Specified by:
getMoves in interface GeometryStrategy
Parameters:
b - The Board module.
l - The LooseGroups module.
geo - The GeometryImpl module.
Returns:
An array of RatedMove objects.

filter

private Stone[] filter(Board b,
                       LooseGroups l,
                       Geometry geo)
Find possible moves which are not obviously bad.

Parameters:
b - The Board module.
l - The LooseGroups module.
geo - The Geometry module.
Returns:
An array of Stone objects which are the possible moves.

tooClose

private boolean tooClose(Point pt1,
                         Point pt2)
Determine if the two points are less than a two space extension apart.

Parameters:
pt1 - One of the points.
pt2 - The other point.
Returns:
true if the points are too close together, or false.

evaluate

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

Parameters:
b - The Board object.
l - The LooseGroups object.
geo - The Geometry object.
stones - The possible moves to be evaluated.
Returns:
A float between 0.0 and 1.0.

computeDistance

private int computeDistance(Stone st,
                            SingleLooseGroup slg)
Find the square of the distance to the closest stone in the group from the given stone.

Parameters:
st - The stone in question.
slg - The loose group in question.
Returns:
The square of the distance to the closest stone in the group.

getStatus

private short getStatus(Stone st,
                        int distance)
Determine whether the stone is closest to the corner, side or center. The check for the side and corner is only within the distance of the distance parameter.

Parameters:
st - The stone in question.
distance - The distance to check for a side or corner.
Returns:
One of the constants CENTER, SIDE, or CORNER.

wasOpponentWeakened

private boolean wasOpponentWeakened(Geometry geo,
                                    Stone st)
Determine if the given move weakens any opponents groups.

Parameters:
geo - The Geometry module.
st - The stone in question.
Returns:
true if any groups were weakened, or false.