org.moyoman.module.geometry.geometryimpl
Class ConnectExistingGroupsMoveGenerator

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

class ConnectExistingGroupsMoveGenerator
extends Object
implements GeometryStrategy

This class rates moves by how well they connect friendly groups. The rating is also affected by how many friendly groups are on the board.


Constructor Summary
(package private) ConnectExistingGroupsMoveGenerator()
           
 
Method Summary
private  float evaluate(Stone st, SingleLooseGroup slg1, SingleLooseGroup slg2, GeometryImpl geo)
          Determine a rating for the given move in relation to the two loose groups.
private  double getDistance(Point pt, SingleLooseGroup slg, GeometryImpl geo)
          Get the euclidean distance from the point to the loose group.
private  double getDistance(SingleLooseGroup slg1, SingleLooseGroup slg2, GeometryImpl geo)
          Get the euclidean distance between two loose groups.
 RatedMove[] getMoves(Board b, LooseGroups lg, GeometryImpl geo, GeometryMoveGenerator gmg)
          Get the rated moves for connecting friendly groups.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectExistingGroupsMoveGenerator

ConnectExistingGroupsMoveGenerator()
Method Detail

getMoves

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

Specified by:
getMoves in interface GeometryStrategy
Parameters:
b - The Board module.
lg - The LooseGroups module.
geo - The GeometryImpl module.
gmg - The GeometryMoveGenerator object.

evaluate

private float evaluate(Stone st,
                       SingleLooseGroup slg1,
                       SingleLooseGroup slg2,
                       GeometryImpl geo)
Determine a rating for the given move in relation to the two loose groups. The algorithm is to multiply the distance from the stone to each of the two groups, and divide that by the same number for a stone which is halfway between the two groups, and then to square that number.

Parameters:
st - The Stone in question.
slg1 - One of the loose groups.
slg2 - The other loose group.
geo - The GeometryImpl module.
Returns:
A float in the range 0.0 to 1.0 which is the rating of the move.

getDistance

private double getDistance(Point pt,
                           SingleLooseGroup slg,
                           GeometryImpl geo)
Get the euclidean distance from the point to the loose group.

Parameters:
pt - The point in question.
slg - The loose group.
geo - The GeometryImpl module.
Returns:
A double which is the euclidean distance.

getDistance

private double getDistance(SingleLooseGroup slg1,
                           SingleLooseGroup slg2,
                           GeometryImpl geo)
Get the euclidean distance between two loose groups.

Parameters:
slg1 - One of the loose groups.
slg2 - The other loose group.
geo - The GeometryImpl module.
Returns:
A double which is the euclidean distance between the loose groups.