The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Game::TextPatterns::Util - utilities for text pattern generation

SYNOPSIS

  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);

DESCRIPTION

See Game::TextPatterns which uses the provided utility functions. The randomly method might well use these functions via a callback function.

FUNCTIONS

adj_4way point max-col max-row

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.

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.

max-col, max-row are array index values so must be 7,7 for an 8x8 pattern.

adj_8way point max-col max-row

Same as adj_4way only returning points by both compass and diagonal motions.

Known Issues

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.