Skip to main content


MetroGYM banner

A pure Python pygame MetroGYM teaching library for metro-network simulation and control logic — Documentation · GitHub · PyPi Index

About The Project

MetroGYM is a pure Python, pygame-powered teaching library for metro-network simulation, signalling, and control logic. It is intentionally small and inspectable: you build a network from primitives, attach train and signal agents, then run it visually or headlessly.

MetroGYM allows you to build complex metro systems from explicit primitives, then drive those worlds with typed train and signal solvers. It's designed for educational purposes, providing a clear and interactive way to understand transport network dynamics and algorithmic control.

See more in the documentation.

Installation

Prerequisites

Before you begin, ensure you have the following installed on your system:

  • Git: For cloning the repository.
  • uv: The recommended Python package and project manager. Install it via astral.sh/uv.

Installation

To install MetroGYM, please run the following:

pip install metrogym
# You can also use uv add metrogym

Getting Started

To build your first simulation, you define the world through a pipeline of explicit primitives:

  1. Initialise the System: Create a MetroSystem to manage the lifecycle and rendering.
  2. Define the Infrastructure: Use a Network to group your Line paths and Station locations.
  3. Attach Agents: Add a Train with a specific solver (the agent's brain) and a Signal that controls access to specific track segments.
  4. Build and Run: Call .fit() to validate the topology and .run() to start the interactive simulation.
from metrogym import Color, MetroSystem, signal, train
from metrogym.primitives import ControlRule, Line, Network, Signal, Station, Train

system = MetroSystem(name="Quick Start", render_scale=2).pipeline([
    Network([
        Line("Loop", Color.BLUE, [(120, 120), (560, 120), (560, 360), (120, 360), (120, 120)]),
        Station("West", (120, 120)),
        Station("North", (560, 120)),
        Station("South", (560, 360)),
    ]),
    Train("A", line="Loop", solver=train.always_proceed(), asset="metro_nose"),
    Signal(
        "North Gate",
        (560, 85),
        controls=ControlRule("Loop", (560, 120), (560, 360)),
        solver=signal.pulse(green_ticks=5, red_ticks=3),
    ),
])

system.fit().run()

License

MetroGYM is licensed under the MIT License.

Metadata

Release files for metrogym 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metrogym 0.1.1
File Size Uploaded Provenance
metrogym-0.1.1.tar.gz 225.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for metrogym 0.1.1
File Interpreter ABI Platform
metrogym-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 550.0 kB

Release files / metrogym-0.1.1.tar.gz

Download URL metrogym-0.1.1.tar.gz
Size 225.9 kB
Tags Source
SHA-256 checksum
How to use checksums
938c2023fc0bef532e84dff9364cdba118d3bc25efa78158525957faecf4540b
BLAKE2b-256 checksum
How to use checksums
22587e2b0ed62ff9861ad9f8d00f0b20484e14f100fd519b2b8bf7cfe8b19305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / metrogym-0.1.1-py3-none-any.whl

Download URL metrogym-0.1.1-py3-none-any.whl
Size 324.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
befcb68dcc25c4c2c1d9bd4aa55c5ff00f4a6838c8ad33760e991cd4d8c033be
BLAKE2b-256 checksum
How to use checksums
5e41e96b1d7a6d1f6536e3bcba06164f9b6cdb019be8be2ecec3674dd5295c52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for metrogym 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page