The question is mainly "how to create a grid of good for the game" Boggle "with a lot of words" where good is defined as containing many words of 5 or more letters.
Boggle - a game in which you roll dice with letters on them, they are placed in a 4x4 grid. Example:
HSAV ENIS KRGI SOLA
Words can be made by joining letters horizontally, vertically or diagonally. In the above table you can make good words "VANISHERS", "VANISHER", "KNAVISH", "ALIGNERS", "SAVINGS", "SINKERS" and about 271 other words depending on the dictionary are used, for example, "AS", " I "," AIR "," SIN "," IS ", etc.
Like a bad example of this grid
OVWC TKZO YNJH DEIE
has only ~ 44 words, of which only 2 letters are> 4 letters long. "TYNED" and "HINKY".
There are many similar questions , but AFAICT is not this exact question. This is, of course, a link to Scramble with Friends.
The first solution, collecting letters at random, has a problem: if you accidentally chose all the consonants, there will be no words. Adding a few random vowels is not enough to guarantee a good set of words. You can only get from 1 to 4 alphabetic words, while a good algorithm will choose a set of letters that contain> 200 words with many words> 7 letters.
I am open to any algorithm. Obviously, I could write code to solve brute force by finding all possible grids, and then sort them by grids using most words, but this simple solution will start forever.
I can imagine various heuristics, for example, choosing a long word (8-16 letters), placing these letters in a grid at random, but in such a way that it can actually make a word and then fill the left spaces. I suspect this is not enough to guarantee a good set of words, although I have not tried it yet.
Perhaps the solution requires pre-processing the dictionary in order to know the common parts of the words. For example, all words that end with the words "ing" or "ers" or "ght" or "tion" or "land". Or somehow arrange them in a graph of common letters. Maybe weighing certain sets of letters, so "ing" or "ers" are often inserted.
Ideas?