Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Solver for Scramble by Zynga

0.00/5 (No votes)
27 Nov 2008 1  
Program to automatically list all the possible words in the game Scramble on Facebook
Scramblegame.jpg

Introduction

This is basically a program to cheat at the Scramble word game located on Facebook. It also contains the option to play the Word Twist Game as well.

The scramble game is just a square board with letters on it. You have to find as many words as possible in three minutes. You can start with any letter, but you can only move to another letter that is touching or diagonal to the current letter.  You also can't use the same letter more than once for each word.

Background

This was an interesting program to write. The first challenge to overcome was coming up with a list of possible words, or a dictionary as I called it. I ended up stripping off all the words from an online crossword dictionary which I think the Scramble program itself used to display the definitions of the words. It showed only fifty words per page, and there were over 2000 pages. It took about 35 minutes to download all 105,000 words, and it crashed Visual Studio when I tried to paste all 105,000 lines of code into my class file. I ended up using Notepad++ to create the file, then added it to the project.

The second challenge was trying to come up with an efficient way of organizing the board to search through the possible paths. I first created a 2 dimensional array of the board, with each item in the array containing its letter, and a list of all squares that it touches. Then I loop through each square, finding all words that start with that square.

This is achieved by first finding all the possible ways to create a word with a length of 3 (not caring if it is a valid word or not at this point).  If the word is a valid word in the dictionary, it is added to a list of found words.  If it could be the start of a longer word, it searches for all other letters that it touches to see if there are other valid words or starts to valid words. It repeats this process to find all the words on the board.

Using the Code

Scramble.jpg

When you first start up the program, it takes about 10-15 seconds to load up the entire dictionary into memory. Once it loads, use the left hand Textbox for typing in the board. You can type in any size board you'd like as long as it is square. The game on Facebook only contains 4x4 and a 5x5 games.

After you have the board entered, push the "Go" button and all the possible words are either listed in the list box, or are copied one at a time to your clipboard, one each second, depending  whether or not the "Use Clipboard" checkbox is checked or not.

Points of Interest

There is nothing too amazing about the code itself, only that it has a class with 105000 lines of code. I'm sure there is a better way to do this, but for a fun project like this, I really didn't care.

I was able to score 1553 points using this program, which is 1400 points more than any of my friends on Facebook. So funny.

History

  • 27th November, 2008: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here