NAME

Game::RoyalUr::Variant - a rule set of the Royal Game of Ur, as a value

VERSION

Version 0.01

SYNOPSIS

use Game::RoyalUr::Variant;

my $finkel  = Game::RoyalUr::Variant->named('finkel');
my $masters = Game::RoyalUr::Variant->named('masters');

my $own = Game::RoyalUr::Variant->custom(route => 'long', safe_rosettes => 1);
print $own->name // $own->describe, "\n";

my $game = Game::RoyalUr->new(seed => $seed, rules => $masters);

DESCRIPTION

Nobody knows how the Royal Game of Ur was played. The board survives and the rules do not, so every set of rules is somebody's reconstruction, and they differ. A variant is one such set, as five values. It is read and never changed.

The two named sets

finkel

The rules Irving Finkel of the British Museum proposed, and the ones most people have met. Seven pieces a side and four dice; a throw with nothing marked moves nothing. A piece follows the short route: four squares of its own, the eight of the middle row, and two more of its own. A piece standing on a rosette cannot be captured.

masters

The rules James Masters proposed. Seven pieces a side and three dice; a throw with nothing marked is worth four. A piece follows the long route, which leaves the middle row a square early, runs round the far end of the board through the other side's row, and comes home from the other direction, so that every fourth step is a rosette and nothing past the first four squares is safe. No rosette protects the piece on it.

Landing on a rosette earns another roll under both, and a piece leaves the board only on the exact roll under both.

The five fields

route

'short', fourteen steps, or 'long', sixteen.

dice

3 or 4.

zero_rolls

What a throw with no die marked is worth: 0 or 4.

safe_rosettes

1 when a piece standing on a rosette cannot be captured, 0 when it can.

pieces

How many a side has, 1 to 7.

Any combination is a rule set that can be played. Only the two above have names.

METHODS

new

my $variant = Game::RoyalUr::Variant->new(route => 'long', dice => 3);

A variant with the fields given, and finkel's for the rest. Croaks on a value a field may not hold.

A key that is not one of the five is not noticed here. Use custom, which refuses one.

named

my $variant = Game::RoyalUr::Variant->named('masters');

One of the named sets. Croaks, listing the names, on anything else.

custom

my $variant = Game::RoyalUr::Variant->custom(pieces => 5);

As new, and croaks on a key that is not one of the five, so that a misspelt rule cannot quietly play the standard game.

of

my $variant = Game::RoyalUr::Variant->of($rules);

A variant from whatever a caller has: undef is finkel, a name is the set of that name, a hash reference is handed to custom, and a variant is returned as it is.

names

The names of the named sets, sorted.

fields

The names of the five fields, in the order they are always written.

route

dice

zero_rolls

safe_rosettes

pieces

The five fields. See "The five fields".

name

'finkel' or 'masters' when the five values are those of a named set, however the variant was made, and undef when they are not.

describe

route=long dice=4 zero_rolls=0 safe_rosettes=1 pieces=7

The five fields spelled out, in order, on one line.

as_hash

The five fields as a new hash reference.

equals

$one->equals($other)

True when the other is a variant with the same five values.

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)