Word Hunt Solver



Project Description:
• Develop a word finder to beat my younger sister, Chloe, in GamePigeon's Word Hunt game!
• Create a UI with Tkinter for character input and ensure that only valid entries (characters) are accepted
• Generate visualizations with Python's Matplotlib to display the starting point as well as path in order to help users quickly score in the game

Overview:
• The grid for entering characters is shown on the right. To make moving between each box easier, use the left and right arrows to navigate to the next field. Once the curser reaches the last box, it will automatically move to the next line once the right arrow is clicked.

• Orginally, I had a submit button to submit the characters. However, this turned out to be a hinderance since the user had to navigate to the button to press it, which is changed it to use the enter key.

• Once the enter key is pressed, the program validates the input and verifies that there is exactly 1 valid character in each box. If this is not the case, an error message is displayed.

• After processing is complete, the program finds all the words in the grid recursively using Python's nltk library to verify each generated word.

• My initial version of this used a 2D array to store the information. Each recursive call would then need a deepcopy of this 2D array, which took about 6-7 seconds to complete. Since speed is very important in Word Hunt, I replaced this with a string based approach to reduce the processing time to around 0.5 seconds.

• The image on the left shows the result once the program is done finding the longest words. Words are sorted by length to maximize score and a path is shown (along with a green box indicating starting position) to help the user quickly score.

• Toggling between each screen is done using the right and left arrow keys.

• Additional information about the current word is provided at the top of the UI to allow the user to inspect the word quickly and skip if necessary.

• During testing, I found that there were often multiple ways to get the same word. To prevent this from happening, I used a set to ensure that previously entered words would not be added a second time.


Additional Implementation Details
• Each row in the grid is stored one after another in the string. To access a specific value, you would use the following equation: currData[4 * (Row #) + (Column #)]

• Since we also need to keep track of the path taken, the row and column numbers are stored in an additional string, which is shown below.


• The number seen in the second part of each tuple is the path to generate that word. It consists of each row and column number concatenated together.

• In this case, we can just take every 2 digits and convert this to a grid box number. Concatenating all numbers together works since we are working with a small 4x4 grid.

• If this project was implemented on a larger grid (let's say 12x12), the second string would need some kind of deliminiter to help differentiate between single digit and double digit row and column numbers.

Results without using software

As you can see, my results without software tend to be a bit inconsistent

Results using software

Using Software: 5/5 Matches Won and 1 rather disgruntled sister

If you'd like to try this program out, please check out my GitHub repository here.


Copyright© 2024 Lucas Luwa. All Rights Reserved.