Some years ago I created a bot able to play Bejeweled solo. I must say, I'm pretty proud of the result. It's not like I love cheating in games, cause that usually ruins the game fun forever. But I do like to try out things and to find new challenges. As I was never really connected to the game, there was no disadvantage to automating the game. Instead, there was satisfaction at the first place.
The bot was developed with the scripting language AutoIt. It's an easy to learn yet very powerful language which you can use for general scripting as well as for windows GUI scripting.
The bot only interacts with the graphical output of the bejeweled game. Basically it reads the colors of the gems and decides which move to make based on an algorithm. The hardest part was to find back the coordinates of the matrix containing the gems and to calculate its dimensions. Finally I succeeded in this by searching for a unique color code which occurs only for the first time at the left top of the matrix and which occurs for the last time at the right bottom of the matrix. With that information I could create a matrix of coordinations to start pixel reading with.
There are some basic Autoit functions I couldn't have done without:
- pixelgetColor(x, y): returns the color of the pixel located at the position specified
- pixelSearch(left, top, right, bottom, color): returns the location of the first pixel matching the color specified
- mouseClick(button, x, y): clicks the mouse button at the location specified
Here you can see the bejeweled bot at work:
I'm not only happy to have succeeded in creating this bot, but also to having tried. It has given me more insight in the development of bots and I already started wondering about a new project.
If you're in need of help with your Bejeweled bot making or you could use some advice, feel free to leave a comment and I'll try my very best to help you.
Update: Following the success of this post, I have written a detailed tutorial including code snippets on the creation of your own bejeweled bot.