Skip to content

ychalier/hoplite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hoplite Icon Hoplite

An attempt at making a basic AI for the Hoplite Android game.

Preamble

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.

Hoplite Android Icon

Getting Started

Prerequisites

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).

Installation

  1. Clone the repository

     git clone https://github.com/ychalier/hoplite.git
    
  2. 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

Usage

  1. Either start the emulated phone in AVD or plug in your phone, and open the Hoplite app.

  2. List the available devices with

     adb devices 
    
  3. Start the script with:

     python main.py play <adb-device-id>
    

Use python main.py --help for more details.

Contributing

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.