|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.moyoman.module.Module
|
+--org.moyoman.module.ladder.ladderimpl.LadderImpl
This module implements the Ladder interface. This module is meant to be both a working Ladder module and a demonstration of how to write a search based module.
Currently, this module is stateless, that is, ladders are read out after each move even though the last move may not have changed ladders which were already present. Caching of results should result in a marked performance improvement.
| Field Summary | |
private static DebugType[] |
dt
The debug types which this module produces. |
private boolean |
isGenerated
This is true after generateMove() but before makeMove() is called. |
private Board |
lastBoard
The current Board module. |
private Groups |
lastGroups
The current Groups module. |
private MoveDescriptorForest |
mdf
The sequence of best play for the various ladders on the board. |
private static ModuleType[] |
mt
The modules upon which this module depends. |
private HashMap |
results
The key is a SingleGroup object, and the value is a LadderInfo object. |
private RatedMove[] |
rm
The moves suggested by this module. |
| Fields inherited from class org.moyoman.module.Module |
|
| Fields inherited from interface org.moyoman.module.ladder.Ladder |
CONFIDENCE |
| Constructor Summary | |
LadderImpl(GameId id,
ModuleName name)
Create a new LadderImpl object. |
|
| Method Summary | |
private void |
calculateLadder(Scheduler sch,
MoveDescriptorForest mdf,
LadderInfo li,
SingleGroup sg,
MoveDescriptor last)
This method adds two moves to a ladder per invocation. |
private LadderInfo |
calculateLadder(SingleGroup sg)
Calculate ladder information for a single group. |
private Set |
calculateLadderBreakers(SingleGroup sg,
MoveDescriptorForest mdf)
Find all moves which are ladder breakers for the given group. |
private Set |
calculateLadderThreats(SingleGroup sg,
MoveDescriptorForest mdf)
Find all moves which are ladder breakers for the given group. |
boolean |
canGroupPotentiallyBeCaught(SingleGroup sg)
Return true if the group is in a potential ladder and would be caught if the opponent moves first. |
Object |
clone()
Clone the module. |
Stone[] |
createLadder(SingleGroup sg)
Get the stones which would put the group into a ladder. |
void |
generateMove(Module[] modules)
Generate moves based on the ladders and potential ladders on the board. |
Debug[] |
getDebugInformation(DebugType[] types)
Return Debug objects based on the current analysis of the board. |
DebugType[] |
getDebugTypes()
Get the debug types that this module supports. |
Set |
getLadderBreakers(SingleGroup sg)
Get all stones which would break the ladder on the group and allow it to escape. |
Set |
getLadderThreats(SingleGroup sg)
Get all stones which would threaten to capture the ladder. |
RatedMove[] |
getMoves()
Get the moves rated by this module. |
private short |
getPathLength(MoveDescriptorForest forest,
MoveDescriptor md,
short len)
Return the shortest path length of the ladder from this point. |
ModuleType[] |
getRequiredModuleList()
Get the module types used by this module. |
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. |
private int |
libCount(Point pt,
Color escapeColor)
|
void |
makeMove(Move move,
Module[] modules)
Update this module with the current move. |
private void |
onePairAnalysis(Point attackerPt,
Point escaperPt,
Scheduler sch,
MoveDescriptorForest mdf,
LadderInfo li,
SingleGroup sg,
MoveDescriptor last)
Add two moves to the ladder. |
private SingleGroup |
refresh(SingleGroup sg)
Return the corresponding SingleGroup object from the current lastGroups. |
short |
totalMovesToCapture(SingleGroup sg)
Return the total number of moves to capture the group. |
| Methods inherited from class org.moyoman.module.Module |
checkTime, create, createHelper, debug, error, error, fatal, fatal, getAllHelpers, getHelper, getId, getKomi, getModule, getModuleName, getScheduler, information, setTime, warning, warning |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.moyoman.module.ModuleInterface |
getScheduler |
| Field Detail |
private static ModuleType[] mt
private static DebugType[] dt
private RatedMove[] rm
private boolean isGenerated
private Board lastBoard
private Groups lastGroups
private HashMap results
private MoveDescriptorForest mdf
| Constructor Detail |
public LadderImpl(GameId id,
ModuleName name)
throws InternalErrorException
id - The id of this player.name - The name of this module.
InternalErrorException - Thrown if the operation fails for any reason.| Method Detail |
private SingleGroup refresh(SingleGroup sg)
throws NoSuchDataException
sg - A SingleGroup object.
NoSuchDataException - Thrown if there is no single group corresponding
to the sg parameter.public boolean isInLadder(SingleGroup sg)
isInLadder in interface Laddersg - The SingleGroup in question.
public boolean isInPotentialLadder(SingleGroup sg)
isInPotentialLadder in interface Laddersg - The SingleGroup in question.
public SingleGroup[] groupsInLadder()
groupsInLadder in interface Ladderpublic SingleGroup[] groupsInPotentialLadder()
groupsInPotentialLadder in interface Ladder
public boolean isGroupCaught(SingleGroup sg)
throws IllegalArgumentException
isGroupCaught in interface LadderIllegalArgumentException - Thrown if isInLadder(sg) would return false.public boolean canGroupPotentiallyBeCaught(SingleGroup sg)
canGroupPotentiallyBeCaught in interface Laddersg - The SingleGroup in question.
public Set getLadderBreakers(SingleGroup sg)
throws IllegalArgumentException
getLadderBreakers in interface Laddersg - The group in question.
IllegalArgumentException - Thrown if isInLadder(sg) would return false.
public Set getLadderThreats(SingleGroup sg)
throws IllegalArgumentException
getLadderThreats in interface Laddersg - The group in question.
IllegalArgumentException - Thrown if isInLadder(sg) would return false.
public Stone[] createLadder(SingleGroup sg)
throws IllegalArgumentException
createLadder in interface Laddersg - The group in question.
IllegalArgumentException - Thrown if the group is not in a potential ladder.
public short totalMovesToCapture(SingleGroup sg)
throws IllegalArgumentException
totalMovesToCapture in interface Laddersg - The group in question.
IllegalArgumentException - Thrown if the group is not in
a ladder or potential ladder, or if the group cannot be captured.
private short getPathLength(MoveDescriptorForest forest,
MoveDescriptor md,
short len)
throws IllegalArgumentException
forest - The sequences of the ladder.md - The current position of the ladder being analyzed.len - The length of the ladder to this position.
IllegalArgumentException - Thrown if the group is not in
a ladder or potential ladder, or if the group cannot be captured.
public void generateMove(Module[] modules)
throws InternalErrorException
generateMove in class Modulemodules - The modules which this module uses.
InternalErrorException - Thrown if the module fails for any reason.public Debug[] getDebugInformation(DebugType[] types)
getDebugInformation in class Moduletypes - The types of debug objects that the caller can use.
public DebugType[] getDebugTypes()
getDebugTypes in class Modulepublic RatedMove[] getMoves()
getMoves in interface ModuleInterfacegetMoves in class Modulepublic ModuleType[] getRequiredModuleList()
getRequiredModuleList in class Module
public void makeMove(Move move,
Module[] modules)
throws InternalErrorException
makeMove in class Modulemove - The last move made.modules - The modules that this module uses.
InternalErrorException - Thrown if the module fails for any reason.private LadderInfo calculateLadder(SingleGroup sg)
sg - The SingleGroup in question.
private void calculateLadder(Scheduler sch,
MoveDescriptorForest mdf,
LadderInfo li,
SingleGroup sg,
MoveDescriptor last)
sch - The Scheduler which represents the state of the board being analyzed.mdf - The sequences of moves found so far.li - The LadderInfo object with the results so far.sg - The single group which is trying to be caught in the ladder.
private void onePairAnalysis(Point attackerPt,
Point escaperPt,
Scheduler sch,
MoveDescriptorForest mdf,
LadderInfo li,
SingleGroup sg,
MoveDescriptor last)
escaperPt - The point on which the escaper is to play after the attackers move.sch - The Scheduler object representing the current position being analyzed.mdf - The sequence of moves in the ladder.li - The LadderInfo object.sg - The group under attack.last - The last position analyzed so far.
private Set calculateLadderBreakers(SingleGroup sg,
MoveDescriptorForest mdf)
sg - The group in question.mdf - The sequences of moves for the ladder.
private int libCount(Point pt,
Color escapeColor)
private Set calculateLadderThreats(SingleGroup sg,
MoveDescriptorForest mdf)
sg - The group in question.mdf - The sequences of moves for the ladder.
public Object clone()
ModuleInterface
clone in interface ModuleInterfaceclone in class Module
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||