org.moyoman.module.ladder
Interface Ladder

All Superinterfaces:
Cloneable, ModuleInterface, Serializable
All Known Implementing Classes:
LadderImpl

public interface Ladder
extends ModuleInterface

The class that implements this interface will examine the board for ladders, and look for ladder breakers and ladder threats. A ladder breaker is defined as a stone as the same color as the group in the ladder which would cause the group to escape, regardless of whether the ladder already works or not. A ladder threat is similar but is a stone of the opposite color from the group in the ladder, which would cause the group to be captured. Note that the term ladder is used here to refer to situations where the group being attacked alternates between one and two liberties. This includes traditional ladders, and also situations such as where one side hanes on the first line, the other side puts that stone in atari, the first side connects, the second side does not connect, and the first side puts the stone on the first line in atari. Ladder techniques may fail to capture this stone, but the Tesuji or Tactics module might get the correct answer. Moves are only evaluated in the local context, so for example if there 8 moves that are ladder breakers, no attempt is made to rank the usefulness of any of these 8 moves.


Field Summary
static float CONFIDENCE
           
 
Method Summary
 boolean canGroupPotentiallyBeCaught(SingleGroup sg)
          Determine if the group is in a potential ladder and can be caught.
 Stone[] createLadder(SingleGroup sg)
          Get the stones which would put the group into a ladder.
 Set getLadderBreakers(SingleGroup sg)
          Get all stones which would enable the group to escape the ladder.
 Set getLadderThreats(SingleGroup sg)
          Get any stone which would cause the group in the ladder to be captured..
 SingleGroup[] groupsInLadder()
          Get all of the groups which are currently in a ladder.
 SingleGroup[] groupsInPotentialLadder()
          Get all of the groups which could be put in a ladder if the opponent moves next.
 boolean isGroupCaught(SingleGroup sg)
          Determine if the group in the ladder can be captured.
 boolean isInLadder(SingleGroup sg)
          Determine if the group is in a ladder.
 boolean isInPotentialLadder(SingleGroup sg)
          Determine if the group is in a potential ladder.
 short totalMovesToCapture(SingleGroup sg)
          Get the number of moves to capture the group.
 
Methods inherited from interface org.moyoman.module.ModuleInterface
clone, getMoves, getScheduler
 

Field Detail

CONFIDENCE

public static final float CONFIDENCE
See Also:
Constant Field Values
Method Detail

isInLadder

public boolean isInLadder(SingleGroup sg)
Determine if the group is in a ladder.

Parameters:
sg - The SingleGroup in question.
Returns:
true if the group is in a ladder, or false.

isInPotentialLadder

public boolean isInPotentialLadder(SingleGroup sg)
Determine if the group is in a potential ladder. A potential ladder is defined as a situation where the opponent can put the group in a ladder if a stone is not added to the group.

Parameters:
sg - The SingleGroup in question.
Returns:
true if the group is in a potential ladder, or false.

groupsInLadder

public SingleGroup[] groupsInLadder()
Get all of the groups which are currently in a ladder. It does not matter if the ladders work or not.

Returns:
An array of SingleGroup objects.

groupsInPotentialLadder

public SingleGroup[] groupsInPotentialLadder()
Get all of the groups which could be put in a ladder if the opponent moves next. It does not matter if the ladders would work or not.

Returns:
An array of SingleGroup objects.

isGroupCaught

public boolean isGroupCaught(SingleGroup sg)
                      throws IllegalArgumentException
Determine if the group in the ladder can be captured. If the group in question has one liberty, then the result of this method is based on the group trying to escape first, but if it has two liberties, then the result of this method is based on the attacker playing first.

Returns:
true if the group is caught, or false if it can escape.
Throws:
IllegalArgumentException - Thrown if isInLadder(sg) would return false.

totalMovesToCapture

public short totalMovesToCapture(SingleGroup sg)
                          throws IllegalArgumentException
Get the number of moves to capture the group. The number of moves by both sides to capture the group in the ladder or potential ladder is returned. If there are branches, then the shortest path which results in a capture is used.

Parameters:
sg - The SingleGroup that is captured.
Returns:
The total number of moves to capture the group.
Throws:
IllegalArgumentException - Thrown if the group is not in a ladder or potential ladder, or if the ladder or potential ladder does not work.

canGroupPotentiallyBeCaught

public boolean canGroupPotentiallyBeCaught(SingleGroup sg)
Determine if the group is in a potential ladder and can be caught. This method would return true only if the group has two liberties, and if the opponent makes the next move which causes the group to be in a ladder so that isGroupCaught() would return true.


getLadderBreakers

public Set getLadderBreakers(SingleGroup sg)
                      throws IllegalArgumentException
Get all stones which would enable the group to escape the ladder. All stones which are ladder breakers are returned regardless of whether the group can currently escape or not.

Parameters:
sg - The group in question.
Returns:
An array of Stone objects.
Throws:
IllegalArgumentException - Thrown if isInLadder(sg) would return false.

getLadderThreats

public Set getLadderThreats(SingleGroup sg)
Get any stone which would cause the group in the ladder to be captured.. It is an error to call this method on a single group which is not in a ladder, but all stones which work are returned regardless of whether isGroupCaught() currently returns true or false.

Parameters:
sg - The group in question.
Returns:
An array of Stone objects.
Throws:
IllegalArgumentException - Thrown if isInLadder(sg) would return false.

createLadder

public Stone[] createLadder(SingleGroup sg)
                     throws IllegalArgumentException
Get the stones which would put the group into a ladder. The group must already be in a potential ladder, so if two stones are returned, then playing either of them would put the group in a ladder.

Parameters:
sg - The group in question.
Returns:
An array of Stone objects.
Throws:
IllegalArgumentException - Thrown if isInPotentialLadder(sg) would return false.