Skip to content

naeemrashid/archero_bot_57

 
 

Repository files navigation

Archero Bot 57

Link to project report here and presentation ppt here

Watch the installation video:

Watch the installation and usage of the emulator (Nox Player):

Contents

  1. Introduction
  2. Installation on Linux
  3. Installation on Windows
  4. Platform installation (emulator)
  5. Game lock disabling
  6. Usage
  7. Game Description
  8. Coordinates management
  9. How it works
  10. Coordinates check explained
  11. Extra

Introduction

This is an archero bot that works on a mobile smartphone connected with usb cable. It was originally build to continously start a game (dungeon 6: the cave), play it until end and loop until energy bar is below 5. Then wait for energy to restart.

  • Supported OS:

    • Windows
    • Ubuntu/Linux distro
  • Supported platform:

    • Usb connection to phone
    • Nox emulator (installation video coming soon)
  • Supported dungeons:

    • 3 . Abandoned Dungeon: tested, FAILING
    • 6 . The Cave: tested, FAILING with 1 year update
    • 10 . The Cave: tests TBD, FAILING with 1 year update
  • Tested resolutions

    • 1080x1920 is full working. Remaining tests have to be done
    • 1080x2220 is full working. All tests show good coordinates positioning.
    • 1080x2280 is working. Remaining tests have to be done
    • 1080x2340 is working. Remaining tests have to be done
    • failing on other resolutions, but working on...
  • Equipment:

    • Try to use all dodging equip and life/atk gaining equipment
    • does NOT work with enlightement book (yet)

If you don't find your screen resolution and you want to contribue, follow these instructions.

Installation on Linux

Follow these steps to install adb, python lisb such as Pillow,matplotlib, numpy, pure-python-adb, pyqt5:

  • $ apt install adb
  • $ pip install Pillow matplotlib numpy pure-python-adb
  • $ pip install pyqt5 . If it fails, try with $ sudo apt-get install python3-pyqt5
  • Install Android Studio with sdk (link here)
  • Enable debug mode on your Smartphone (Settings -> about phone/info and tap 7 times on kernel version, then Settings -> debug options, activate it, debug mode and activate it). May vary based on phone model.

Installation on Windows

Follow these steps:

  • Install latest python from here. When installing, make sure to select "Add to PATH" in first page of installation wizard

  • Install Android Debug Bridge:

    • Download adb package from here
    • Extract the compressed file (Left click -> Extract Here)
    • Rename the extracted folder to 'adb'
    • Copy 'adb' folder into 'C:'
    • Go to Control Panel -> System -> Advanced system settings -> Environment Variables
    • Under "System variables" list, find 'Path', click on it and then click on 'Edit...' button below
    • Click 'New' and in the created TextBox write 'C:\adb'
    • Click 'OK' and then exit
  • Open a Command Line (press start, write CMD, press enter) and execute following commands by copying and pasting in the command line and pressing enter:

    pip install Pillow matplotlib numpy pure-python-adb pyqt5

  • Finally, download this program by clicking (in this page) on "Clone or download ->Download Zip". Once downloaded extract the compressed file (Left click -> Extract Here) and copy where you want. This is the program folder.

Platform installation

This bot can work either connected to smartphone trough usb or with Nox emulator on your pc.

If you want to use your phone, skip these steps.

If you want to use the emulator:

  • Download Nox emulator from here and install it.
  • Open the emulator
  • Insert your google mail and password (the account that you use on your phone, that archero uses to save data).
  • Enable debug mode (settings->info and tap 7 times on build, then go back, development options, activate debug usb)
  • Download the archero bot on the emulator.
  • Open it

Disable Blue auto lock screen

When using this bot with a Samsung (like S7, S8, S9, S10 and S20 along with plus, edge, note and ultra versions) the Game Tools will automatically lock your screen with a little blue lock every 35 seconds. To disable it, follow this:

  • Open your gamea, and swipe UP FROM THE BOTTOM OF THE SCREEN. You will see the Game Tools icon in the bottom left. Click this.
  • Click on Advanced game features.
  • Turn Auto screen lock OFF

Thanks to userYIxYmjMxs6 for this post on samsung community.

Usage

Once cloned the repo, execute GameController.py. The interface is not complete but provides basic view and play operations.
Remember to disable notifications or activate Do Not Disturb mode.

Game description

Set dungeon to The Cave (number 6) and run the executable GameController.py:
If you launch from terminal, it is possible to specify the starting level of first run (e.g. python static_bot_cave.py 16).
If setting start from 0, the program will check your energy. If 5 or above, then starts a game and plays until he dies. He normally does between 12 to 20 levels.
Once it ends, he goes to main menu and checks another time if it has energy. This program is not perfect. If he somehow thinks to be on a different level but the game is ahead, please manually end the game, return to main menu and restart the game.
Even if it will fail, no harm will be done (it will not exit and click randomly on your phone).

Coordinates Management

Static coordinates check

The bot takes screenshots over time and detecting what is currently on the screen is a requested operation before starting the bot. With this said you have to execute check_static_coors.py and checking that each row starts with OK.

If some NO_DETECTION are found, don't start the bot. Other MULTIPLE_DETECTIONS are allowed.

Coordinates check

If the program is clicking in wrong places, then use TouchManager script. Create a folder with all your screenshots. Set images_path to screenshots path. launch TouchManager script and use the interface (for windows double-click on 'checkCoordinates.py.'). Current version: basic_usage.

How it works

The package adb lets us use various android tools like:

  • tapping on a screen coordinate
  • swiping between two points in an amount of time
  • taking a screenshot

With those functions, i built a dictionary with needed coordinates (in datas/default_dict.py) to start with.

All coordinates are normalized in [0, 1]. This is done because then we will set our screen width and height according to the phone screen used.

Using the TouchManager app we can check each point location for each screenshot that we have (default folder images/samsungs8+).

When we are in need to check something on the screen, we take a screenshot (saved as 'screen.png'), load the image as a list of pixels and get from it a set of pixel locations. Then check those with our needed pixels. All this is done in the game_screen_connector script. For example when checking if having 5 or more energy to play one game, we check that pixel corresponding to 5th bar of energy is blue:

Check_bar

Coordinates check explained

In order to detect the game state, a static coordinate check is done. For each interesting state (on pause, on devil question, on skill choose) there is a list of (x,y) coordinates that checks if the color is in a specific color range. Example:
Checking 'endgame' consist in checking that we see the 'blue' color in 3 different points.
These coordinates have to have red, green, blue colors in an interval being (48, 98, 199) +- 5.
In the future implementation, this hole static check will be replaced by a neural network model trained to automatically detect those data in the screenshot.

Issue: Adb not working

If adb doesn't work or installation failed, check out this video. It explains how to install on windows and ubuntu.

Statistics saving

Every game statistics is saved in datas folder as a statisics csv file. It can be opened by LibreOffice or Excel.
This is usefull in future games plotting to know how it performed.

Extra

Thanks to RimanCz for screenshorts done with Samsung S10e (1080x2280).
Thanks to MahirZukic for screenshorts done with Xiaomi Mi 9 (1080x2340).
Thanks to AgamemnonasKyr for screenshots done for upper black strip in game (1080x2280).
For any bug open an issue. If not having a github account, email me at fabian_57@yahoo.it.

About

A bot to farm on Archero mobile game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%