26Aug/115
My Bejeweled Blitz cheat bot
A few months ago I've written a cheatbot (in Java) for PopCap's Bejeweled Blitz on Facebook. Today I've done a few improvements. Time to share this with the web.
You might think "OMG H4X!!!one!!". Well, not really. I didn't manipulate the game or browser in any way, I simply let my computer move my mouse and play the game.
How does it work?
- Take a screenshot of the current grid (or field)
- Check the color of the pixel in the middle of each gem on the grid
- If it's a hypercube: move the hypercube randomly to a direction
- Check for each gem whether moving it is a valid move
- If so, move it!
- Repeat until the minute is over
- ...
- Profit!
This performs pretty well, check out the video below:
Improvements still to be done:
- It does not recognize every special gem, this should be fixed
- The first valid move is now performed immediately, perhaps a better heuristic is possible (e.g. find hypercubes first, then search for multipliers... etc.)
- It should have a shortcut to e exited, now it keeps on running; making the mouse impossible to use until the minute is over.
- The code is a bit messy, should be cleaned up.
Funny thing: Normally Blitz guarantees there always is a new move, however I happened to have a field once with no further possibilities, probably because of a race condition between my bot and the game, see below.
Questions and comments are welcome ![]()









August 26th, 2011 - 11:06
Very nice indeed. How about combining it with a machine learning algorithm to learn patterns that score well?
August 26th, 2011 - 18:13
That would be very doable I guess, though I’m not sure wheter there really is a “best strategy”, there is a lot of randomness going on.
August 27th, 2011 - 00:04
Very cool. Do you have any stats on how many moves are possible, on average? If it’s only 1 most of the time, there’s little to do in terms of strategy. But even if it’s 2 on average, you can easily think ahead a few steps based on what you know.
Next step would be to think ahead based on what you *don’t* know, i.e. probability that the right gems will fall in from the top and make that awesome combo.
If you manage to separate the thinking from the looking and moving, I’d love to poke at that code for a bit
December 28th, 2011 - 23:30
Great work . Does it work on other games or just for this?
January 6th, 2012 - 10:54
Well, it’s currently hard-coded to work for Bejeweled Blitz, however the technique can be used for other games/applications as well.