Package: racingenv
RacingEnvA simple 2D racing environment usinggymnasiumInstallationRequirementspython 3.8+,C++17 compilerPackage requirements:scikit-build-core >=0.4.3nanobind >=1.3.2gymnasium>=0.26.0pygame>=2.1.0numpy>=1.19Registered EnvironmentsThe package registers three environmentsracingenv/Racing-v1racingenv/Racing-features-v1racingenv/Racing-pixels-v1Environment ArgumentsThe environment can be customized using the following kwargs:render_modehumanrgb_arraydebugagentobs_type (this should only be specified when usingracingenv/Racing-v1)pixelsfeaturesresolution, 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)pyhsics_settings, a dictionary containing the physics settings (a more details below)map, path to a map file (again more details below)Feature SpaceThe 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 raysDistance 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 SpaceImage scaled down to 64x64 asnp.array. (Shape 12288x1)RewardsOn 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 settingsThere 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 agentacceleration, the acceleration applied by the forward and backward actiondrag, drag applied every frame the agent is not acceleratingmax_lateral_velocity, maximum velocity in the lateral direction (aka. drift)lateral_acceleration, acceleration in lateral directionlateral_drag, drag applied in the lateral directionangular_velocity, strength of the agents steeringdrift_threshold, minimum lateral velocity needed to driftCustom mapsIn progressRendering ModesThe environment supports 4 rendering modesHumanImplements human rendering, additionally a resolution tuple (width, height) maybe be passed when creating the environment viaresolution=(width, height).RGB_ArrayRenders the same frame as in human mode, but the resolution is fixed to be 800 by 600, additionallyrender()returns the frame asnp.arrayinstead of blitting it onto the screen.AgentRenders the game in the same way the agent "sees" it.DebugHuman rendering with additional debug information.CreditsThe AE86 sprite has been created byu/cropmania.This environment was created as part of the FachprojektApplied Deep Reinforcement Learningat TU-Dortmund.