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


OpenTTDLab 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

When run on macOS, OpenTTDLab has a dependency that pip does not install: 7-zip. To install 7-zip, 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 itself handles downloading them.

Running an experiment

The core function of OpenTTD is the run_experiment function.

from openttdlab import run_experiment, save_config

# Run the experiment and get results
results, config = run_experiment()

# Print the results...
print(results)

# ... and config
print(config)

# ... which can be saved to a file and then shared (or archived)
save_config('my-experiment-{experiment_id}.yml', config)

Reproducing an experiment

If you have the config from a previous experiment, you can pass it into run_experiment to exactly reproduce. If for some reason it cannot be reproduced, it will error.

from openttdlab import run_experiment, load_config

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

# ... and use it to run the same experiment
results, config = run_experiment(config=config)

print(results)

Licenses and attributions

OpenTTDLab is licensed under the GNU General Public License version 2.0.

OpenTTDLab is based on TrueBrain's OpenTTD Savegame Reader, also licensed under the GNU General Public License version 2.0.

The OpenTTDLab logo is a modified version of the OpenTTD logo. The OpenTTD logo is licensed under the GNU General Public License version 2.0.

The .gitignore file is based on GitHub's Python .gitignore file. This was originally supplied under CC0 1.0 Universal. However, as part of OpenTTDLab it is licensed under GNU General Public License version 2.0.

OpenTTD is authored by the OpenTTD team. OpenTTD is also licensed under the GNU General Public License version 2.0.

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.16.tar.gz (16.4 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.16-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openttdlab-0.0.16.tar.gz
  • Upload date:
  • Size: 16.4 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.16.tar.gz
Algorithm Hash digest
SHA256 c8a3d0510d876a1888c202c9c8d0b943dd80f0d3dcead9133ef9d1ef96ba9a51
MD5 2f3d4b8ed39e70dc60a2eb03ea17f89b
BLAKE2b-256 0820c3769c88f2535dbe8c4bcfc22fb0cc3ab42113bff55558e4978d77869dae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: openttdlab-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 15.9 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.16-py3-none-any.whl
Algorithm Hash digest
SHA256 04413a846adce98d721c7f5a3aa98a72048b7daa26c7864168d46d8a5a10b00b
MD5 46c6f468f519466a6040f2256b942cf8
BLAKE2b-256 e06fbfb0b6adf7ef098de0ab66719c00fe8a0ac57d79436b8d95a66d11804068

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