NAME
Game::Reversi::Notation - squares, boards and transcripts as text
VERSION
Version 0.01
SYNOPSIS
Game::Reversi::Notation->text_to_square('f5'); # 29
Game::Reversi::Notation->square_to_text(29); # 'f5'
my $squares = Game::Reversi::Notation->parse('f5d6c3d3c4');
my $steps = Game::Reversi::Notation->walk($board, 'b', $squares);
DESCRIPTION
What is standard and what is ours
Standard. The square. Files a to h, ranks 1 to 8, so f5. And the transcript: those squares concatenated with no separator, f5d6c3d3c4, which is the form published games and WTHOR records use. This distribution adopts both rather than inventing its own, so that a transcript from anywhere can be read here.
Ours. How a pass is written, --, and only because something has to be written when a pass must be shown. Sources differ and most transcripts omit passes entirely, since a pass is forced and can be recovered from the position.
Passes are recomputed, never trusted
"parse" discards any pass written into a transcript and "walk" puts the passes back by asking the position. A written pass that disagreed with the rules would otherwise be believed.
This matters more than it sounds. A transcript carries squares and no colours, so which player made each move depends entirely on how many turns were forfeited earlier. A reader that assumes the colours alternate will misattribute every move after the first pass, and will do it silently: the moves stay legal-looking and the game still replays, but to the wrong position and the wrong score.
METHODS
square_to_text, text_to_square
One square, both ways. text_to_square returns undef for anything that is not a square, so a caller can tell a bad square from square 0.
parse
The squares of a transcript, in order. Accepts the concatenated standard form and tolerates separators. Written passes are accepted and discarded. Dies on anything it cannot read.
render
Squares back to a concatenated transcript.
render_with_passes
Steps from "walk" rendered with their passes shown.
walk
Replays squares over a board, inserting the forced passes, and returns a step per move: colour, square, flips, passes and the resulting board. Dies on a square that is not legal for whoever is to move, and on a transcript that runs past the end of the game.
board_to_text, text_to_board
A board as eight lines of eight characters, . for empty, and back. The grid only, with no coordinates, so that the two are exact inverses.
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.