Click here to Skip to main content
6,595,444 members and growing! (15,955 online)
Email Password   helpLost your password?
Languages » C# » Applications     Intermediate License: The Code Project Open License (CPOL)

Solver for Scramble by Zynga

By dlabar

Program to automatically list all the possible words in the game Scramble on Facebook
C#, Windows, .NET 3.5, WinForms, LINQ, Dev
Posted:27 Nov 2008
Views:17,335
Bookmarked:12 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
2 votes for this article.
Popularity: 0.50 Rating: 1.67 out of 5
1 vote, 50.0%
1
1 vote, 50.0%
2

3

4

5
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)

About the Author

dlabar


Member

Location: United States United States

Other popular C# articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
GeneralWindows XP won't acknowledge this program PinmemberBecky Althoff12:24 25 Jun '09  
QuestionHow do I run this in windows xp? PinmemberMatt witt18:06 16 Mar '09  
GeneralVB Version? PinmemberMember 41501809:06 9 Jan '09  
QuestionCan U write in vb.net Pinmemberrqwe12:36 26 Dec '08  
GeneralMy vote of 1 Pinmembersaddestwhisper20:43 25 Dec '08  
Generalwots the deal ? how to install and run the code ? Pinmemberspice_lover14:26 22 Dec '08  
GeneralMissing Resources.rsx Pinmemberkeith.b8:32 2 Dec '08  
GeneralMy vote of 2 PinmemberGwannoes2:42 2 Dec '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Nov 2008
Editor: Deeksha Shenoy
Copyright 2008 by dlabar
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project