NAME

Game::Merrills::Points - the 24 points, the lines between them and the 16 mills

VERSION

Version 0.03

SYNOPSIS

use Game::Merrills::Points;

my $d2 = Game::Merrills::Points::point('d2');      # 19
Game::Merrills::Points::name(19);                  # 'd2'
Game::Merrills::Points::adjacent($d2);             # 16, 18, 20, 22
Game::Merrills::Points::mills_of($d2);             # [18, 19, 20], [16, 19, 22]

DESCRIPTION

The board of Nine Men's Morris is three squares, one inside the next, joined at the middle of each side. Men stand where lines meet or turn, which gives 24 points, 32 lines between neighbouring points, and 16 rows of three that can become a mill.

A point has a number and a name. The numbers run 0 to 23 in reading order from the top of the board, and the names are the usual coordinates, files a to g from the left and ranks 1 to 7 from the bottom:

a7 . . d7 . . g7        0        1        2
.  b6 . d6 . f6 .          3     4     5
.  .  c5 d5 e5 . .            6  7  8
a4 b4 c4 .  e4 f4 g4    9  10 11    12 13 14
.  .  c3 d3 e3 . .            15 16 17
.  b2 . d2 . f2 .          18    19    20
a1 . . d1 . . g1        21       22       23

The centre, d4, is not a point. That is why a4 b4 c4 and e4 f4 g4 are two mills and b4 c4 e4 is none, and the same down the d file.

Every point is in exactly two mills, one across and one down. The twelve corners have two neighbours, the midpoints of the outer and inner squares have three, and the four midpoints of the middle square, d6, b4, f4 and d2, have four.

Nothing here knows whose man is where. See Game::Merrills::Board.

PACKAGE VARIABLES

The tables the functions read are package variables, for code that asks often and would sooner index than call. Treat them as read only.

@NAME

The coordinate of each point.

%POINT

The number of each coordinate, in lower case.

@ROW, @COL

Where each point sits on a seven by seven grid, row 0 at the top and column 0 on the left.

@ADJACENT

For each point, an arrayref of its neighbours in ascending order.

@MILLS

The sixteen mills, each an arrayref of three points. The eight across come first.

@MILLS_OF

For each point, an arrayref of the two mills it belongs to.

FUNCTIONS

None is exported. Every function that takes a point number dies when handed anything that is not one.

all_points

The 24 point numbers, in order.

for my $n (Game::Merrills::Points::all_points()) { ... }

point

The number of a coordinate, or undef when the name is not a point. Case does not matter.

Game::Merrills::Points::point('A7');     # 0
Game::Merrills::Points::point('d4');     # undef

name

The coordinate of a point.

Game::Merrills::Points::name(0);         # 'a7'

row_of

The row of a point, 0 at the top to 6 at the bottom.

Game::Merrills::Points::row_of(0);       # 0

col_of

The column of a point, 0 on the left to 6 on the right.

Game::Merrills::Points::col_of(2);       # 6

adjacent

The neighbours of a point, the points a man standing on it can move to along a line.

Game::Merrills::Points::adjacent(0);     # 1, 9

is_adjacent

True when a line joins the two points.

Game::Merrills::Points::is_adjacent(0, 1);     # 1
Game::Merrills::Points::is_adjacent(0, 2);     # 0

mills

All sixteen mills, each a fresh arrayref of three points.

my @mills = Game::Merrills::Points::mills();

mills_of

The two mills a point belongs to, each a fresh arrayref of three points.

my ($across, $down) = Game::Merrills::Points::mills_of(0);

CONSTANTS

POINTS

24, the number of points.

SIZE

7, the number of files and of ranks.

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)