Friday, May 30, 2008

The Word Challenge's Bot (UPDATED)

Hello,
Instead of trying all combinations of words using the first bot, a wonderful modification was added. I used the dictionary located here and used only the words inside it.
The difference is amazing.
Try it here.

Monday, May 19, 2008

java.awt.Robot and the Facebook's Word Challenge Bot

Imagine that you have a Java GUI program written using the AWT and Swing libraries, and you'd like to automate the program. For example, you'd like to automatically supply GUI input events from the keyboard and mouse to the program. In this way, the program could operate without user intervention. This type of automation might be useful for testing purposes, or to produce a self-running demo program.

java.awt.Robot is a new class in JDK 1.3, designed to handle this type of automation. It's a way to automatically feed input events to a program. The events are generated in the native input queue of the platform, as if they had actually been generated by the user. For example, using java.awt.Robot, you can generate an event that is equivalent to a user moving the mouse to particular (X,Y) coordinates on the screen.

You can see an example on how to use this class on this link.

Facebook's Word Challenge Bot

Now lets see how can we use this in making our cool bot for the Facebook's word challenge game.

In this game you are required to construct words whose lengths range from 3 to 6. No need for a dictionary to do that, the range is already small enough to try all combinations of letters in a reasonable amount of time, then use the java.awt.Robot to print this output on the keyboard while you keep the focus on the game, you'll find it so much fun :)

Here's a link to the Netbeans project I used to make the bot.

And here's the bot itself.

Usage

  • Start the game and Know the allowed alphabet.
  • Edit the batch file provided with the game.
  • Add the alphabet at the end as the first command line arguments all in a single string.
  • e.g. If the allowed alphabet was {a, b, c, d, e and f} add "abcdef" - without the quotes - at the end of the file.
  • After adding the alphabet add an integer from 3 to 6 indicating the maximum length you desire for the letters generation.
  • e.g. Adding 4 to the end of the file generates words of lengths 3 and 4.
  • Now save and close.
  • Run the batch file.
  • Set the focus at the game (Just click at any place in the game's window).
  • Watch your score :)
Of coarse the program is subject to many modifications, you are encouraged to do your modifications and send me the updates if you want.

Enjoy,