Click here to Skip to main content
15,884,388 members
Articles / Desktop Programming / Windows Forms
Article

Solver for Scramble by Zynga

Rate me:
Please Sign up or sign in to vote.
2.67/5 (5 votes)
27 Nov 2008CPOL3 min read 85.3K   1.6K   22   15
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionExactly what I needed. Neat coding, thanks. Pin
Emre201320-Feb-13 16:42
Emre201320-Feb-13 16:42 
GeneralMy vote of 5 Pin
Emre201320-Feb-13 16:08
Emre201320-Feb-13 16:08 
Questionprocess method? Pin
Lhocu21-Nov-11 14:37
Lhocu21-Nov-11 14:37 
AnswerRe: process method? Pin
dlabar21-Nov-11 16:27
dlabar21-Nov-11 16:27 
GeneralRe: process method? Pin
Lhocu24-Nov-11 16:05
Lhocu24-Nov-11 16:05 
GeneralMy vote of 1 Pin
crashandburn531-Oct-11 11:48
crashandburn531-Oct-11 11:48 
GeneralRe: My vote of 1 Pin
Lhocu21-Nov-11 14:41
Lhocu21-Nov-11 14:41 
GeneralWindows XP won't acknowledge this program Pin
Becky Althoff25-Jun-09 11:24
Becky Althoff25-Jun-09 11:24 
QuestionHow do I run this in windows xp? Pin
Matt witt16-Mar-09 17:06
Matt witt16-Mar-09 17:06 
QuestionVB Version? Pin
Member 41501809-Jan-09 8:06
Member 41501809-Jan-09 8:06 
QuestionCan U write in vb.net Pin
rqwe26-Dec-08 11:36
rqwe26-Dec-08 11:36 
GeneralMy vote of 1 Pin
tljy_9725-Dec-08 19:43
tljy_9725-Dec-08 19:43 
Questionwots the deal ? how to install and run the code ? Pin
spice_lover22-Dec-08 13:26
spice_lover22-Dec-08 13:26 
GeneralMissing Resources.rsx Pin
keith.b2-Dec-08 7:32
keith.b2-Dec-08 7:32 
GeneralMy vote of 2 Pin
Gwannoes2-Dec-08 1:42
Gwannoes2-Dec-08 1:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.