The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Games::Trackword - find words on a Trackword grid.

SYNOPSIS

  use Games::Trackword;

  my $board = Games::Trackword->new('TRA WKC ORD');

  foreach my $word (@wordlist) {
    print "OK $word\n" if $board->has_word($word);
  }

DESCRIPTION

This module lets you set up a Trackword grid and query whether or not it is possible to find words on that grid.

Similar to Boggle, but not restricted by the size of the grid.

METHODS

new
  my $board = Games::Trackword->new('TRA WKC ORD');

  # TRA
  # WKC
  # ORD

You initialize the board with a series of letter blocks representing the letters that are shown on the grid. Spaces (or non alphabetics) may be inserted to make the board string more readable.

Grids bigger than 3x3, are simply represented by long strings separated by spaces:

  my $board4 = Games::Trackword->new('TRAC ROWK DTR WKCA');
  my $board5 = Games::Trackword->new('TRACK TDROW RACKW RTDRO ACKWO');
qu
  $board->qu();  # Boggle rules
  $board->qu(0);  # Trackword rules (default)

Use if 'Qu' should be represented as a 'Q' (as per Boggle). In this instance words containing the letter Q should be entered in full ('Queen', rather than 'qeen'). Note that in Boggle words containing a 'Q' not immediately followed by a 'U' are never playable.

has_word
  print "OK $word\n" if $board->has_word('tithe');
  print "NOT OK $word\n" unless $board->has_word('queen');

Given any word, we return whether or not that word can be found on the board following the normal rules of Trackword (and Boggle).

BUGS & ENHANCEMENTS

By its very nature the size of grid is the only limiting factor of this module. If you can create a grid that is too large to fit in memory, the author recommends that you not to do that!

If you think you've found a bug or would have a suggestion for an enhancement to the current code, send details and patches (if you have one) to <modules@missbarbell.co.uk>.

ACKNOWLEDGEMENTS

The original idea for this came from my disappointment that Tony Bowden's Games::Boggle module couldn't handle Trackword style grids (typically 3x3) and bigger, and also forced the use of Qu rather Q & U. Much of the code here steals from Tony's module.

See Games::Boggle if you want a traditional Boggle rules module.

AUTHOR

Barbie, <barbie@cpan.org> for Miss Barbell Productions http://www.missbarbell.co.uk.

COPYRIGHT

  Copyright (C) 2003 Barbie for Miss Barbell Productions
  All Rights Reserved.

  This module is free software; you can redistribute it and/or 
  modify it under the same terms as Perl itself.