Conquering the Monolith beast with Android MonkeyRunner

Though it may be generally considered cheating, when I was faced with having to endure repeatedly tapping the beast in the game Monolith on Android I did what every good programmer does and automated the task.

The tool I used was Android's MonkeyRunner as I was planning on using to test the UI of an app I was writing, so provided me with good practice.

Autotapper script in action

Setting up MonkeyRunner

Monkey Runner is part of Android's Software Development Kit (SDK). Follow the instructions in the links below to download the SDK and configure your device to enable development mode.

  1. Follow the official instructions to install the standalone Android SDK tools.
  2. Follow the official instructions for enabling ADB debugging on your device.

Running the autotapper

  1. Download the script for the autotapper (below) to your computer
  2. Plug in your Android Device via the USB
  3. Start the game, ensuring that the beast is showing
  4. Run the script via the command below:
$>~/adt-bundle/tools/monkeyrunner ~/monolith_autotap.py

You can customise the position of the taps by changing the co-ordinates in the line

tap_positions = [[200, 400], [300, 410]]

Autotapper script

Stopping the autotapper

Press Ctrl+C to stop the autotapper script, this will allow the script to clear up gracefully.

Possible problems

The following are a few workarounds to little problems I ran into whilst writing the script but didn't get around to finding permanent solutions.

Autotapper fails to connect to device

If the script doesn't manage to connect then it could be that the ADB daemon needs to be started. This can be achieved by running the following.

$>~/adt-bundle/platform-tools/adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

Autotapper keeps throwing 'Error sending touch event'

I found that approximately 1 in every 2 times I ran the script it would fail with the error below. I don't know why it does this but it is easily remedied by stopping the executing of the script (via Ctrl+C) and then running it again.

150803 09:12:56.303:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice] Error sending touch event: 209 409 DOWN_AND_UP
150803 09:12:56.303:S [MainThread] [com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Broken pipe