NAME

Game::Checkers::Move - one move, with everything it did

VERSION

Version 0.01

SYNOPSIS

use Game::Checkers::Move;

my $move = Game::Checkers::Move->new(
	from     => 23,
	to       => 7,
	path     => [23, 14, 7],
	captures => [18, 10],
	captured => [1, 1],
	side     => 'white',
);

$move->notation;   # '23x14x7'
$move->is_jump;    # 1

DESCRIPTION

A value object describing one applied or legal move. It carries the whole jump path and every captured piece, so a client can animate a move and "undo" in Game::Checkers can restore the position exactly, without either of them re-deriving anything from the board.

THE RAW MOVE

Game::Checkers::Rules generates moves as unblessed arrayrefs, because the search visits too many of them to bless one each time. The layout is a documented interface and its constants live here:

[ RM_FROM, RM_TO, RM_PROMOTED, RM_PATH, RM_CAPTURES, RM_CAPTURED, RM_KING ]

RM_PATH is the squares landed on including the starting square, RM_CAPTURES the squares the captured pieces stood on in the order they were jumped, RM_CAPTURED their position values so a jumped king comes back a king, and RM_KING whether the piece was already crowned before the move.

PROPERTIES

from

Readonly integer, the square the move starts on.

$move->from;

to

Readonly integer, the square the move ends on.

$move->to;

path

Readonly arrayref of the squares landed on, starting with "from" and ending with "to". A simple move has two entries and a double jump three.

$move->path;

captures

Readonly arrayref of the squares the captured pieces stood on, in the order they were jumped. Empty for a simple move.

$move->captures;

captured

Readonly arrayref of the position values of the captured pieces, in the same order as "captures", so an undo restores a jumped king as a king.

$move->captured;

Readonly boolean, true when the move crowned the moving piece.

$move->promoted;

king

Readonly boolean, true when the moving piece was already crowned before the move.

$move->king;

side

Readonly string, black or white.

$move->side;

FUNCTIONS

from_raw

Class method building a move from the raw arrayref Game::Checkers::Rules generates and the side that made it.

my $move = Game::Checkers::Move->from_raw($raw, 'black');

to_raw

The raw arrayref for this move.

my $raw = $move->to_raw;

is_jump

True when the move captured anything.

$move->is_jump;

notation

The move in standard numeric notation: 11-15 for a simple move and the full path for a jump, 23x14x7. The full path is always emitted, so a stored game is unambiguous when it is replayed, even though the short form 23x7 is accepted on input.

$move->notation;

coord_notation

The same move with each square named by its file and rank, f6-e5 and e3xc5xe7. It is what Game::Checkers::Terminal prints, because the board it draws is lettered and numbered round the edge rather than square by square. A stored game keeps "notation".

$move->coord_notation;

stringify

The same as "notation".

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:

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)