List out the optimum shortest set of words to complete the puzzleĪs usual, I am not the first to attempt this coding project and there is always room for improvement.Detect the 3 tasks required to complete the puzzle with maximum 3 stars.Chop up the tile grid to obtain and detect the scores for each tile.Thereafter, the OCR detected grid is printed for the user to review before proceeding with the rest of the solver codeĪfter I decided that I have achieved sufficiently good results with using OCR to detect the tile grid, I moved on to:.From my tests, I was unable to properly detect the letters P, I and R, so some hardcoded correction was needed.The tile grid is then 'chopped up' to obtain the 16 tiles, then some image pre-processing is applied before attempting OCR.From there a snapshot is taken of the tile grid (pixel coordinates are coded for 1920 by 1080 screen resolution).For convenience, I used pyautogui to search for the hint button as a way to detect if the Wordament game is on-screen.Used the pyautogui library to take screenshots, cv2 and numpy to assist with image processing, and pytessaract for OCR.Finally, output the words found to the terminalĪfter I got the above working, I proceeded to code in some OCR to detect the tile grid automatically:.prefix tiles can only be pathed from but cannot be pathed to, either/or tiles will require two runs, etc) Run the pathing based on user's selection, taking note of special tiles (e.g.Seek user input on whether user wants to search for words using special tiles only, or search for words of specific length, or search for all words.Detect the presence of special tiles (prefix, suffix, either/or, digram, corners).Get user to manually input the letters left to right, top row to bottom row, in space delimited manner.Define a bunch of functions to help with pathing (given any starting point in the grid, go left/right/up/down/etc to as yet unused tiles to form letter sequences and test if they might be valid words).say the code finds a path with letters in the sequence 'XYZ', there is no point pathing further since there are no words that start with 'XYZ') ![]() Prep a set of 'valid' truncated words from the word list (this is used later to decide to stop 'pathing', e.g.Read in a word list (I tried various dictionaries found online and ultimately settled on using a Scrabble word list).The following ideas and approaches were adopted:. My code is designed to work in single-player, and the motivation for this (in addition to the joy of learning to code) is to find those last few pesky 'common words' that Wordament says that I have yet to find. In this way, the solver can calculate all the solutions immediately, without take care about the server limitations or the number of users.This is a coding project that I was most happy with - building a solver that could search for possible words in the Microsoft Wordament game.ĭisclaimer: Of course, do not use such code to cheat in multi-player. Then, at the client side, the Javascript script uses this subset and calculates all the solutions for each word it looks the signs, calculates the score and finds the best way to swipe. This one builds the little subset of words that are writable in the Ruzzle grid. But in this way you have to download all the dictionary, and this will saturate all the available bandwidth of my Web site in few days.įor these reasons, I make a little C++ application that, at the server side, analyzes all the 600.000 words, just in few milliseconds. With a modern computer, with Chrome and its powerful V8, the words are analyzed only in few seconds. On the contrary, with a Javascript algorithm that calculate all the solutions, the things are quite different. If we think that this page can be used by a lot of users, this approach is not good the site will be constantly unreachable. With this big dictionary, a PHP algorithm that analyze all the words can take several seconds. For this reason, I tell you how it works. ![]() This engineering challenge is the main reason that leads me to make this solver. But, is not the same if you do the same thing in a Web site, where a lot of people can use it at the same time. The official dictionary, for example the Italian one, has 600.000 words you can observe that analyze all words is not a thing that can be done fast.Ī little application to do this, in you computer, is simple to do.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |