Skip to main content

gym-racer

OpenAI gym environment of a racing car.

Action space

The action space is a combination of two discrete action spaces:

1) accelerate:  NOOP[0], UP[1], DOWN[2]
2) steer:  NOOP[0], LEFT[1], RIGHT[2]

Reward

The reward is mainly related to the direction along the street, then multiplied by the speed of the car squared.

Observation space

There are two types of observation possible:

  • lidar with shape (n): a lidar with n rays, each element indicates the first sensor out of the road
  • diamond with shape (n, n): a square of sensors, with a corner on the car

The observation type can be set by passing it in the call to gym.make, and the default parameters can be overridden by passing a sensor_array_params dict:

sat = "lidar"       # default
#  sat = "diamond"
racer_env = gym.make(
    "racer-v0",
    sensor_array_type=sat,
    sensor_array_params=sensor_array_params,
)

The default parameters for the lidar are:

sensor_array_params["ray_num"] = 7               # number of rays per side
sensor_array_params["ray_step"] = 15             # distance between sensors along a ray
sensor_array_params["ray_sensors_per_ray"] = 20  # number of sensors along a ray
sensor_array_params["ray_max_angle"] = 70        # angle to sweep left/right

The default parameters for the diamond are:

sensor_array_params["viewfield_size"] = 20  # number of rows/columns in the sensor
sensor_array_params["viewfield_step"] = 10  # spacing between the dots

Render modes

There are two types of render mode available, the human mode initializes pygame and renders what the car is doing to the screen, while in console mode only the bare minimum of the pygame environment is loaded (to use spritecollide). An environment in console mode cannot be rendered as human.

The render mode can be set by passing it in the call to gym.make:

mode = "human"       # default
#  mode = "console"
racer_env = gym.make(
    "racer-v0",
    render_mode=mode,
)

Info

Info is a dict with some car details:

keys = ["car_pos_x", "car_pos_y", "car_dir", "car_speed"]

Metadata

Release files for gym-racer 0.0.2

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

Source distribution (sdist)

Source distribution for gym-racer 0.0.2
File Size Uploaded
gym_racer-0.0.2.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gym-racer 0.0.2
File Interpreter ABI Platform
gym_racer-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / gym_racer-0.0.2.tar.gz

Download URL gym_racer-0.0.2.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e17d8eb58d5fcc9ce5be22945a6573eb5babf460ed4f199e3256ead162393e9e
BLAKE2b-256 checksum
How to use checksums
e9e389afb2de9a49d077b60ea16fc1d8ba73e25d429692752c26fe944062248c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

Release files / gym_racer-0.0.2-py3-none-any.whl

Download URL gym_racer-0.0.2-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
672e3fdce9747e5cfb021a4938342ed35fb80cca997bbf9bf5bad034ebaf43d0
BLAKE2b-256 checksum
How to use checksums
ec9c58528a6373d5b9000c14869df4f53bb6d446a96038b56551bcaf65a1fc4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

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