Skip to main content

Python framework for running reproducible experiments using OpenTTD

Project description

OpenTTDLab logo

OpenTTDLab - Run reproducible experiments using OpenTTD

PyPI package Test suite Code coverage


OpenTTD is a Python framework for running reproducible experiments using OpenTTD, and extracting results from them. An experiment in OpenTTDLab terms is the combination of:

  • Exact version of OpenTTD, any AIs used, and OpenTTDLab itself
  • Ranges of values for OpenTTD config settings, command line arguments and random seed

This can be configured/extracted for each experiment in either machine or human readable forms, for use in code or publishing respectively.

OpenTTDLab is based on TrueBrain's OpenTTD Savegame Reader, but it is not affiliated with OpenTTD.

[!NOTE] Work in progress. This README serves as a rough design spec.

Installation

OpenTTDLab is distributed via PyPI, and so can usually be installed using pip.

python -m pip install OpenTTDLab

OenTTDLab itself requires additional binaries:

  1. unzip
  2. (Linux only) tar
  3. (macOS only) 7-zip

The only one of these not likely to already be installed is 7-zip. To install 7-zip on macOS, first install Homebrew, and then use Homebrew to install the p7zip package that contains 7-zip.

brew install p7zip

You do not need to separately download or install OpenTTD (or OpenGFX) in order to use OpenTTDLab. OpenTTDLab handles downloading them, which is the reason OpenTTDLab requires the binaries mentioned above.

Running an experiment

The core function of OpenTTD is the setup_experiment function.

from openttdlab import setup_experiment, save_config

# If necessary, this will download the latest OpenTTD
run_experiment, get_config = setup_experiment()

# Run the experiment and get results. This may take time
results = run_experiment()
print(results)

# The information needed to reproduce the experiment
config = get_config()
print(config)

# Which can be saved to a file and then shared
save_config('my-config.yml', config)

Reproducing an experiment

If you have the config from a previous experiment, you can pass it into setup_experiment to exactly reproduce

from openttdlab import setup_experiment, load_config

# Load the config from file
config = load_config('my-config.yml')

# allow_platform_difference=True will allow experiments from a platform other than the one
# the original experiments were performed on. Otherwise, setup_experiment may error because
# the exact same OpenTTD will not be able to be run on this platform
run_experiment, get_config = setup_experiment(config=config, allow_platform_difference=True)

# Run the experiment and get results
results = run_experiment()
print(results)

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

openttdlab-0.0.10.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openttdlab-0.0.10-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file openttdlab-0.0.10.tar.gz.

File metadata

  • Download URL: openttdlab-0.0.10.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for openttdlab-0.0.10.tar.gz
Algorithm Hash digest
SHA256 71f44a959c5eaadbe074caf05e645d4875b48784d2a6c56aca5f59dc57dbc312
MD5 7943d72efdc23a2eee107d898eb58996
BLAKE2b-256 29c6720284004e2f08ae73b803eca435eb559828e71601bac9991a8ee8df9894

See more details on using hashes here.

File details

Details for the file openttdlab-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: openttdlab-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for openttdlab-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 e3e6b9e771a9fb16a6eef337493fe7e6ecb5a05e8b2071057876fc5ed69e1b8d
MD5 05aa8e91013981aadcba5751d6aa9358
BLAKE2b-256 b5d947b15db98c105dc6c738a72d2e22073b1bb6119d37bc1b3fde90662355a3

See more details on using hashes here.

Supported by

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