NAME
Array::Tour::Random - Class for Array Tours.
SYNOPSIS
use Array::Tour::Random qw(:directions);
PREREQUISITES
Perl 5.6 or later. This is the version of perl under which this module was developed.
DESCRIPTION
A simple iterator that will return the coordinates of the next cell if one were to randomly tour a matrix.
Tour Object Methods
new([<attribute> => value, ...])
Creates the object with its attributes. The attributes are:
- dimensions
-
Set the size of the grid:
my $spath1 = Array::Tour->new(dimensions => [16, 16]);
If the grid is going to be square, a single integer is sufficient:
my $spath1 = Array::Tour->new(dimensions => 16);
- start
-
Default value: [0, 0, 0]. Starting point of the random walk.
has_next()
Returns 1 if there is more to the tour, 0 if finished.
next()
Returns an array reference to the next coordinates to use. Returns undef if the iterator is finished.
direction()
Returns the current direction as found in the :directions EXPORT tag. These are the constant values North, West, South, and East.
reset([<attribute> => value, ...])
Return the internal state of the iterator to its original form. Optionally change some of the characteristics using the same parameters found in the new() method.
opposite()
Return a new object that follows the same path as the original object, reversing the inward/outward direction.
describe()
Returns as a hash the attributes of the maze object. The hash may be used to create a new tour object.
dimensions()
Returns the value of the dimensions attribute.
See Also
Games::Maze
AUTHOR
John M. Gamble may be found at <jgamble@cpan.org>