NAME
Game::Checkers::Notation - moves, positions and games as text
VERSION
Version 0.01
SYNOPSIS
use Game::Checkers::Notation;
my $parsed = Game::Checkers::Notation::parse_move('23x14x7');
my $fen = Game::Checkers::Notation::fen_from_position($position, 'black');
my ($position, $turn) = Game::Checkers::Notation::position_from_fen($fen);
my $game = Game::Checkers::Notation::parse_pdn($text);
DESCRIPTION
Three notations, all of them text and none of them aware of the rules. Nothing here decides whether a move is legal: that is "move" in Game::Checkers, which resolves a parsed move against the legal list and is the only thing that can, because 23x7 names one sequence in one position and two in another.
Moves
Standard numeric notation. A simple move is 11-15. A jump is 23x14x7, the whole path, and the short form 23x7 is accepted on input but never emitted.
A square may also be written as its algebraic name, f6-e5 and c3xe5xg7, which is what Game::Checkers::Terminal reads and writes because the board it draws has files and ranks on it and no numbers. The two spellings do not mix inside one move. Numeric notation is what PDN stores, so "format_move" emits it and "format_coord_move" is the display form.
FEN
A position and the side to move, as B:W21,22,23:B1,2,K3: the side to move, then the White pieces, then the Black, with K marking a king. Squares are emitted in ascending order within each colour so the string is stable and two positions compare as strings.
A FEN is a position, not a game. It carries neither the repetition history nor the no progress counter, and both of those decide draws, so a game restored from a FEN alone can reach a different verdict than the game it came from. Use PDN for a game.
PDN
The seven standard tags, then the movetext, then a result token. Comments in braces and after a semicolon are parsed and discarded; a comment is never emitted.
FUNCTIONS
parse_move
Parses one move, returning { from, to, squares, jump } or undef when the string is not a move. The squares come back as numbers whichever spelling was given. Whitespace is ignored and x and a file letter may be upper case. A square outside 1 to 32, a name that is not a playing square, the same square twice in a row, or the two spellings in one move, is not a move.
Game::Checkers::Notation::parse_move('11-15');
Game::Checkers::Notation::parse_move(' 23 x 14 x 7 ');
Game::Checkers::Notation::parse_move('f6-e5'); # squares [11, 15]
format_move
The notation for a Game::Checkers::Move or for a hashref as "parse_move" returns.
Game::Checkers::Notation::format_move($move); # '23x14x7'
format_coord_move
The same move with its squares named by file and rank.
Game::Checkers::Notation::format_coord_move($move); # 'e3xc5xe7'
fen_from_position
The FEN for a position arrayref and the side to move.
Game::Checkers::Notation::fen_from_position($position, 'black');
position_from_fen
Returns the position arrayref and the side to move. Dies on a malformed string: a missing piece list, a square outside 1 to 32, the same square twice, or a colour other than B or W. Pass strict => 1 to refuse more than twelve pieces of a colour, which an ordinary game cannot have but a composed problem can.
my ($position, $turn) = Game::Checkers::Notation::position_from_fen($fen);
parse_pdn
Parses a PDN game into { tags, moves, result }, where moves is the notation of each move in order. Dies on a token that is neither a move number nor a move. The moves are not checked against the rules here; "from_pdn" in Game::Checkers replays them and refuses the first one that is illegal.
my $game = Game::Checkers::Notation::parse_pdn($text);
format_pdn
Emits { tags, moves, result } as PDN: the seven standard tags in their usual order with ? for anything missing, then FEN and SetUp when present, then any other tags sorted, then the movetext wrapped at 79 columns and the result.
my $text = Game::Checkers::Notation::format_pdn($game);
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-game-checkers at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-Checkers. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Game::Checkers
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)