NAME

Game::Dominoes::Notation - tiles, plays and whole hands as text

VERSION

Version 0.01

SYNOPSIS

use Game::Dominoes::Notation qw(parse_move to_text from_text to_layout);

to_text([ $play, $another ]);        # '5-5@L* 5-2@L'
from_text('5-5@L* 5-2@L D2 P |');    # the moves, as hashrefs
my $layout = to_layout('5-5@L* 5-2@L');

DESCRIPTION

There is no published standard notation for dominoes, the way chess has PGN and draughts has PDN. The notation here is this distribution's own invention. It is written down and kept stable, but it is not an authority and nothing outside this distribution is obliged to read it.

The grammar

6-4      a tile, higher face first
6-4@L    a play: that tile on arm L
6-6@L*   a play that made the spinner
D        a draw from the boneyard
D3       three draws in one turn
P        a pass
|        the end of a hand

Tokens are separated by whitespace. Arms are L and R along the main line and U and D off the spinner, as Game::Dominoes::Layout names them.

Text is the fixture format on purpose

A diff of ordered text is readable, and there is no hash-ordering trap to sort around. There is no JSON fixture in this distribution: decoded JSON has no order, and a test that depends on one fails about one run in five.

FUNCTIONS

tile_text, parse_tile

tile_text($tile);      # '6-4'
parse_tile('6-4');     # a Game::Dominoes::Tile

One tile. parse_tile accepts the faces in either order and dies on anything that is not two faces from 0 to 6.

move_text, parse_move

move_text($play);        # '5-5@L*'
parse_move('D3');        # { kind => 'draw', count => 3 }

One move. move_text takes a Game::Dominoes::Play or a hashref in the same shape. parse_move returns a hashref whose kind is play, draw, pass or hand_end.

to_text, from_text

to_text(\@moves);                     # a line of tokens
from_text('5-5@L* 5-2@L D2 P |');     # an arrayref of move hashrefs

A whole sequence. from_text on empty or undefined text gives an empty arrayref rather than dying, because a hand with no moves yet is not an error.

to_layout

my $layout = to_layout('5-5@L* 5-2@L 5-3@R');

Replays the plays onto a fresh Game::Dominoes::Layout, ignoring draws and passes, which change a hand and not the table.

This is for drawing a diagram. It is not enough to restore a game from: the text carries neither the hands nor the boneyard order, and both of those decide the result. The move log is the canonical serialisation, and a position never is.

SEE ALSO

Game::Dominoes::Layout, whose arms this names; Game::Dominoes::Play, what a play token comes from.

AUTHOR

LNATION <email@lnation.org>

BUGS

Please report any bugs or feature requests to bug-game-dominoes at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-Dominoes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Game::Dominoes::Notation

ACKNOWLEDGEMENTS

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)