NAME
Game::Merrills::Move - one whole move: where from, where to, and the man it took
VERSION
Version 0.03
SYNOPSIS
use Game::Merrills::Move;
use Game::Merrills::Points;
my $move = Game::Merrills::Move->new(
from => Game::Merrills::Points::point('d2'),
to => Game::Merrills::Points::point('d3'),
remove => Game::Merrills::Points::point('a1'),
closes => 1,
side => 'white',
);
$move->notation; # 'd2-d3xa1'
$move->is_capture; # 1
$move->is_placement; # 0
DESCRIPTION
A turn in Nine Men's Morris can have up to three parts: the point a man leaves, the point it lands on, and, when landing completes a mill, the enemy man taken off the board. A move here is always the whole turn. There is no such thing as a move that has closed a mill and not yet taken its man, so nothing that holds a move ever has to ask whether the turn is finished.
While men are still being placed there is no point to leave, and from is undef. When no mill is closed there is nothing to take, and remove is undef.
A move records what was done. It does not know whether it is legal.
THE RAW MOVE
Where many moves are made and thrown away, a move travels as a plain arrayref indexed by the RM_ constants below. "from_raw" and "to_raw" convert between the two.
PROPERTIES
All are read only. Points are the numbers of Game::Merrills::Points.
from
The point the man left, or undef when the man came from the hand.
$move->from;
to
The point the man landed on. Every move has one.
$move->to;
remove
The point of the enemy man taken, or undef when no mill was closed.
$move->remove;
closes
How many mills the man completed by landing: 0, 1 or 2. Two mills still take one man. Defaults to 0.
$move->closes;
flew
True when the man moved to a point that is not a neighbour of the one it left, which a side down to three men may do. Defaults to false.
$move->flew;
side
The side that moved, white or black.
$move->side;
METHODS
from_raw
Builds a move from a raw move and the side that made it.
my $move = Game::Merrills::Move->from_raw($raw, 'white');
to_raw
The move as a fresh raw move.
my $raw = $move->to_raw;
is_placement
True when the man came from the hand.
$move->is_placement;
is_capture
True when the move took a man.
$move->is_capture;
notation
The move as it is written down: d2 for a placement, d2-d3 for a move, with xa1 on the end when it took the man on a1. See Game::Merrills::Notation.
$move->notation;
stringify
The same as "notation".
$move->stringify;
CONSTANTS
The indexes of a raw move.
- RM_FROM
-
The point left, or undef.
- RM_TO
-
The point landed on.
- RM_REMOVE
-
The point of the man taken, or undef.
- RM_CLOSES
-
The number of mills completed.
- RM_FLEW
-
True when the man flew.
AUTHOR
LNATION, <email at lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)