NAME

Games::AlphaBeta - game-tree search with object oriented interface

SYNOPSIS

use Games::AlphaBeta;
my $game = Games::AlphaBeta->new( ... );

while ($game->abmove) {
        print draw($game->peek_pos);
}

DESCRIPTION

Games::AlphaBeta provides a generic implementation of the AlphaBeta game-tree search algorithm (also known as MiniMax search with alpha beta pruning). This algorithm can be used to find the best move at a particular position in any two-player, zero-sum game with perfect information. Examples of such games include Chess, Othello, Connect4, Go, Tic-Tac-Toe and many, many other boardgames.

Users will have to provide references to four callback functions specific to the game they are implementing. These are:

move($position, $move)

Create $newpos as copy of $position and apply $move to it. Return $newpos.

findmoves($position>

Returns a list of all legal moves the current player can perform at the current $position. Note that if a pass move is legal in the game (i.e. as it is in Othello) you must allow for this function to produce a null move. A null move does nothing but pass the turn to the next player.

endofgame($position)

Returns true if $position is the end of the game, false otherwise. Remember to account for a draw in addition to either of the players winning.

evaluate($position)

Returns the calculated fitness value of the current position for the current player. The value must be in the range -99_999 - 99_999 (see BUGS).

METHODS

Most of this module's methods are inherited from Games::Sequential; be sure to check its documentation.

Users must not modify the referred-to values of references returned by any of the below methods, except, of course, indirectly using the supplied callbacks.

Games::AlphaBeta provides these new methods:

4 POD Errors

The following errors were encountered while parsing the POD:

Around line 77:

=over without closing =back

Around line 85:

'=end' without a target? (Should be "=end internal")

Around line 203:

'=end' without a target? (Should be "=end internal")

Around line 238:

'=end' without a target? (Should be "=end internal")