NAME
Game::Mahjong::Notation - the hand strings the tests and the terminal speak
VERSION
Version 0.01
SYNOPSIS
use Game::Mahjong::Notation;
my @ids = Game::Mahjong::Notation::parse('123m 55p EEE');
my $hand = Game::Mahjong::Notation::parse_hand('19m 55p pung(EEE) ckong(4444s) F1');
my $text = Game::Mahjong::Notation::print(@ids); # "123m 55p EEE"
DESCRIPTION
A token is digits followed by a suit letter (123m, 55p, 9s), a run of honour letters (EEE, RGB), or a bonus tile (F1 to F4 the flowers, T1 to T4 the seasons). Tokens are separated by spaces. A meld is its kind around a token: chow(234s), pung(EEE), kong(5555p), and ckong(5555p) for a concealed kong.
The honour letters
E S W N are the winds, R G the red and green dragons, and the white dragon is B, for blank, because W is the west wind.
What it refuses
A rank of zero, a suit letter it does not know, a fifth tile of one kind and a second of one bonus tile all die: a hand of five fives is not a hand, and a test that could write one would pass a vector no wall can deal.
print is canonical
The suits in order, ranks ascending within each, then the honours in table order, then the bonus tiles. parse(print(parse($x))) equals parse($x) for every $x, which is the round trip the tests run.
FUNCTIONS
parse
A string to a list of kind ids, in the order written.
parse_hand
A string with melds to { concealed => [ids], melds => [ { kind, tiles, concealed } ], flowers => [ids] }, each list sorted. The meld entries are plain hashes here; Game::Mahjong::Meld takes them from phase 02.
A list of kind ids to the canonical string.
print_meld
One meld hash to its kind(tiles) token.
print_hand
A hand hash back to a string, concealed tiles first, then the melds, then the flowers.
letters
The honour letter table, for the terminal's help text.
SEE ALSO
Game::Mahjong, Game::Mahjong::Tiles
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.