Gymnasium environment for risky decision-making

Home

Crosswalk Task

Crosswalk Task is a naturalistic reinforcement learning paradigm for studying risk taking through real-time decision making. Inspired by road-crossing games such as Crossy Road and Frogger, participants cross roads while avoiding collisions with vehicles. The task introduces crosswalks, requiring participants to continuously choose between jaywalking as a risk-taking strategy and using crosswalks as a risk-averse strategy.

CrosswalkEnv PyPI version GitHub

CrosswalkEnv is the Python/Gymnasium implementation of the Crosswalk Task. It is designed as an integrated framework for human behavioral data collection and reinforcement learning model training.

Behavioral experiments with human participants can be launched with a single function call:

from crosswalk_env import task

task.run_session(subj_id=1000, session_id=1, max_seconds=1200)

Because CrosswalkEnv follows the standard Gymnasium API. State–action trajectories collected from human participants can be used to fit models using approaches such as imitation learning (IL) and inverse reinforcement learning (IRL). The environment can also be used directly to train and evaluate reinforcement learning agents without human data:

import gymnasium as gym
import crosswalk_env

gym.register_envs(crosswalk_env)
env = gym.make("crosswalk-v1")
for _ in range(5):
    obs, info = env.reset()
    while True:
        # choose an action according to a policy (random policy for demonstration)
        action = env.action_space.sample()
        obs, reward, terminated, truncated, info = env.step(action)
        if terminated or truncated:
            break

env.close()

CrosswalkWebEnv npm version GitHub

CrosswalkWebEnv is a React-based web implementation of the Crosswalk Task, designed for deploying experiments online and collecting behavioral data at scale. It records state–action trajectories in the same format as CrosswalkEnv, allowing collected data to be used directly for downstream model training and analysis, including imitation learning (IL) and inverse reinforcement learning (IRL).

import ExperimentPage from 'crosswalk-web-env';

export default function App() {
  return (
    <ExperimentPage subjectId={1000} sessionId={1} maxSeconds={1200} localSave={true} />
  );
}

How to cite this work?

If you use this package, please consider citing it with this piece of BibTeX:

@misc{crosswalktask,
  title        = {Crosswalk Task: A naturalistic reinforcement learning paradigm for characterizing real-world risky behavior},
  author       = {Jeong, Jinwoo and Ahn, Woo-Young},
  year         = {2026},
  howpublished = {Research Square},
  note         = {Preprint},
  doi          = {10.21203/rs.3.rs-11343272/v1},
  url          = {https://doi.org/10.21203/rs.3.rs-11343272/v1}
}