Skip to main content

A multi-agent reinforcement learning environment for probing the overlap of MARL and social sciences

Project description

🚇 Collective Crossing

Waiting Policy Demo

Tests Coverage mypy Documentation

A multi-agent reinforcement learning environment for simulating collective behavior in tram boarding/exiting scenarios. This project provides a grid-world environment where multiple agents interact to achieve their goals while sharing some resources together.

🎯 Overview

The CollectiveCrossingEnv simulates a minimal tram boarding scenario where coordination is essential to find the optimal collective behavior:

  • Boarding agents 🚶‍♂️ start in the platform area and navigate to the tram door
  • Exiting agents 🚶‍♀️ start inside the tram and navigate to the exit
  • Simple collision avoidance 🛡️ prevents agents from occupying the same space, which makes the passing through the tram door a bottleneck and a challenge
  • Configurable geometry 🏗️ allows customization of tram size, door position, and environment
  • Flexible reward system 🎁 supports multiple reward strategies (default, simple distance, binary)
  • Customizable termination ⏹️ configurable episode termination conditions
  • Adaptive truncation ⏱️ flexible episode truncation policies
  • Configurable observations 👁️ customizable observation functions and spaces

🚀 Quick Start

from collectivecrossing import CollectiveCrossingEnv
from collectivecrossing.configs import CollectiveCrossingConfig
from collectivecrossing.reward_configs import DefaultRewardConfig
from collectivecrossing.terminated_configs import AllAtDestinationTerminatedConfig
from collectivecrossing.truncated_configs import MaxStepsTruncatedConfig
from collectivecrossing.observation_configs import DefaultObservationConfig

# Create environment with configurable systems
reward_config = DefaultRewardConfig(
    boarding_destination_reward=15.0,
    tram_door_reward=10.0,
    tram_area_reward=5.0,
    distance_penalty_factor=0.1
)

terminated_config = AllAtDestinationTerminatedConfig()
truncated_config = MaxStepsTruncatedConfig(max_steps=100)
observation_config = DefaultObservationConfig()

config = CollectiveCrossingConfig(
    width=12, height=8, division_y=4,
    tram_door_x=6, tram_door_width=2, tram_length=10,
    num_boarding_agents=5, num_exiting_agents=3,
    render_mode="rgb_array",
    reward_config=reward_config,
    terminated_config=terminated_config,
    truncated_config=truncated_config,
    observation_config=observation_config
)

env = CollectiveCrossingEnv(config=config)
observations, infos = env.reset(seed=42)

📚 Documentation

🌐 Live Documentation - Complete documentation site

🎮 Key Features

  • Multi-agent simulation with boarding and exiting agents
  • Collision avoidance prevents agents from overlapping
  • Configurable geometry customizable tram and door positions
  • Ray RLlib compatible uses MultiAgentEnv API
  • Multiple rendering modes ASCII and RGB visualization
  • Type-safe configuration using Pydantic v2
  • Flexible reward system multiple reward strategies with custom configurations
  • Customizable termination configurable episode ending conditions
  • Adaptive truncation flexible episode timeout policies
  • Configurable observations customizable observation functions and spaces

🛠️ Installation

Quick Install with pip

pip install collectivecrossing

Development Install

# Clone and install
git clone git@github.com:nima-siboni/collectivecrossing.git
cd collectivecrossing
uv sync

See Installation Guide for detailed instructions.

🚀 Quick Deploy

# Deploy documentation to GitHub Pages
./scripts/docs.sh deploy

See Local Deployment Guide for details.

🧪 Testing

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov=collectivecrossing

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests
  5. Submit a pull request

See Development Guide for detailed contribution guidelines.

📄 License

This project is licensed under the Apache License 2.0.


Happy simulating! 🚇✨

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

collectivecrossing-0.1.2.tar.gz (25.9 MB view details)

Uploaded Source

Built Distribution

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

collectivecrossing-0.1.2-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file collectivecrossing-0.1.2.tar.gz.

File metadata

  • Download URL: collectivecrossing-0.1.2.tar.gz
  • Upload date:
  • Size: 25.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for collectivecrossing-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b343db4b4c420ffe03f27e1e0cb7750e07a8a9982f374f492bd0b6e9a5551cd3
MD5 9b90614745314e13c47c513e1672f623
BLAKE2b-256 3ba8e938f1d3db40caf21b1d1a24ffeb45dc1e972addc5ce9bf788dbc2119f2b

See more details on using hashes here.

File details

Details for the file collectivecrossing-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for collectivecrossing-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65e122f6d3c37ef6b83ed0b1e804ece6611f50014b4f6f9c62321f43bdebd519
MD5 76e6bad5e6255564b013e36f9b2206b0
BLAKE2b-256 735a71c17c229bf8ede60f17a67608b862663add91830e3dff45e7054c7484ce

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