Once the word list for the puzzle has been entered, it’s time to generate the puzzle.
I’ve been programming since personal computers were assembled from kits, so the code for the app I use is all homemade. The program has been through many iterations since I first started developing these word searches, changing each time new variations were added. Each puzzle can either be a vanilla word search: words are placed normally or can have special code for a variation ‘injected’ into the generation and publishing code.
We first start by creating an empty grid of the size we want the puzzle to be. We normally start with a 15 x 15 grid, since that’s big enough for most words to fit.
The program than takes the longest word and tries to fit it into the grid.
To optimize this process, we come up with all possible placements for a word of that length. For example, if the word is ten letters long, then there are five ways in a 15 x 15 to place it going left to right in each row and five going right to left. Similarly, there are five ways to place it top down in a column, and five ways to place it bottom up. The diagonals are similar, but there are fewer placements since we need to have at least ten spaces.
With this placement figured out, we then choose one randomly and put the word in.
We then continue the process with the remaining words. The program makes a list of the possible placements and then rejects any where the wrong letters cross. So if a word has an “E” and the grid already has a “D” there, that is not a possible placement.
After discarding the impossibly placements, we then try to pick the placement which overlaps the most other words already placed in the grid. The intention is to make the puzzle as “dense” as possible, with as many letters overlapping as we can. There’s one caveat to that: we don’t want a word to overlap more than one letter of a different word. So if we have the words “GOLDEN” and “ENTANGLE”, we don’t want the “EN” to overlap. We could do that, but it’s easier for the puzzle solver if they don’t.
While we’re doing our insertions, we’re also trying to keep the different placements fairly balanced. That is, if there are six answers appearing left to right in a row, we also want about six going right to left, six going top to bottom, six bottom up and six each on the four diagonals. With 30 answers going in, it’s not possible to have them exactly equal, so we shoot for the count of the fewest in any of the eight directions being no less than two from the most found in the other directions.
If we’re lucky, we make it to the end and we’ve fit all the words in. Usually, when trying to make a tight puzzle, one without too many extra spaces, we discover after putting 25 or so words in that the remaining words can’t be placed. In this case, we pop backwards and try different placements for words. Since we’re choosing our placements randomly, this can make a puzzle take a long time to generate. If it continues to fail, we’ll often stop the process and add a row or column to the puzzle and try again.
Once the puzzle has been generated, it’s time to put in the phrase. In most cases, we start off the puzzle without the hidden phrase in place so we can determine how many empty spaces are in the puzzle where we can put the phrase. If there are too many spaces, that means the grid is too large and we’ll cut off a row or column and generate it again.
When the puzzle has a decent number of blank spaces, usually around 60 characters, we’ll play around with our intended hidden message, rephrasing it until it’s the right length. At times, we can’t get the perfect length, so we’ll regenerate the word search grid so it has a different number of empty spaces.
With the phrase in place, the next step is to validate the puzzle. Using the same placements we used for putting words into the grid, we now go back and make sure that every answer appears exactly once in the puzzle. The puzzle generator should have done a good job of this, but it’s possible that when the phrase was inserted, we inadvertently put in letters which made the same word appear more than once.
Now that the puzzle has been generated and validated, it goes into the database, ready for the publishing step.