|
|||||||||||
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.tactics.tacticsimpl.TacticsImpl
This module implements the Tactics interface. It is responsible for finding sequences of moves for playing tactically. It is a low level module which does not do any strategic analysis.
This Tactics implementation is meant to be a tradeoff between skill and development time. It is meant to be sophisticated enough to produce the tactical play of at least a 10 kyu player, but simple enough that it can be implemented reasonably quickly. It is also meant to be extensible so that it can grow more sophisticated over time.
Currently, this module is stateless, but eventually results will be reused across moves. This is because most moves will only have a tactical effect on a small part of the board and so an incremental update will be much faster. If a large group is captured, then a full analysis of the board can be done.
This module implements ideas from volume 5 of Janice Kim's Learn to Play Go series, "The Palace of Memory", and from Bruce Wilcox's book "EZGO Oriental Strategy in a Nutshell" based on his three decades of experience in the field of computer go. Neither Janice or Bruce endorse the work here, and any mistakes are my responsibility alone.
The algorithm will use the following features:
Field Summary | |
private MoveDescriptorForest |
blackMDF
The MoveDescriptorForest object containing sequences of good moves for Black. |
private static DebugType[] |
dt
The debug types that this module supports. |
private Stone[] |
important
The stones which should try to be saved. |
private boolean |
isGenerated
This flag is used to determine when to clear variables set by generateMove(). |
private Board |
lastBoard
The last board obtained from makeMove(). |
private Groups |
lastGroups
The last groups obtained from makeMove(). |
private LooseGroups |
lastLooseGroups
The last loose groups obtained from makeMove(). |
private Move |
lastMove
The last Stone played. |
private ModuleType[] |
mt
The modules that this module requires. |
private RatedMove[] |
rm
The moves that were rated by this module. |
private MoveDescriptorForest |
whiteMDF
The MoveDescriptorForest object containing sequences of good moves for White. |
Fields inherited from class org.moyoman.module.Module |
|
Fields inherited from interface org.moyoman.module.tactics.Tactics |
CONFIDENCE |
Constructor Summary | |
TacticsImpl(GameId id,
ModuleName name)
Create the TacticsImpl object. |
Method Summary | |
private void |
analyzeLibertyCount(SingleLooseGroup slg)
Increase the liberties of friendly groups, and decrease the liberties of opponents groups. |
private boolean |
areLegalCoordinates(int x,
int y)
|
private void |
calculateTacticsForSingleLooseGroup(SingleLooseGroup slg)
Compute tactics for the loose group. |
private boolean |
canCuttingStoneBeCaptured(SingleGroup sg1,
SingleGroup sg2,
Stone st)
Determine if an opponents stone played at the cutting point could be captured. |
Object |
clone()
Clone the module. |
private boolean |
findConnectedDiagonal(SingleGroup sg1,
SingleGroup sg2)
This is true if the two groups are connected by a diagonal. |
void |
generateMove(Module[] modules)
Generate the move for this module. |
private void |
generateRatedMoves(Color color)
|
private void |
generateTacticalSequences(Color color)
Generate the rated moves, and the related tactical sequences. |
MoveDescriptorForest |
getCurrentPlayerKoThreats()
Get sequences of moves where the current player makes the first two moves. |
MoveDescriptorForest |
getCurrentPlayerSequences()
Get sequences of moves that might occur in tactical play for the current player. |
private Point |
getCuttingPoint(SingleGroup sg1,
SingleGroup sg2)
Find the cutting point for the diagonal connection between two groups. |
Debug[] |
getDebugInformation(DebugType[] types)
Return the debug information for this module. |
DebugType[] |
getDebugTypes()
Return the types of debug information that this module supports. |
private short |
getLibertyCount(SingleLooseGroup slg)
Get the liberty count for the loose group if it acts like a single group. |
RatedMove[] |
getMoves()
Return the moves generated by the module. |
MoveDescriptorForest |
getOpponentPlayerKoThreats()
Get sequences of moves where the opponent player makes the first two moves. |
MoveDescriptorForest |
getOpponentPlayerSequences()
Get sequences of moves that might occur in tactical play for the opponent player. |
ModuleType[] |
getRequiredModuleList()
Return the modules that this module requires to perform its task. |
boolean |
isMoveUrgent(SingleGroup sg)
Determine if the group is stable, or if another move is required. |
boolean |
isMoveUrgent(SingleLooseGroup slg)
Determine if the loose group is stable, or if another move is required. |
void |
makeMove(Move move,
Module[] modules)
Update the internal data structures of this module with the new move. |
private void |
recompute()
Calculate tactics for all loose groups on the board. |
void |
setImportantStones(Stone[] stones)
Set the stones which should preferentially be saved. |
private boolean |
singleALC(SingleLooseGroup slg)
Analyze the possible sequences of moves if the loose group only has one single 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 DebugType[] dt
private ModuleType[] mt
private RatedMove[] rm
private Board lastBoard
private Groups lastGroups
private LooseGroups lastLooseGroups
private MoveDescriptorForest blackMDF
private MoveDescriptorForest whiteMDF
private boolean isGenerated
private Stone[] important
private Move lastMove
Constructor Detail |
public TacticsImpl(GameId id, ModuleName name) throws InternalErrorException
id
- The id of the game.name
- The name of this module.
InternalErrorException
- Thrown if the operation fails for any reason.Method Detail |
public void generateMove(Module[] modules)
generateMove
in class Module
modules
- An array of modules which this module needs
in order to perform its work. Those modules reflect the
current state of the board but are copies of the actual modules,
so this method is free to manipulate them.private void generateTacticalSequences(Color color)
private void generateRatedMoves(Color color)
public Debug[] getDebugInformation(DebugType[] types)
getDebugInformation
in class Module
types
- Only return a subset of the debug types in this array.
public DebugType[] getDebugTypes()
getDebugTypes
in class Module
public RatedMove[] getMoves()
getMoves
in interface ModuleInterface
getMoves
in class Module
public ModuleType[] getRequiredModuleList()
getRequiredModuleList
in class Module
public void makeMove(Move move, Module[] modules)
makeMove
in class Module
move
- The move that was just made.modules
- The modules that this method needs to perform its job.private void recompute()
private void calculateTacticsForSingleLooseGroup(SingleLooseGroup slg)
slg
- The SingleLooseGroup in question.private short getLibertyCount(SingleLooseGroup slg)
slg
- The single loose group.
private boolean findConnectedDiagonal(SingleGroup sg1, SingleGroup sg2)
sg1
- A SingleGroup object.sg2
- Another SingleGroup object.
private Point getCuttingPoint(SingleGroup sg1, SingleGroup sg2)
sg1
- A SingleGroup object.sg2
- Another SingleGroup object.
private boolean canCuttingStoneBeCaptured(SingleGroup sg1, SingleGroup sg2, Stone st)
sg1
- A SingleGroup object.sg2
- Another SingleGroup object.st
- The opponents stone to be captured.
private void analyzeLibertyCount(SingleLooseGroup slg)
private boolean singleALC(SingleLooseGroup slg)
slg
- The SingleLooseGroup in question.
private boolean areLegalCoordinates(int x, int y)
public MoveDescriptorForest getCurrentPlayerSequences() throws NoSuchDataException
getCurrentPlayerSequences
in interface Tactics
NoSuchDataException
- Thrown if the last move made was not generated by this player.public MoveDescriptorForest getOpponentPlayerSequences() throws NoSuchDataException
getOpponentPlayerSequences
in interface Tactics
NoSuchDataException
- Thrown if the last move made was not generated by this player.public MoveDescriptorForest getCurrentPlayerKoThreats() throws NoSuchDataException
Tactics
getCurrentPlayerKoThreats
in interface Tactics
NoSuchDataException
public MoveDescriptorForest getOpponentPlayerKoThreats() throws NoSuchDataException
Tactics
getOpponentPlayerKoThreats
in interface Tactics
NoSuchDataException
public void setImportantStones(Stone[] stones)
setImportantStones
in interface Tactics
stones
- The stones which are important.public boolean isMoveUrgent(SingleGroup sg)
Tactics
isMoveUrgent
in interface Tactics
sg
- The group in question.
public boolean isMoveUrgent(SingleLooseGroup slg)
Tactics
isMoveUrgent
in interface Tactics
slg
- The loose group in question.
public Object clone()
clone
in interface ModuleInterface
clone
in class Module
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |