NAME

Game::Senet::Rules - a game of Senet as a position and how it changes, given rolls

VERSION

Version 0.02

SYNOPSIS

use Game::Senet::Rules;

my $game = Game::Senet::Rules->new(rules => 'kendall');
my @moves = $game->moves(3);
@moves ? $game->apply($moves[0]) : $game->forfeit(3);
print $game->side, " to move\n";
$game->undo;

DESCRIPTION

A position and the rules it is played under, and what a move or a forfeit does to it. The rolls come from outside: this class holds no seed and throws no sticks, and it does not ask whether a move it is handed is one moves listed. Game::Senet is the game a player plays; this is what it plays it on.

Whose turn it is afterwards is the engine's to say and is read, never worked out here: a roll of 1, 4 or 5 keeps the side to move whatever was done with it, and a 2 or 3 passes it.

CONSTRUCTOR

new

my $game = Game::Senet::Rules->new(rules => 'skyruk');
my $game = Game::Senet::Rules->new(rules => 'kendall', first => 'dark');
my $game = Game::Senet::Rules->new(rules => 'kendall', position => $string);

rules is a rule set as "rules" in Game::Senet::Engine takes one, kendall when not given. Without a position the game starts with the pieces interleaved on the first houses, dark on the odd and light on the even, and first, light or dark, to move: light unless told. A position, a position string, croaks when its number of pieces a side is not the rule set's.

METHODS

rules

The rule set as a hash, a copy.

side

light or dark: whose throw it is.

only

The house whose piece alone the next throw may move, or 0. Under skyruk a piece that arrives on house 26 is thrown for again, and that throw is its own.

ply

Moves and forfeits made, the starting position's included.

position

The position string.

key

The position's key, sixteen hex characters.

board

A copy of the board, a Game::Senet::Engine.

home

my $n = $game->home('light');

How many of a side's pieces have borne off.

protected

in_blockade

print "protected\n" if $game->protected(12);

Whether the piece on a house cannot be swapped, and whether it is part of a blockade, under this game's rules. See "protected" in Game::Senet::Engine.

status

ongoing, won or drawn.

how

home when a side has borne off every piece, ply_cap for the draw at the ply cap, undef while the game goes on.

winner

light, dark, or undef.

is_over

True when the game has ended.

moves

my @moves = $game->moves($roll);

What a roll allows the side to move, as Game::Senet::Moves, honouring only. None once the game is over.

apply

$game->apply($move) or die "not applied";

Makes a move and returns it, or returns undef without changing anything when the game is over, the move is the other side's, or only names another house.

forfeit

$game->forfeit($roll);

A throw that allows nothing. The roll is needed, because a forfeit on a 1, 4 or 5 keeps the turn. Returns 0 once the game is over.

undo

Takes back the last move or forfeit, only with it. 0 when there is nothing to take back.

depth

How many moves and forfeits there are to take back.

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)