Wordsearch

Print your own puzzles with Jim Flewker's wordsearch program

 

Issue 23

Sep/Oct 86

Next Article >>

<< Prev Article

 

 

Requires printer.

If you enjoy puzzles, here's a chance to create your own hidden word puzzles for your family and friends, or even your own, puzzlement. The program does require a printer but will work on any 80 column printer.

The program allows you to enter up to 20 words, each of which may be up to fifteen letters, which it then places in a matrix which is 21 characters square. Words may intersect but will not necessarily do so.

As it places the words, the program prints them in normal fashion to the printer and in their placements within the word square on the screen. Once all the words are placed, a hard copy of the solution will first be printed before the rest of the matrix is filled with random letters to produce the familiar word square. You then have the choice of printing the final puzzle or, if you are not happy with the arrangement, re-running the puzzle to place the same words differently. You may repeat this process as often as desired.

ADDITIONAL FACILITIES

As well as printing the standard puzzle, the user has other options.

Clues may be provided to guide the searcher in place of the usual list of words. For example, French words could be used in the puzzle and the searcher could be provided with clues in the forms of their English meanings. Each clue can be up to three lines of text but if you wish to use longer clues you may change the dimensioned length of CLUE$.

The difficulty of the puzzle can be controlled at the beginning of the program by selecting whether words can be placed diagonally or backwards. The default allows words to be placed in any direction although always in a straight line.

In addition to these options, there is no reason why you cannot modify the program further by changing certain key variables. More words could be entered or the program could try more ways to place words. The notes on variables and how the program works should assist.

AtariLister - requires Java

HOW IT WORKS

Inititialisation is from line 10000 wit the main routine between lines 1000 and 3100 with various subroutines preceding the main routine.

Lines 20-30 - Set colour, remove cursor and send to the main set-up routine at....
Lines 10000-10210 - where variables are dimensioned and initialised and user options are provided. We then return to....
Lines 1000-1090 - where you input the words for the puzzle which are put together in a large string. Asterisks are used to demarcate words and the words are crudely sorted on input so that the longest are first.
Lines 1100-1150 - give you the chance to input clues and then....

Lines 1160-1190 draw a frame for the matrix using PLOT and DRAWTO in text mode 0. Then comes a sort of central loop....
Lines 1200-1250 - which split off a word and send it to the subroutine which places it satisfactorily in the matrix. The subroutine in question is at.... 

Lines 400-490 - and is itself almost a hornets' nest of subroutines. Briefly, after a direction and starting point have been decided, the matrix is checked to see if the word will fit. If not, the starting point is changed and the process rapidly repeated, up to 100 times if necessary. When enough spaces are found, the letters of the word (or, more precisely, their ASCII codes) are put in the matrix. and the word is added to the screen. The Atari then goes back for another word. When all words are done, the matrix is printed to the printer and we move to....

Lines 2000-2050 - which fill in all the blanks in the matrix with alphabetic garbage. After which.... 

Lines 2080-2110 - offer the choice of printing the puzzle or trying again.
Lines 2200-2240 - refill the matrix with blank spaces and go back to line 1170 to begin splitting out the words again.

THE SUBROUTINES

Line 50 onwards - a brief way of finding which way to move in the matrix. Uses variables R, L, UP, DOWN which have been set in the Direction routine (lines 500-680).
Line 100 onwards - prints an instruction or status line at the top of the screen, but also either clears the screen or sounds the bell depending on what value the variable HCR is set to.
Line 200 onwards - takes numeric values from MATRIX, which are ASCII codes and turns them into letters on the screen.
Line 300 onwards - chooses starting points quite randomly but checks them with direction and word length (variable LW). Called and then recalled until the word is fitted in.
Line 400 onwards - see above.
Line 500 onwards - DIRection is changed by adding INC. If INC is set to 1 then direction changes by 45 degrees. From this, subroutines set the self-explanatory variables UP, DOWN, R and L

MAIN VARIABLES

MATRIX - a 2-dimensional array whose dimensions correspond to the size of the wordsquare and which holds the ASCII codes of the letters. The dimensions can easily be altered - e.g. width could be increased or reduced. At present the matrix is too wide to be printed on a 1020 printer but you could experiment with a smaller matrix. BIG$ - because the Atari has no arrays of strings, this long string holds all the words to be used. TEMP$ - used as a holding string when manipulating strings, also to input clues.
CLUE$ - holds all clues, separated by CR character (ASCII 155). Increase the DIMensioned length if you want long clues.
WORD$ - used for single words.
HEAD$ - the instruction or status line. Usually 38 characters long.
X - horizontal position in MATRIX and also (with the addition of 9) on screen.
Y - the equivalent for the vertical position. SX and SY - starting positions.
DIR - controls direction of word placement. There are 8 directions in all.
MAX - the value to which DIR can go before it is reset to 1.
INC - the amount by which DIR is increased after each word.
LIMIT - the number of times the Atari will try and place a word before giving up. Important since, in the main, placement is quite randomly decided. LIMIT can easily be Increased if need be.
TRY - counts the attempts to place a word. LEFT (and CLUELEFT) - limits and counts down the words/clues input. Left can easily be increased, up to 30. You would need to make adjustments to BIG$, TEMP$ and perhaps CLUE$. You may also need to adjust LIMIT and HEAD$ if you plan to use many long words.

top