NAME
Game::Brandubh::Bot - a program that plays brandubh, at three strengths
VERSION
Version 0.01
SYNOPSIS
use Game::Brandubh;
use Game::Brandubh::Bot;
my $game = Game::Brandubh->new;
until ($game->status eq 'finished') {
my $move = Game::Brandubh::Bot->choose($game, seed => $thirty_two_bytes);
$game->play($move);
}
my $better = Game::Brandubh::Bot->hint($game);
DESCRIPTION
Chooses a move for whichever side is to move. It is "search" in Game::Brandubh with levels of play on top, and it holds nothing: every method is called on the class, and the game is the only state there is.
A level is a number of positions
How strong the program plays is how many positions it may look at before it chooses: 1,000, 10,000 or 100,000. It is never a number of seconds. The same game, level and seed give the same move every time, on a busy machine as on an idle one, so a game against the program can be played again move for move.
The weakest level also plays a move picked without thought one time in five. A program that only looks less far ahead is still a careful player; this one is meant to be beaten by somebody learning the game.
The seed
seed is any string, and in practice the thirty-two bytes a game was made with. From it the program draws which level to play, when no level is given, and which of several equally good moves to choose. Two programs given different seeds do not play the same game. A program given none always plays the same way.
VARIABLES
@LADDER
The levels a seed draws from, weakest first. A level that appears twice is drawn twice as often.
%SLIP
For each level, out of a hundred, how often a move is picked without thought.
$LEVEL
When set, the level every call plays at unless it is given one. For tests.
METHODS
choose
my $move = Game::Brandubh::Bot->choose($game);
my $move = Game::Brandubh::Bot->choose($game, seed => $bytes, level => 10_000);
A move for the side to move, as it is stored, or undef when the game is finished. The game is not changed.
seed-
See "The seed".
level-
How many positions to look at. When left out it is
$LEVELif that is set, and otherwise the level the seed draws. slip-
Out of a hundred, how often to pick a move without thought. The level's own figure when left out.
weights-
Passed to the search: see "weights" in Game::Brandubh::Rules. For measuring the program, not for playing against it.
Croaks when it is not given a game, or is given a level that is not a whole number.
think
my $thought = Game::Brandubh::Bot->think($game, seed => $bytes);
choose, with its working shown. Takes what choose takes and returns a hash reference, or undef when the game is finished: move; level, the level it played at; slipped, true when the move was picked without thought; and, when it was not, depth, nodes and score as "search" in Game::Brandubh reports them.
hint
my $move = Game::Brandubh::Bot->hint($game);
The move the strongest level would choose, with no slip.
level_for
my $level = Game::Brandubh::Bot->level_for($seed);
The level a seed draws from @LADDER. The same seed always draws the same level. With no seed, the middle of the ladder.
slip_for
my $percent = Game::Brandubh::Bot->slip_for($level);
How often that level picks a move without thought, out of a hundred.
levels
my @levels = Game::Brandubh::Bot->levels;
The different levels there are, weakest first.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)