WordFind - Class for generating Word Find type puzzles
use Games::WordFind;
$puz=Games::WordFind->new({cols=>10});
@words=qw(perl camel llama linux great);
$puz->create_puzzle(@words);
print $puz->get_plain();
or,
print $puz->get_latex();
This module simply provides a class which can be
used to generate WordFind type puzzles. It is simple
to use, the relevant methods are:
- $puzzle = Games::WordFind->new({OPTIONS});
-
Returns a WordFind object with a default size of 10x10.
- OPTIONS:
- cols => N
Sets the matrice size to N x N for the new puzzle.
- intersect => 1
Sets the intersect flag to allow words to intersect (share letters)
in the puzzle (default is off).
- only => [directions]
Allows you to specify a set of directions for words to follow; the
directions are given in compass form: n s e w nw ne se sw. For example
using only => [qw/e se ne/] will only allow words to be placed
in the puzzle in left-right orientation.
- no => [directions]
Alternative to the above --- allows you to specify certain directions
to be disallowed. If both only and no are given, only the former
is recognized.
- $puzzle->
create_puzzle(LIST)
-
This method takes the LIST of words and creates the puzzle. Any
words which are longer than the number of columns in the puzzle
are dropped from the wordlist and a warning is issued. This
method will return references to three arrays; a two dimensional
array of the puzzle, an array of the words used, and a two
dimensional array of the puzzle solution. These are so you can
format your puzzle output yourself rather than using the latex or
html formatting functions described next.
- $puzzle->get_plain({solution => 1})
-
This method gets the puzzle and its solution matrix
in a plain text format. If you supply the optional
hash reference with a non-zero value for 'solution',
a solution matrix is included immediately following
the puzzle.
- $puzzle->get_latex({solution => 1, wrapper => 1})
-
This method creates a latex formatted version of the puzzle
containing tabular environments to set the puzzle and solution (a
newpage separates the two). The optional hash argument can
contain the key 'wrapper' which tells the method to return the
puzzle wrapped with a latex preamble, and the key 'solution'
which will return the solution matrix after a
\newpage command
in the latex source.
- $puzzle->get_html({solution =>1, wrapper =>1})
-
Similar to the latex method, though, of course, there is no
newpage separation of the solution.
Andrew L Johnson <ajohnson@cpan.org>
WordFind.pm and wordfind.pl are copyright (c) 1997-2002 Andrew L
Johnson. This is free software and you may redistribute it and/or
modify it under the same terms as Perl itself.
Rob Duarte submitted patches that eventually led to the only
and no options.
perl(1).