View Full Version : Scrabble word finder
Sanchek
12-28-2007, 04:55 PM
I've been playing online Scrabble (http://apps.facebook.com/scrabulous/) against this linguistics major who absolutely kicks my ass. After losing a half dozen times in a row, I figured if they can bring their specialized education to the table, I should bring mine too.
So, I wrote an application to generate anagrams from a set of letters and check them against the TWL Scrabble dictionary. I decided to go ahead and host it where others can use it too. If you play Scrabble, it might be of use.
Enjoy (http://winscrabble.com).
Sanchek
12-28-2007, 04:56 PM
Also, it's the weirdest thing. A large, large majority of the traffic to that site is from Canada. Is Scrabble the national pastime of Canada or something?
Kelraz Bladesinger
12-28-2007, 05:42 PM
Haha thats crazy clever. Kudos.
Palarran
12-28-2007, 09:33 PM
Hmm, I think something is wrong.
I was curious whether words longer than 8 letters were included, since it is normally difficult to form words more than 8 letters long in Scrabble. I tried entering "unbecoming" (the first word that came to mind, for some reason). It did return the 9 letter word "mucinogen" but not "unbecoming".
Yet "unbecoming" should be on the list:
http://www.scrabulous.com/dictionary_search.php?word=unbecoming&dic=twl
Next I tried "optionally". This time it worked; the top result was "optionally".
Edit: I tried some more words with the prefix "un" to see if that was the issue. "Uninspired" and "uncommitted" worked. "Unoriginal" and "unforgiven" didn't.
Edit 2: "Onomatopoeia" worked but it took close to a minute to return results. "Alphabetically" resulted in a timeout. You may need to either cut off the number of letters considered or use a more efficient algorithm. :)
Sanchek
12-29-2007, 06:33 AM
I'll take a look at that. Mainly, it's focused towards the 7 letter combinations that you can make in a normal Scrabble game (though, it does have the entire TWL word list to check against).
Sanchek
12-29-2007, 07:21 PM
It's fixed now. Thanks for finding that for me.
To improve performance, I have lists of valid 2-5 letter word prefixes. If a branch of the tree is going down a path that's impossible to make a word from, it preemptively stops that branch short. Somehow, I managed to be missing about 6% of those from the five letter list, including UNBEC. Oops.
As for performance, yeah it kinda blows for a lot of letters. I'm just using a recursive algorithm, with that prefix based pruning. So, when you get to 12 letters, it's running nearly a half billion permutations. Ouch.
I've read about a more efficient algorithm, using a directed graph, but I doubt I'll ever feel like implementing it.
edit: Oh, and unforgiven isn't a valid TWL word, so that's why that one failed.
Palarran
12-29-2007, 11:27 PM
Aha, you're right! With "unforgiven" I got lazy and just checked google ("define:unforgiven") instead of the TWL dictionary, since I had already closed the scrabulous.com page.
I was trying to think of how I would do it if I wanted to optimize for execution speed rather than ease of coding or anything else. (If I wanted a quick-and-dirty solution I'd probably have taken a similar approach to yours.)
I'd probably create a tree structure where each node (except the root node) represented a letter, and contained a set of child nodes representing letters _after_ that letter. Each word on the TWL list would be attached as a leaf node to the series of nodes representing the unique letters in the word sorted alphabetically. For example "banana" would be attached to (root)->A->B->N. Then if my search string was "ABCABCN" I would see that it has 2 A's, 2 B's, 2 C's, and one N, and iterate through the words in these lists, checking their letter counts against those of the search string:
A ("aa")
A->B ("abba", "baba", "aba", "baa", "ab", "ba")
A->B->C ("bacca", "abaca", "cab")
A->B->C->N ("cabana")
A->B->N ("banana", "ban", "nab")
A->C ("caca")
A->C->N ("cancan", "canna", "can")
A->N ("anna", "naan", "nana", "ana", "nan", "an", "na")
B (empty)
B->C (empty)
B->C->N (empty)
B->N (empty)
C (empty)
C->N (empty)
N (empty)
Of course I don't feel like implementing it either. :) I just like the problem solving part.
Fandros
12-30-2007, 01:17 AM
Palarran, I'm a mere vessel now....
Sanchek
12-30-2007, 03:38 AM
That's basically the same as the directed graph approach. I'm just worried that the memory footprint would be a lot larger than using a flat word list, which will cause me trouble at that shared host.
Oipunx the High Elf Cleri
01-03-2008, 11:42 AM
One of my best friends has memorized every two letter and three letter word in the english language.
He loves scrabble!
Starrla
01-29-2008, 11:20 AM
Also, it's the weirdest thing. A large, large majority of the traffic to that site is from Canada. Is Scrabble the national pastime of Canada or something?
Could it be that is so cold up there that no one gets out much and to play games is the best for fun inside? :) Just guessing.....
Sanchek
01-29-2008, 11:38 AM
Haha, that's all I could figure too.
Sixee
01-29-2008, 12:16 PM
How to tell if you are playing a Canadian in Scrabble:
They have the letters C O L O and R and say they can't spell colour.....
You have the letters F A V O R I T and E and call you on the incorrect spelling of favourite....
Sanchek
02-25-2008, 06:23 PM
If any of you play Scrabulous on Facebook, PM me or AIM me. I have something ridiculous built, that could use some testing. You'll thank me.
Nydia Ywalmoriel
02-25-2008, 06:34 PM
I haven't logged on to Facebook recently, but I can PM you and we can do a game sometime - and I've beat Malse using your cheesebot program Mark 1 on multiple occasions, although he did have the lead on me when we stopped playing.
Regards,
Nydia
Sanchek
02-25-2008, 06:42 PM
That's beautiful.
Nydia Ywalmoriel
02-25-2008, 06:53 PM
I just realized that that sentence was ambiguous, but I presume it was understood that *he* was using said cheesebot program, as I don't, to this point, use them :).
Sanchek
02-25-2008, 07:03 PM
Oh, he wasn't using the good one. Just the public one.
Kelraz Bladesinger
02-25-2008, 07:46 PM
BTW Sanchek:
http://winscrabble.com/Words-with-no-vowels.aspx
A few of those words aren't in any dictionary I've ever seen. Like PHPHT (even your dictionary.com link says "no results") PHT, and TSKTSKS
Sanchek
02-25-2008, 07:47 PM
They're in the Scrabble tournament word list dictionary, which is what counts for most Scrabble games. So, I go with it.
Kelraz Bladesinger
02-25-2008, 08:36 PM
what does it mean? :)
Sanchek
02-25-2008, 08:51 PM
It means your opponent will know you're cheating!
Sanchek
02-29-2008, 01:00 AM
I made it a little prettier. What do you think?
Malse
03-11-2008, 10:29 AM
Oh, he wasn't using the good one. Just the public one.
Being a man, I never used that against anybody but you after you developed it in response to me kicking your ass. Which I thought was cool in a sneaky way.
I do apologize for not really helping you much on it, I sort of totally lost interest in online scrabble around the time you were getting it going and had to settle for beating Nydia four times in a row over the Christmas holiday with Willgatus and Faervas as collateral damage.
To be fair, in one of our last FB games Dave did deliver an excellent coupe de grace with COCAINES across a triple world score.
Sanchek
03-11-2008, 01:01 PM
I never used it on you. I thought we had something special.
Sanchek
06-21-2008, 10:59 PM
I finally released the Scrabulous deal, if anyone's playing that on Facebook:
http://winscrabble.com/scrabulous/
Sanchek
07-29-2008, 05:51 PM
http://bits.blogs.nytimes.com/2008/07/29/facebook-shuts-down-scrabulous/
Bastards.
Apparently, they offered those Indian guys $10 million to buy them out, but they refused. Now they get 0. That was smart...
akipt
07-30-2008, 12:59 PM
For what's it worth, my wife uses your word finder for another game she plays online. Don't know the name, but you get 6 or 7 letters and you have to figure out all the different words they make in a certain amount of time.
Sanchek
07-30-2008, 02:27 PM
Well, I hope she finds it handy.
I'm not too worried about my site. People will keep using it just the same with EA's Scrabulous replacement.
I think EA's might actually provide greater opportunity for cheating. In the few minutes it was up yesterday, I dug into it and found a way to view the other player's rack. That should be fun!
I'm mostly annoyed because I enjoy playing Scrabulous myself (without cheating), and the new EA version isn't working yet. I lost a game I was in the middle of, where I had just played a 122 point word.
Taleren Bloodsong
07-31-2008, 01:09 AM
For what's it worth, my wife uses your word finder for another game she plays online. Don't know the name, but you get 6 or 7 letters and you have to figure out all the different words they make in a certain amount of time.
Word Whomp on Pogo.
Grift3r
07-31-2008, 01:30 PM
It's back: http://techdirt.com/articles/20080730/1936041842.shtml
Sanchek
07-31-2008, 04:39 PM
I think that's something that's actually been around for 6+ months, but never caught on. I have a feeling that it still won't. Too complicated, for people who just want to play Scrabble easily.
I have noticed a lot of people still using my Scrabulous Solver on the "play by email" version on the Scrabulous site itself. Apparently, it's still there, doesn't check for US/CA IPs, and functions identically to Scrabulous on Facebook.
Sanchek
01-22-2011, 04:26 PM
Aha, you're right! With "unforgiven" I got lazy and just checked google ("define:unforgiven") instead of the TWL dictionary, since I had already closed the scrabulous.com page.
I was trying to think of how I would do it if I wanted to optimize for execution speed rather than ease of coding or anything else. (If I wanted a quick-and-dirty solution I'd probably have taken a similar approach to yours.)
I'd probably create a tree structure where each node (except the root node) represented a letter, and contained a set of child nodes representing letters _after_ that letter. Each word on the TWL list would be attached as a leaf node to the series of nodes representing the unique letters in the word sorted alphabetically. For example "banana" would be attached to (root)->A->B->N. Then if my search string was "ABCABCN" I would see that it has 2 A's, 2 B's, 2 C's, and one N, and iterate through the words in these lists, checking their letter counts against those of the search string:
A ("aa")
A->B ("abba", "baba", "aba", "baa", "ab", "ba")
A->B->C ("bacca", "abaca", "cab")
A->B->C->N ("cabana")
A->B->N ("banana", "ban", "nab")
A->C ("caca")
A->C->N ("cancan", "canna", "can")
A->N ("anna", "naan", "nana", "ana", "nan", "an", "na")
B (empty)
B->C (empty)
B->C->N (empty)
B->N (empty)
C (empty)
C->N (empty)
N (empty)
Of course I don't feel like implementing it either. :) I just like the problem solving part.
After all this time, I finally got around to reworking the algorithm from scratch. I'd been upgrading the hosting to larger and larger VPS setups trying to keep up with demand over the last year or so, and finally got fed up with throwing hardware at the problem like a noob.
I had forgotten about this, but that trie is almost exactly how I ended up implementing it. It's so much faster now; especially for 8+ letters and/or blanks. Let me know if you're interested in the implementation (C#). It turned out not to be very difficult once I solved a stupid problem or two of my own doing.
fildien
01-24-2011, 02:26 PM
So after seeing this it made me wonder.... does anyone play words with friends on your iphone/ipad/itouch? If so and you want to play a round with me I can be found as NURTA. :)
Jensae1
01-24-2011, 03:56 PM
After all this time, I finally got around to reworking the algorithm from scratch. I'd been upgrading the hosting to larger and larger VPS setups trying to keep up with demand over the last year or so, and finally got fed up with throwing hardware at the problem like a noob.
I had forgotten about this, but that trie is almost exactly how I ended up implementing it. It's so much faster now; especially for 8+ letters and/or blanks. Let me know if you're interested in the implementation (C#). It turned out not to be very difficult once I solved a stupid problem or two of my own doing.
I'd be curious to see your implementation.
Sanchek
01-24-2011, 04:06 PM
Is the email address in your profile here current?
Jensae1
01-25-2011, 01:44 AM
I just updated it.
Sanchek
01-25-2011, 03:51 AM
I sent you the codes.
Jensae1
01-29-2011, 12:27 PM
Thanks San - peeking at it today. Last few days have been pretty rough at work.
Sanchek
01-29-2011, 12:30 PM
I think what I sent you may have had a misleading comment. The blanks aren't de-prioritized by the position of the if statement in the loop, as the comments claimed, but by sorting them to the end of the letters array at the beginning of the search.
Trikki
02-06-2011, 12:22 PM
Remind me to never play scrabble with you egg heads. :p
:devil
Sanchek
02-10-2011, 02:26 AM
So after seeing this it made me wonder.... does anyone play words with friends on your iphone/ipad/itouch? If so and you want to play a round with me I can be found as NURTA. :)
BTW, do not use a sensitive password for WwF. It transmits your username and password in an easily reversible encoding, every 10 seconds or so. Anyone on unencrypted WiFi with you could easily sniff your password if you opened WwF on that network.
fildien
02-14-2011, 01:06 PM
BTW, do not use a sensitive password for WwF. It transmits your username and password in an easily reversible encoding, every 10 seconds or so. Anyone on unencrypted WiFi with you could easily sniff your password if you opened WwF on that network.
good to know and glad I chose some of the wall rinky-dink password when I made my account. thanks for the tip!
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.