Automating Android Games with Python: Stick Hero

Automating games regardless of platform is a fun and challenging way to learn programming skills whether it’s Python, JavaScript, or otherwise. Oh, and getting huge high scores is cool too.

Hope you enjoyed the video!

Check out this code here:

Join my Discord server to chat with me:

Check out some code on my GitHub:

Come visit us on Reddit:

Other Social:

47 Replies to “Automating Android Games with Python: Stick Hero”

  1. Rookie Videos

    Maybe this is a stupid question, because I don't know much about this, but would it be a viable approach to check for the right pixel above the ninja to turn black, instead of calculating the time?

    I can imagine getting screenshots the whole time would be bad for performance, but I wonder if it's possible to just check for one specific pixel. If so, could it be more accurate without losing too much performance?

  2. Amel Babić

    if i dont have a phone, can i use an emulator like bluestacks and take a screen shot every time the level changes and then unpack them into pixels?

  3. feras assaf

    Hello, I thank you for all these beautiful videos. I have a question. When I try to connect to the emulator with the same written code, it does not work. Please note that there are no errors.

  4. Ondona

    U could of done a press of x time and then taken a screenshot straight away. From the line straight up u could of gotten the pixels per second (only difference i could think of that i would of tried)

  5. Jens B.

    Python is just awesome. Great video! Beyond the scope I know but I'd scan from top-left downwards to get the proper starting location of Y without hardcoding. That would suggest breaking out the transition detection into a reusable function.

    Furthermore, I feel it's kinda waste if time to store the screenshot on file. Haven't tried the libs in question but if it's possible to screen cap directly inro memory I'd consider it way more neat.

    Finally it would be interesting to actually clock the time drawing the stick and dynamically adjust the timing along the way to get better accuracy.

    Of course, that's all overkill for a proof of concept as shown here. However, it does take into account good practices and interesting extensions like reusability and device independent code. I believe the code required to do it wouldn't be too complicated.

    Again, great video!

  6. ColD4D

    Hi. I just want to run your source code from github but I got a problem with 'unresolved reference 'ppadb' and some imports. IDK what to do please help anyone?

  7. Henry McCoy

    I think the reason why at the end it wasn't getting shorter distances perfect is because the inaccuracy in the time it touches isn't a percentage but instead a discrete value. Should be an easy fix.

  8. Noorquacker

    "So now we need to see the transitions between the pillars"
    My calc-traumatized self: aight compute average brightness of all the pixels and then take a trashy derivative of this and take absolute peaks of this derivatives to find rising/falling edges…

  9. FotoTrip

    Great and simple approach. It's probably overkill but instead of 'time sleep' in the end we can pull image and as soon as previous is different from current start applying the algorithm.

  10. Rishikesh Kanabar

    Hi I dont know where someone would be there to answer this but when I tried 1400 index for the image, I got 0 parameters. I tried out more values and at 1700, I get a score of about 35 and then I get the error : ValueError: not enough values to unpack (expected 3, got 1). I dont know what to do here. Can you please help me out? Thanks for this amazing video.

  11. Dhev Tamang

    Can anyone give me instructions to setting up the same terminal in the video to run py files? I tried doing it in adb shell, it outputs error of inaccessible or not found in systems/bin/sh:

Leave a Reply

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