Skip to main content

Core library for Retro Speedlab: A high-performance RL toolkit for classic games.

Project description

datenwissenschaften

Python 3.12 License: GPL-3.0

The reinforcement-learning engine behind Retro Speedlab.

datenwissenschaften turns classic-game emulators into reproducible training systems. It provides visual and state-aware environments, recurrent and evolutionary agents, parallel execution, durable checkpoints, episode recording, and a live browser dashboard in one focused Python package.

This repository contains the reusable engine. For game runners, end-to-end examples, and user-facing documentation, start with Retro Speedlab.

Why this engine

  • Exploration for sparse rewards — multi-input CNN-LSTM PPO combines visual frames, normalized RAM, temporal memory, and normalized, clipped, annealed Random Network Distillation (RND).
  • State-aware neuroevolution — NEAT trains and routes independent controllers across declared game states.
  • Efficient execution — vectorized environments, automatic worker selection, CUDA tuning, and CPU fallback.
  • Reliable training runs — atomic checkpoints, resumable model state, automatic savestates, and .bk2 replay capture.
  • Operational visibility — a local Vue dashboard reports episode outcomes, reward distributions, environment details, PPO parameters, RND progress, and NEAT generations.
  • Game-oriented infrastructure — ROM discovery, RAM models, state machines, visual encoders, and configurable action translation.

Model choices

Model Best suited to Characteristics
RecurrentRNDModel Sparse-reward NES games and partially observable state Automatic visual + RAM inputs, NES-tuned recurrent PPO, LSTM memory, intrinsic RND exploration
NEATModel Compact engineered features and explicit state-by-state evolution Separate populations and winning controllers per training state
Custom SB3 model Experiments that need a standard Stable-Baselines3 algorithm Integrates through the same builder, trainer, callbacks, and dashboard

RecurrentRNDModel is the recommended starting point for visual agents. RND encourages the policy to visit novel observations, while its influence decays during training so learned external rewards increasingly drive behavior. The predictor, fixed target, optimizer, reward statistics, and annealing progress are all preserved in checkpoints. Selecting it also clears incompatible per-game NEAT artifacts before loading or creating the recurrent model. Environment wrappers always use RGB observations and one emulator step per selected action; these are fixed engine defaults rather than game-level options. The default profile uses longer 512-step rollouts, a 512-unit LSTM, gamma=0.999, gae_lambda=0.98, and a slower 10-million-step RND decay. These settings preserve more temporal context and delayed reward information than the shorter arcade baseline while retaining conservative PPO updates.

Set training.savestate_beaten_threshold to the number of victories required before a training state is marked as beaten and the next automatic savestate is promoted. Each <State>.beaten file stores the current victory count; the default threshold is 1.

Installation

The package requires Python 3.12.

pip install datenwissenschaften

For local development:

git clone https://github.com/datenwissenschaften/datenwissenschaften.git
cd datenwissenschaften
poetry install
cp config.example.yaml config.yaml

Training dashboard

Enable the dashboard with ui.enable: true, then open http://127.0.0.1:18080. It refreshes live training telemetry without interrupting the learners and distinguishes between PPO + RND and NEAT runs.

Dashboard history is restored from and atomically persisted to models/<game>/<savestate>/history.json. The ui mapping accepts enable, host, port, and max_episodes. Episode history is unlimited by default; set max_episodes to a positive integer to impose a limit. Binding to 0.0.0.0 makes the dashboard reachable on the local network; use that only on a trusted network and open it through the machine's actual IP address.

How a run fits together

  1. A game package defines RAM structures, training states, rewards, and action translation.
  2. The environment factory creates vectorized emulator workers and processed visual observations.
  3. A model builder creates or restores the selected policy.
  4. The trainer coordinates learning, checkpoints, replay capture, telemetry, and optional uploads.
  5. The dashboard exposes the active run without coupling the learner to a separate monitoring service.

Development

Run Python quality checks:

ruff check src
black --check src
python -m compileall -q src

Build the dashboard assets after changing the Vue frontend:

cd src/datenwissenschaften/ui/frontend
npm ci
npm run build

License

Copyright © datenwissenschaften contributors. Distributed under the GNU General Public License v3.0.

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

datenwissenschaften-1.11.3.tar.gz (116.4 kB view details)

Uploaded Source

Built Distribution

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

datenwissenschaften-1.11.3-py3-none-any.whl (138.3 kB view details)

Uploaded Python 3

File details

Details for the file datenwissenschaften-1.11.3.tar.gz.

File metadata

  • Download URL: datenwissenschaften-1.11.3.tar.gz
  • Upload date:
  • Size: 116.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for datenwissenschaften-1.11.3.tar.gz
Algorithm Hash digest
SHA256 fa1f2f2fb94f5afc8560cc61f6cfe9df27b138c7a07b9b3a895aa4201e8fdc5f
MD5 a349a42b1d6eb26edeee9f99a9b0d17a
BLAKE2b-256 c1c1be8b2bc23a8a9b756cca78ac8a5f39f6a1bb48d08f5cddfc8fb450f6f623

See more details on using hashes here.

File details

Details for the file datenwissenschaften-1.11.3-py3-none-any.whl.

File metadata

  • Download URL: datenwissenschaften-1.11.3-py3-none-any.whl
  • Upload date:
  • Size: 138.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1018-azure

File hashes

Hashes for datenwissenschaften-1.11.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3c01c0e1df8cda8dd669f99a2432c35a084c4d79847a57aa7737f06fde892acf
MD5 2d21d6022ffd3f00dee5f0a030e3da2f
BLAKE2b-256 e6257962af7f258262f9d13c0be07438f64f08f37df6f64b517d7309742b7827

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