Game::TextPatterns::Util - utilities for text pattern generation
use Game::TextPatterns::Util qw(adj_4way adj_8way); my @adj = adj_4way([1,1], 7, 7); my @diags = adj_8way([1,1], 7, 7);
See Game::TextPatterns which uses the provided utility functions. The randomly method might well use these functions via a callback function.
Given a point that is an array reference column, row (x,y) returns the points adjancent by compass motion. Note that error checking is limited in these routines as _fill or such in theory will restrict input points to lie within the bounding box.
column, row
Callers must not assume that the points will be returned in any particular order; use shuffle or rand to pick from the points randomly if necessary.
shuffle
rand
max-col, max-row are array index values so must be 7,7 for an 8x8 pattern.
max-col, max-row
7,7
Same as adj_4way only returning points by both compass and diagonal motions.
Humans are really good at mixing up the col,row (x,y) points with other forms especially given the different orientation of the internal pattern. Favor non-square patterns for tests to better expose such mixups.
To install Game::TextPatterns, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::TextPatterns
CPAN shell
perl -MCPAN -e shell install Game::TextPatterns
For more information on module installation, please visit the detailed CPAN module installation guide.