Wednesday, December 5, 2007

Cheating for Fun

I recently checked out the Scramble application on Facebook, which is a knock-off of Boggle. It's a fun diversion, even though I usually get my ass kicked. There's an annoying chat window there, too, and invariably someone will accuse someone else of cheating, at which point a number of people will pipe up with "how would you cheat?"

This got me thinking...how *would* you cheat? You'd just have to write a Scramble puzzle solver that spit out all the words in on the board. That sounded like a fun problem. I hadn't done anything with recursion in a while, so I gave it a go. Below is what I came up with. You'll need a word list to run it. I originally used /usr/share/dict/words, but it was missing a lot of valid words (I think it only has base words, no plurals or tenses). So I stole the scrabble word list from the Debian scrabble package, which worked much better.

Anyway, here you go:



I did try this out a couple times on Scramble and won handily. There's really not much fun in that, though.

Update: I posted this in one of the comments below, but I'll put it here as well to make sure everyone sees it: This was really just an exercise in coming up with a fun algorithm, and is primarily intended for programmers. If you’re just looking to cheat at Boggle/Scramble, there are plenty of web sites that will help you with that, and with a lot less effort.

8 comments:

  1. i cant get this thing run... it just shows me a txt file...

    ReplyDelete
  2. can this run on a mac?

    ReplyDelete
  3. I don't seem to know how to get this to work after I get Ruby and then the code and words. Would anyone like to give me any help?

    ReplyDelete
  4. Ally- I'm pretty sure there's not anything more to uninstalling than just dragging the Locomotive folder in Applications to the trash.

    ReplyDelete
  5. I think it's gone now. goodness I'm slow...

    ReplyDelete
  6. Interesting, but I assume that Ruby is not supported on Vista?

    ReplyDelete
  7. Hi i got this running in cmd but am new to ruby.. How do i get it to output on to the board?

    ReplyDelete
  8. Very interesting, hopefully i can this working and install ruby! Thanks for sharing :)

    ReplyDelete