de.tabacha.cgo.strategy
Class NoRecursionTemplate

java.lang.Object
  extended byde.tabacha.cgo.AbstractEngine
      extended byde.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

Field Summary
 
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
 
Constructor Summary
protected NoRecursionTemplate()
          Constructor.
 
Method Summary
protected abstract  Move bestMove()
           
protected  Board board()
          Returns a fast and small and immutable implementation of the Board interface.
 boolean canPlayBothSides()
          This default implementation always returns false.
protected  int[] getMinMaxRow()
           
protected  void initNewMoveSearch()
           
protected abstract  boolean jumpFound(Jump j, int min, int max)
           
protected  boolean minMaxFound(int min, int max)
           
protected abstract  boolean putFound(Put p)
           
 Move think(Board position)
          Thinking here.
 
Methods inherited from class de.tabacha.cgo.AbstractEngine
getAuthor, getDescription, getI18nProperty, getName, getVersion, initGame, random
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoRecursionTemplate

protected NoRecursionTemplate()
Constructor.

Method Detail

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()