Skip to main content

A package that can be used to make an AI learn from Amstrad CPC games.

Project description

Amstrad Learning Environment

The Amstrad Learning Environment is a Python interface that is meant to be used with AIs and OpenAi Gym. The Python library is available on Linux and Windows.

Installation

Unix

First you’ll need to install Python3 (version >= 3.6). To install Python :

$ sudo apt-get install python3

To check the version :

$ python3 --version

Then, you’ll need to install pip, so you can install the amle-py package :

$ curl https://bootstrap.pypa.io/get-pip.py | python

With pip, you’ll need to install two dependencies :

$ pip install --upgrade setuptools
$ pip install --upgrade numpy

Finally you can install amle-py :

$ pip install --upgrade amle-py

Windows

Install Python by going on their website. Make sure to add Python to your path and install pip during the installation.

How to use

Compile and use the sources (Linux only)

To compile the sources you will need to install a few dependencies :

  • SDL 1.2

  • libpng

  • libzip

  • cppunit

Once you have all these dependencies, you can compile the project. You may also want to generate the documentation of the project, this is done in the doc/ folder. Make sure to have doxygen installed :

$ sudo apt-get install doxygen

And then :

$ doxygen doxygen.config

Use the Python library

First you will need to create a new Python file in which you import the library :

import amle_py

Then you will need to create a new amle object :

amle = amle_py.AmLEInterface()

And you will need to load a game :

amle.loadSnapshot("Arkanoid", "snap/arka.sna")

Note that the first string has to a name the AmLE can understand. If you have a doubt you can get the list of all possible strings with :

games = amle.getSupportedGames()

Moreover, the second argument is a path to YOUR .sna file. You have to import one from the internet and generate one yourself with an emulator. Also, it doesn’t have to be in a snap/ folder, this is just cleaner.

Then you may want to run the game :

while not(amle.gameOver()):
    amle.step()

This doesn’t do anything interesting though, you can also interact with the game. To do so, before the loop you can do :

nbLegalActions = amle.getNbLegalActions()
legalActions = np.empty(nbLegalActions, dtype=np.int32)
amle.getLegalActions(legalActions)
legalActions = legalActions.tolist()

And then in the loop :

import amle_py
import random
# The previous code discussed
while not(amle.gameOver()):
    amle.act(random.choice(legalActions))
    amle.step()

Finally, you may want to generate the documentation for the library. To do so go in the amle_py folder and run :

$ pydoc -w amle_python_interface.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amle-py-1.1.5.tar.gz (8.9 MB view details)

Uploaded Source

Built Distribution

amle_py-1.1.5-py3-none-any.whl (9.0 MB view details)

Uploaded Python 3

File details

Details for the file amle-py-1.1.5.tar.gz.

File metadata

  • Download URL: amle-py-1.1.5.tar.gz
  • Upload date:
  • Size: 8.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

File hashes

Hashes for amle-py-1.1.5.tar.gz
Algorithm Hash digest
SHA256 3451ad0b7e05e36619153c020fde3e9b623cccfe9562473196439fc7e0734d2a
MD5 ab4bd2f7fcafeb7584580e2579a3e67c
BLAKE2b-256 310796d48076af34a30f35d0cfeee3f2a1f789218d1239cc6b677c758033713a

See more details on using hashes here.

File details

Details for the file amle_py-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: amle_py-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.9

File hashes

Hashes for amle_py-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 88d0a0fe4c7b3a09745b465f927959ca9d137ddbafc22152d66d392c41843693
MD5 c8f9aff96ce416023f669708b9a0c913
BLAKE2b-256 fcb78d3f13b3924f0dc25273d7a56b5c84ffd1a7f0b6a1e4957c3e21cdfd3ff7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page