NAME

Term::Chess::Bot - the opponent: Plisco's search, bounded in nodes

VERSION

Version 0.03

SYNOPSIS

my $uci = Term::Chess::Bot->choose($game, 'p2');    # 'g8f6', or undef
my $try = Term::Chess::Bot->hint($game, 'p1');      # at the top rung

DESCRIPTION

A thin wrapper on Chess::Plisco::Engine::Tree that answers choose($game, $seat) like every other bot in the house.

The budget is a node count drawn from the game's seed, one rung per game, from @LADDER: 2,000, 10,000, 10,000 or 40,000 nodes. The middle rung is there twice on purpose, so it is drawn twice as often. The budget is in nodes and never in seconds, so the same position answers the same on a busy machine as on an idle one, and a game replayed from its seed meets the same opponent.

Setting $Term::Chess::Bot::LEVEL pins every game to one budget instead, which is what a command-line option or a test wants.

A search that fails inside Plisco dies here rather than quietly playing the first legal move, which is how every wiring fault in Plisco's tree otherwise shows itself.

METHODS

ladder

The budgets, in rung order.

level_for

my $nodes = Term::Chess::Bot->level_for($seed);

The budget for a seed: $LEVEL if set, otherwise a rung drawn from the seed.

choose

my $uci = Term::Chess::Bot->choose($game, $seat);

The move the search prefers, as coordinates, or undef when the game is over or the seat is not on move. It does not play the move. In list context it also returns the nodes the search visited and the budget it was given, which is how a test sees that the budget is a budget.

hint

The same, always at the top rung whatever the game drew: somebody asking for help is not asking for a beginner's answer.