Creating a Bejeweled bot with AutoIt

Update: Following the success of this post, I have written a detailed tutorial including code snippets on the creation of your own bejeweled bot.

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.

Related Posts by Categories

Comments

5 Responses to "Creating a Bejeweled bot with AutoIt"

Anonymous said... April 23, 2009 at 7:16 AM

Hey, this would be great if you could upgrade it to play Bejeweled 2's Zen mode - in order to "beat" it and unlock the last secret mode you have to reach Level 281 or something like that. :O

Steven Machtelinckx said... April 23, 2009 at 8:10 AM

wow level 281 sounds like a lot :-) I'm not sure what you mean by Zen mode because I never played bejeweled 2. Is it some rage mode?

Though recently I upgraded my bot to be able to handle bejeweled blitz on facebook. It's not finished yet because it's hard to recognize the colors of the special blinking gems, but I already managed to get 200k in 1 minute :-) But if I get my bot to work fine for bejeweled blitz, it will probably also work for bejeweled 2 zen mode :-)

Anonymous said... June 26, 2009 at 8:41 PM

I tried this and works fine
http://www.youtube.com/watch?v=6vwQKsi232s

http://www.nessuno.org

TestWithUs said... May 7, 2013 at 6:05 AM

SWIFT Interview questions on

http://testwithus.blogspot.in/p/swift.htm

For selenium solution visit
http://testwithus.blogspot.in/p/blog-page.html


For QTP interview questions

http://testwithus.blogspot.in/p/qtp-questions.html


www.searchyourpolicy.com




TestWithUs said... May 7, 2013 at 6:25 AM

SWIFT Interview questions on

http://testwithus.blogspot.in/p/swift.htm

For selenium solution visit
http://testwithus.blogspot.in/p/blog-page.html


For QTP interview questions

http://testwithus.blogspot.in/p/qtp-questions.html


www.searchyourpolicy.com




Post a Comment

Recent Articles

Top Commenters

Recent Comments