The purpose of this project is to demonstate how to solve word puzzles like Scrabble, Words with Friends or crosswords using Javascript. It's no Deep Blue, but it should be able to beat just about any human at Scrabble or Words with Friends.
Game Type:
Instructions
To start the game, enter each of the letters you possess in your hand into the input boxes on the right side of the page and click the suggest button and it will recomment some opening plays. Click on each one to see the recommended placement. To get suggestions for a game in progress, enter the letters that have been played so far onto the board spaces, enter your hand and click suggest.
Key
Double Word
Triple Word
Double Letter
Triple Letter
Start Position
Board
Hand
How Does it Work?
The bot iterates through each space on the board and treats it as a potential starting position for words, both horizontally and vertically.
It looks at the spaces to the right of the word and below it to determine a pattern for the potential words to follow. For example, if the space immediately to the right of the starting position is a "T" and the starting position is 4 away from the edge of the board, the pattern would be " T ".
It then loops through a list of 113,000 valid English words to determine if any of them can be spelled using the letters in the given pattern, filling in any of the blanks with letters in the hand and returns a list of candidates.
It then checks all of the adjacent words formed (if any) to verify each of them are valid.
Finally it scores the primary word and each adjacent word, taking bonus spaces into consideration and returns a total score for each potential play.
The list of potential plays is sorted by total points and the top 10 picks are returned to the player.