NAME
Game::Backgammon::Bot - the backgammon opponent
SYNOPSIS
my $bot = Game::Backgammon::Bot->new(level => 3);
my $turn = $bot->choose($game);
$game->play($turn) if $turn;
DESCRIPTION
One ply over the legal turns, scoring the position each reaches: pip advantage, checkers off and on the bar, made points, the longest prime, an anchor in the opponent's home board, and blot exposure.
Backgammon does not reward depth. Past this turn the dice are unknown, so a second ply averages over rolls rather than reading a line, and the branching is already in the hundreds on a double.
Bounded in work, not in time
choose scores each legal turn exactly once, so the cost is a property of the position. A bot inside a transaction on a busy server does the same work and picks the same turn as one on an idle server. Ties break on the turn's notation rather than on enumeration order, so the answer is stable.
Levels
Lower levels are ignorant rather than shallow, which is what makes them beatable in a way a person can feel.
3 everything, including blot exposure.
2 shape but not blots, so it leaves shots a person will punish.
1 the pip count alone: a pure running game.
SEE ALSO
Game::Backgammon::Shots for the hit-probability table and what it ignores.
METHODS
level
1, 2 or 3.
knows_blots, knows_shape
What this level is allowed to take into account.
choose($game)
The turn it would play, or undef when the game offers none.
score($board, $player)
The position from that player's side; higher is better for them.
blot_exposure($board, $player)
The total risk that player is carrying: for each of their blots, the worst single shot bearing on it.