NAME

Graph::Maker::TowerOfLondon - create tower of London puzzle graph

SYNOPSIS

use Graph::Maker::TowerOfLondon;
$graph = Graph::Maker->new ('tower_of_london', balls => 3);

DESCRIPTION

Graph::Maker::TowerOfLondon creates a Graph.pm graph of configurations occurring in the tower of London puzzle.

The tower of London puzzle has 3 spindles which can hold at most 1,2,3 balls respectively. 3 balls are in some arrangement on the spindles. The aim is to go from one specified configuration to another.

Each graph vertex is a configuration of balls on spindles. Each edge is a legal move from one configuration to another. A legal move is to take the top ball from any spindle and move it to the top of another, provided it fits in the capacity of the destination (1,2,3 for spindle numbers 1,2,3 respectively).

Spindles

Option spindles => S specifies how many spindles are used for the puzzle. The default is 3 as described above. For S spindles and N balls the vertices are numbered ...

Spindles=1 is allowed but is a trivial 1-vertex graph since all balls are on that spindle and no moves are possible.

Spindles=2 is allowed but is 2^N vertices in pairs since only the smallest ball can ever move.

Balls=1 is always a complete-S graph since the single ball can move from anywhere to anywhere.

Balls >= 2 has complete-S sub-graphs which are one of the balls moving around anywhere. Connections between those subgraphs ...

FUNCTIONS

$graph = Graph::Maker->new('tower_of_london', key => value, ...)

The key/value parameters are

balls     =>  integer
spindles  =>  integer, default 3
adjacency =>  string, default "any"
graph_maker => subr(key=>value) constructor, default Graph->new

adjacency can be

"any"        any moves between spindles permitted
"cyclic"     moves only between spindles in a cycle
"linear"     moves only between spindles in a row
"star"       moves only to or from centre spindle

Other parameters are passed to the constructor, either graph_maker or Graph->new().

If the graph is directed (the default) then edges are added both forward and backward between vertices. Option undirected => 1 creates an undirected graph and for it there is a single edge between vertices.

SEE ALSO

Graph::Maker, Graph::Maker::Complete, Graph::Maker::Cycle, Graph::Maker::Linear

HOME PAGE

http://user42.tuxfamily.org/graph-maker-other/index.html

LICENSE

Copyright 2015, 2016, 2017, 2018, 2019, 2020, 2021 Kevin Ryde

This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with This file. If not, see http://www.gnu.org/licenses/.