Click here to Skip to main content
Click here to Skip to main content

Solver for Scramble by Zynga

, 27 Nov 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

dlabar

United States United States
No Biography provided

Comments and Discussions

 
QuestionExactly what I needed. Neat coding, thanks. PinmemberEmre201320-Feb-13 17:42 
GeneralMy vote of 5 PinmemberEmre201320-Feb-13 17:08 
Questionprocess method? PinmemberLhocu21-Nov-11 15:37 
AnswerRe: process method? Pinmemberdlabar21-Nov-11 17:27 
GeneralRe: process method? PinmemberLhocu24-Nov-11 17:05 
GeneralMy vote of 1 Pinmembercrashandburn531-Oct-11 12:48 
GeneralRe: My vote of 1 PinmemberLhocu21-Nov-11 15:41 
GeneralWindows XP won't acknowledge this program PinmemberBecky Althoff25-Jun-09 12:24 
QuestionHow do I run this in windows xp? PinmemberMatt witt16-Mar-09 18:06 
QuestionVB Version? PinmemberMember 41501809-Jan-09 9:06 
QuestionCan U write in vb.net Pinmemberrqwe26-Dec-08 12:36 
GeneralMy vote of 1 Pinmembersaddestwhisper25-Dec-08 20:43 
Questionwots the deal ? how to install and run the code ? Pinmemberspice_lover22-Dec-08 14:26 
GeneralMissing Resources.rsx Pinmemberkeith.b2-Dec-08 8:32 
GeneralMy vote of 2 PinmemberGwannoes2-Dec-08 2:42 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 27 Nov 2008
Article Copyright 2008 by dlabar
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid