An attempt at making a basic AI for the Hoplite Android game.
Hoplite is a popular turn-based strategy Android game developed by Magma Fortress, originally created in 2013. Try it (there is a free and a premium version), you will love it!
This modules provides an interface for automatically playing the game on an Android simulator or even live on a device. Screen is captured and analyzed for the program to get a logical representation of the game. Then, like most chess engines, possible moves are explored and evaluated by pondering some relevant features. The best one is picked, and played.
Here is a demonstration of it working on a emulator.
This is a first draft, meaning many components are missing or poorly implemented.
You will need Python 3 and Android Studio (for adb
).
adb
allows for remotely controlling the Android device (either a real phone plugged into the computer via USB with 'USB debugging' enabled, or an emulated phone created with AVD).
-
Clone the repository
git clone https://github.com/ychalier/hoplite.git
-
Install the dependencies
cd hoplite/ pip install -r requirements.txt
Disclaimer: interactions with phone screen currently rely on static and hardcoded values. A screen resolution of 1080x1920 is required for them to work properly. For other resolutions, changes might be required in the following places:
vision.observer.ScreenParser.__init__
actuator.hexagonal_to_pixels
actuator.Actuator
-
Either start the emulated phone in AVD or plug in your phone, and open the Hoplite app.
-
List the available devices with
adb devices
-
Start the script with:
python main.py play <adb-device-id>
Use python main.py --help
for more details.
Open pull requests or issues if you have any proposition to make. I put some screenshots here (2MB) helping development, and the templates (1MB) used for the classifiers.
If you implement some features, please make sure your code is clean enough (for this matter I use the Pylint linter) and documented enough (add docstrings with short descriptions, types of arguments and returned values). I use pdoc to generate the documentation.