de.tabacha.cgo.strategy
Class NoRecursionTemplate
java.lang.Object
de.tabacha.cgo.AbstractEngine
de.tabacha.cgo.strategy.NoRecursionTemplate
- All Implemented Interfaces:
- Constants, Engine
- Direct Known Subclasses:
- FiveTypes, ModernMikeGo, SimpleEngine
- public abstract class NoRecursionTemplate
- extends AbstractEngine
Template to simplify the writing of simple engines that only test the first move.
To use this class, overwrite the methods
initNewMoveSearch()
,
jumpFound(de.tabacha.cgo.Jump, int, int)
,
minMaxFound(int, int)
,
putFound(de.tabacha.cgo.Put)
and
bestMove()
.
$Id: NoRecursionTemplate.java,v 1.10 2004/12/23 21:42:44 mk Exp $
- Version:
- $Revision: 1.10 $
- Threadsafe?
- false
Fields inherited from interface de.tabacha.cgo.Constants |
BALL, COL_COUNT, DCOL, DOWN, DROW, E, EMPTY, FIRST_DIRECTION, KICK_OFF_FIELD, LAST_DIRECTION, N, NE, NW, OPPOSITE, PIECE, ROW_COUNT, S, SE, SW, UP, UPSIDEDOWN, W |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NoRecursionTemplate
protected NoRecursionTemplate()
- Constructor.
canPlayBothSides
public final boolean canPlayBothSides()
- Description copied from class:
AbstractEngine
- This default implementation always returns false.
- Specified by:
canPlayBothSides
in interface Engine
- Overrides:
canPlayBothSides
in class AbstractEngine
- See Also:
Engine.canPlayBothSides()
initNewMoveSearch
protected void initNewMoveSearch()
jumpFound
protected abstract boolean jumpFound(Jump j,
int min,
int max)
- Returns:
- true if the move is found
minMaxFound
protected boolean minMaxFound(int min,
int max)
- Returns:
- true if the move is found
putFound
protected abstract boolean putFound(Put p)
- Returns:
- true if the move is found
bestMove
protected abstract Move bestMove()
board
protected Board board()
- Returns a fast and small and immutable implementation of the Board interface.
Methods that would change the board (or would enable a change) throw an
UnsupportedOperationException.
To get a changeable board, use the clone() method.
think
public final Move think(Board position)
- Thinking here.
- Parameters:
position
- The actual position
- Returns:
- The move the routine makes
getMinMaxRow
protected int[] getMinMaxRow()