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.

Install From Source

  1. Clone the repository:

    git clone https://github.com/larrywhizz767-png/MetroGYM.git
    cd MetroGYM
    
  2. Sync the environment: uv will automatically create a virtual environment, install the correct Python version, and fetch all dependencies (including pygame and beartype).

    uv sync
    
  3. Verify the installation: Run a quick check to ensure everything is set up correctly:

    uv run python -m compileall src
    

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()

Local Documentation

To run the documentation locally, ensure you have the docs dependencies installed and run:

uv sync --group docs
uv run zensical serve

License

MetroGYM is licensed under the MIT License.

Metadata

Release files for metrogym 0.1.0

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.0
File Size Uploaded Provenance
metrogym-0.1.0.tar.gz 226.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 550.6 kB

Release files / metrogym-0.1.0.tar.gz

Download URL metrogym-0.1.0.tar.gz
Size 226.3 kB
Tags Source
SHA-256 checksum
How to use checksums
19d384fa5de498932316799aeec74745688152f101486de161119b88c7ec9e81
BLAKE2b-256 checksum
How to use checksums
09197addf6af93b2e5ee11cc66017e13dee1f0f6dd9fb6c0fbdde73afec57d36
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.0-py3-none-any.whl

Download URL metrogym-0.1.0-py3-none-any.whl
Size 324.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
830fa6c503106652491bccb9b9afa6f8df321a4547b147a30cddb735968e2ded
BLAKE2b-256 checksum
How to use checksums
f835be7e07c6f8be23daee672e73ddcd17682a2d4097f49f797207d146af2b2f
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.0

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.0 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