Writing this thing was fun but not as easy as first thought. Or to be more accurate doing it so that it was fast enough to play was difficult. The SOWPODS word list is very large, 2.8MB of text, which takes an appreciable time to load into the application even before processing begins. Many words are greater than 9 letters so since this game only deals with words of 9 letters or less the word list can be made smaller without affecting the game at all.
Calculating the solution for a random word and key letter was an interesting problem. At first it seems easy. The method is fairly well-known and involves sorting every word in the word list, sorting every possible word from the puzzle word and looking for the intersection. First problem - using arrays for this is very slow since looking for the word can involve hundreds of thousands of comparisons and that task is multiplied by the number of words in the dictionary. Second problem, if "LILT" is a word in the solution then so is "TILL" - you can't just stop looking after the first match. The advantage of calculating the whole solution in a background thread is that once done the complete solution is available at any time and it makes response better when checking words as they are built letter-by-letter.
No comments:
Post a Comment