Skip to main content

RacingEnv

A simple 2D racing environment using gymnasium

Installation

Requirements python 3.8+, C++17 compiler

Package requirements:

  • scikit-build-core >=0.4.3
  • nanobind >=1.3.2
  • gymnasium>=0.26.0
  • pygame>=2.1.0
  • numpy>=1.19

Registered Environments

The package registers three environments

  1. racingenv/Racing-v1
  2. racingenv/Racing-features-v1
  3. racingenv/Racing-pixels-v1

Environment Arguments

The environment can be customized using the following kwargs:

  1. render_mode
    • human
    • rgb_array
    • debug
    • agent
  2. obs_type (this should only be specified when using racingenv/Racing-v1)
    • pixels
    • features
  3. resolution, a tuple of the form (width, height) (Note that, when training the agent on pixels, the resolution will affect the observation returned by the environment)
  4. pyhsics_settings, a dictionary containing the physics settings (a more details below)
  5. map, path to a map file (again more details below)

Feature Space

The environment defines the following features (Shape 37x1):

  • Agent x-position [0.0, 1.0]
  • Agent y-position [0.0, 1.0]
  • Agent normalized x-direction [-1.0, 1.0]
  • Agent normalized y-direction [-1.0, 1.0]
  • Distance to the inner bound of the next checkpoint or MAX_RAY_LENGTH [0.0, 1.0]
  • Normalized x-direction to the inner bound of the next checkpoint [-1.0, 1.0]
  • Normalized y-direction to the inner bound of the next checkpoint [-1.0, 1.0]
  • Distance to the outer bound of the next checkpoint or MAX_RAY_LENGTH [0.0, 1.0]
  • Normalized x-direction to the outer bound of the next checkpoint [-1.0, 1.0]
  • Normalized y-direction to the outer bound of the next checkpoint [-1.0, 1.0]
  • Agent forward velocity [-1.0, 1.0]
  • Agent angular velocity [-1.0, 1.0]
  • Agent lateral velocity [-1.0, 1.0]
  • For each of the 8 rays
    • Distance to the intersection or MAX_RAY_LENGTH if no intersection occurred [0.0, 1.0]
    • x-position of the intersection or the furthest point that could be an intersection [0.0, 1.0]
    • y-position of the intersection or the furthest point that could be an intersection [0.0, 1.0]

Pixel Space

Image scaled down to 64x64 as np.array. (Shape 12288x1)

Rewards

On the track there are several checkpoints that can only be taken in order, passing a checkpoint gives the agent a one time reward of 1.0. Hitting a wall gives the agent a reward of -1.0. Should the agent ever come to a complete standstill the environment will truncate.

Physics settings

There are several physics settings that can be customized by passing a dictionary when creating the environment, which needs to specify all the keys below:

  • max_velocity, the maximum possible forwards or backwards velocity of the agent
  • acceleration, the acceleration applied by the forward and backward action
  • drag, drag applied every frame the agent is not accelerating
  • max_lateral_velocity, maximum velocity in the lateral direction (aka. drift)
  • lateral_acceleration, acceleration in lateral direction
  • lateral_drag, drag applied in the lateral direction
  • angular_velocity, strength of the agents steering
  • drift_threshold, minimum lateral velocity needed to drift

Custom maps

In progress

Rendering Modes

The environment supports 4 rendering modes

Human

Implements human rendering, additionally a resolution tuple (width, height) maybe be passed when creating the environment via resolution=(width, height).
human

RGB_Array

Renders the same frame as in human mode, but the resolution is fixed to be 800 by 600, additionally render() returns the frame as np.array instead of blitting it onto the screen.

Agent

Renders the game in the same way the agent "sees" it. agent

Debug

Human rendering with additional debug information. debug

Credits

The AE86 sprite has been created by u/cropmania.
This environment was created as part of the Fachprojekt Applied Deep Reinforcement Learning at TU-Dortmund.

Metadata

Release files for racingenv 2.0.4

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

Source distribution (sdist)

Source distribution for racingenv 2.0.4
File Size Uploaded Provenance
racingenv-2.0.4.tar.gz 44.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for racingenv 2.0.4
File Interpreter ABI Platform
racingenv-2.0.4-cp312-abi3-manylinux_2_35_x86_64.whl CPython 3.12 abi3 Linux glibc 2.35+ x86-64 Details

Total release size: 131.3 kB

Release files / racingenv-2.0.4.tar.gz

Download URL racingenv-2.0.4.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
517c41996a4ee3706eb79869f99bb4b790e426269e8973f576fc98a3d678d9db
BLAKE2b-256 checksum
How to use checksums
0c08355368dace8507166f02ab8eeb7fa28e91702c2e0d6945f9ce597d9663fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / racingenv-2.0.4-cp312-abi3-manylinux_2_35_x86_64.whl

Download URL racingenv-2.0.4-cp312-abi3-manylinux_2_35_x86_64.whl
Size 86.6 kB
Tags CPython 3.12 Linux glibc 2.35+ x86-64 abi3
SHA-256 checksum
How to use checksums
f35001c07c6bd8f76f28d42867d298b94e01801532c7d61dc614c3f57e2c1ba3
BLAKE2b-256 checksum
How to use checksums
6f4e73fc4f87ffd43042035a114103504a0a8119d974145505bade2d68a9b641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Security for racingenv 2.0.4

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.

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