NAME
Game::Brandubh::Variant - the rule set a game of brandubh is played under
VERSION
Version 0.01
SYNOPSIS
use Game::Brandubh::Variant;
my $rules = Game::Brandubh::Variant->named('brandubh');
my $house = Game::Brandubh::Variant->custom(repeat => 2, throne_reentry => 1);
print $house->as_string, "\n"; # custom throne_reentry=1,repeat=2
my $same = Game::Brandubh::Variant->from_string($house->as_string);
print "equal\n" if $same->equals($house);
my $game = Game::Brandubh->new(variant => $house);
DESCRIPTION
A value: seven fields that between them say which game of brandubh is being played. It cannot be changed once made. Two with the same fields are equal.
The rules of brandubh were never written down, and every set in use is a reconstruction. This distribution follows one of them by default, described in Game::Brandubh, and each field here is a point at which a table might reasonably play it another way.
Made by named, custom or from_string
Not by new, which croaks. The three constructors check every field's name and value; a misspelt field would otherwise be dropped without a word and the default game played in its place.
Only one set has a name
brandubh is the default, and is the only set this version publishes under a name. The fields that make the other sets are all here and all work, and a set built from them is called custom. A name is a promise that the set has been checked against a written source for that set, and that has been done for one.
FIELDS
Each is also a method that returns its value.
escape-
cornerby default: the king wins on a corner.edge: on any square of the edge. king_everywhere_two-
0 by default. With 1 the king is captured by two attackers like any other piece wherever he stands, the throne included.
king_strong-
0 by default. With 1 the king is captured only when every side of him is closed, by an attacker or by the empty throne, wherever he stands. It contradicts
king_everywhere_two, and a set with both croaks. throne_reentry-
0 by default: once the king has left the throne he may not return.
throne_pass-
1 by default: a piece may slide across the empty throne, though none may stop on it.
repeat-
3 by default: the game is drawn when a position occurs for the third time. A whole number from 2 up.
ply_cap-
400 by default: the game is drawn after this many moves, counting both sides'. A whole number from 1 to 4096.
CONSTANTS
PLY_CAP_MAX
4096, the largest ply_cap.
METHODS
named
my $rules = Game::Brandubh::Variant->named('brandubh');
my $rules = Game::Brandubh::Variant->named;
A published rule set. Croaks on a name that is not one.
custom
my $rules = Game::Brandubh::Variant->custom(%fields);
A rule set from fields, each left out being the default. Croaks on a field that does not exist, on a value the field cannot take, and on a set that contradicts itself. When the fields happen to be exactly those of a published set, the result carries that set's name.
from_string
my $rules = Game::Brandubh::Variant->from_string('custom repeat=2');
A rule set from the string as_string writes. undef for anything else, without dying: the string usually comes from a file somebody else wrote.
as_string
The name of a published set, or custom followed by the fields that differ from the default, field=value with commas between.
as_hash
A hash reference of all seven fields, the form Game::Brandubh::Rules and Game::Brandubh::Engine take.
equals
if ($rules->equals($other)) { ... }
True when the other is a rule set with the same seven fields.
name
brandubh, or custom.
escape
king_everywhere_two
king_strong
throne_reentry
throne_pass
repeat
ply_cap
The value of the field. See "FIELDS".
fields
my @names = Game::Brandubh::Variant->fields;
The names of the seven fields.
names
my @names = Game::Brandubh::Variant->names;
The names of the published sets.
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)