ai.alphabeta
Class AlphaBeta

java.lang.Object
  |
  +--ai.alphabeta.AlphaBeta
All Implemented Interfaces:
GameInterface

public class AlphaBeta
extends java.lang.Object
implements GameInterface

A class for alpha-beta searching.

Will return the best move for given situation and player, as calculated by the alpha-beta search algorithm with given search depth.

Version:
$Revision: 1.0.1, 2003-09-18 $
Author:
Peter Larsson

Fields inherited from interface ai.alphabeta.GameInterface
BLACK, COLUMNS, EMPTY, EVEN, PLAYERSTRINGS, ROWS, WHITE
 
Constructor Summary
AlphaBeta(int player)
           
AlphaBeta(int player, int depth)
           
 
Method Summary
static java.lang.Object getBestMove(NodeModel node, int player, int alpha, int beta, int depth)
          Returns the best move for given situation and player, as calculated by the alpha-beta search algorithm with given search depth.
static java.lang.Object search(NodeModel node, int player, int alpha, int beta, int depth, boolean first)
          Returns the best move for given situation and player, as calculated by the alpha-beta search algorithm with given search depth.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlphaBeta

public AlphaBeta(int player)

AlphaBeta

public AlphaBeta(int player,
                 int depth)
Method Detail

getBestMove

public static java.lang.Object getBestMove(NodeModel node,
                                           int player,
                                           int alpha,
                                           int beta,
                                           int depth)
Returns the best move for given situation and player, as calculated by the alpha-beta search algorithm with given search depth.
Parameters:
node - The Node Model for the Game
player - player in turn
alpha - best score for black (maximizer) along the path to state
beta - best score for white (minimizer) along the path to state
depth - maximum recursion depth
Returns:
Returns the bestMove or null if no move is found

search

public static java.lang.Object search(NodeModel node,
                                      int player,
                                      int alpha,
                                      int beta,
                                      int depth,
                                      boolean first)
Returns the best move for given situation and player, as calculated by the alpha-beta search algorithm with given search depth.
Parameters:
node - The Node Model for the Game
player - player in turn
alpha - best score for black (maximizer) along the path to state
beta - best score for white (minimizer) along the path to state
depth - maximum recursion depth
first - use false to return the score for the best move instead of the move itself
Returns:
Returns the bestMove or null if no move is found