Giter Site home page Giter Site logo

ychalier / hoplite Goto Github PK

View Code? Open in Web Editor NEW
9.0 7.0 3.0 1006 KB

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

Home Page: https://ychalier.github.io/hoplite/

Python 89.38% Jupyter Notebook 10.57% Batchfile 0.05%
hoplite artificial-intelligence monkeyrunner android tactical-rpg roguelike

hoplite's Introduction

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.

hoplite's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hoplite's Issues

After a few steps I encounter an error on my terminal.

Traceback (most recent call last):
File "/home/hoplite/main.py", line 3, in
import hoplite.main
File "/home/hoplite/hoplite/main.py", line 243, in
main()
File "/home/hoplite/hoplite/main.py", line 236, in main
play(args.serial, args.prayers, args.record)
File "/home/hoplite/hoplite/main.py", line 87, in play
controller.run()
File "/home/hoplite/hoplite/controller.py", line 192, in run
self.step()
File "/home/hoplite/hoplite/controller.py", line 155, in step
move = self.brain.pick_move(self.memory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/hoplite/hoplite/brain.py", line 172, in pick_move
best_move = max(outcomes.items(), key=lambda x: x[1])[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: max() arg is an empty sequence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.