Python framework for running reproducible experiments using OpenTTD
Project description
OpenTTDLab •
Python framework for running reproducible experiments using OpenTTD. 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
- Granularity of output
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
pip install OpenTTDLab
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_experimental_config = setup_experiment(config=config, allow_platform_difference=True)
# Run the experiment and get results
results = run_experiment()
print(results)
API design considerations
- Mutability is avoided
- Impure functions are avoided
- In terms of the user-facing API, keeping it mostly OOP-free, and deliberately focused on key behaviour
- Designed so if type checking were in place and passes, API misuse should be close to impossible
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
Built Distribution
Hashes for openttdlab-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1033c2b535589f448ced6f0c2e7fa7d189f14b14efee52477169c962f91f65f7 |
|
MD5 | c560bf9244ddb75715ef0b9de307011f |
|
BLAKE2b-256 | 5cfea9f9520d001bd81d863d5259f32ae144fe4f2812753e26d45bca5b706f68 |