Fun with Bluestacks, Clash of Clans and Sikuli

So recently I decided to merge some fun time with some work time stuff for no good reason at all other than boredom.  For fun lately, I like to play Clash of Clans on my iPad.  For work, sometimes I use a program called Sikuli to handle automated testing of UI bits that I develop.  I thought it would be a decent waste of time to take the two and slap them together.

To do this I required Bluestacks, it is an Android emulator for PC.  Available for download at http://www.bluestacks.com

I also needed the Clash of Clans app… piece of cake, you’d have to be blind to miss it, it is everywhere. It’s like Bluestack’s major selling point right now “Play Clash of Clans on PC!” since CoC developer SuperCell has only made it for mobile devices.

Then I installed Sikuli which is available at www.sikuli.org and began thinking about how I would write my Sikuli Script.  I think that step is very important before diving right in.  You have to look at the graphical display and think about what tasks are repeatable, definable, and in logical steps for which I can create simple loops and finds.  Here is a simple example from my CoC script.

while exists("1410149875690.png"):
   click(exists("1410149875690.png"))
while exists("1410149916890.png"):
   click(exists("1410149916890.png"))

This basically in real short code creates a while loop on the two things I deemed most important, collecting my resources. Note the embedded exists inside the click() function. I found this to be important as something like an IF exists(img) click(img) actually makes Sikuli search twice and sometimes on the second turn it fails to find the image and throws an exception.

As for exceptions I figured they would happen so I just put most things that might causes errors into a try/catch. This pretty much handles that.

try:
    some code...
except FindFailed:
    some code...

And I posted this Youtube Video: http://youtu.be/DKQm5J2gLU4 (Sadly – SuperCell filed a copyright complaint against this video because it demonstrated botting – so it’s no longer available).

So I uploaded the .mp4 instead… here ya go.

One thought on “Fun with Bluestacks, Clash of Clans and Sikuli”

  1. And SuperCell makers of Clash of Clans didn’t like my YouTube video so they went and got it taken down. Maybe I’ll do another Sikuli blog post someday.

Leave a Reply

Your email address will not be published. Required fields are marked *