Class FrictionDetector
- Namespace
- Gym.Environments.Envs.Box2D
- Assembly
- Gym.Environments.dll
Gymnasium's FrictionDetector: CarRacing's contact listener. Any contact with a tile recolours the tile with the
road colour; a wheel's contact adds the tile to the wheel's tiles (removed when it ends), and a tile's first visit
pays 1000/N to the score and may complete the lap.
public sealed class FrictionDetector : b2ContactListener
- Inheritance
-
FrictionDetector
- Inherited Members
- Extension Methods
Remarks
Public, as Gymnasium's is a module-level class whose name no other env shares (DR-28 keeps only the duplicated
ContactDetector private). Reference:
gymnasium/envs/box2d/car_racing.py.
Constructors
FrictionDetector(CarRacingEnv, double)
A detector for an env.
public FrictionDetector(CarRacingEnv env, double lapCompletePercent)
Parameters
envCarRacingEnvThe env.
lapCompletePercentdoubleThe share of the track's tiles that, visited when the start tile is reached, completes the lap.
Exceptions
- ArgumentNullException
Thrown when
envis null.
Properties
Env
Python's env.
public CarRacingEnv Env { get; }
Property Value
LapCompletePercent
Python's lap_complete_percent.
public double LapCompletePercent { get; }
Property Value
Methods
BeginContact(b2Contact)
A contact begins: _contact(contact, True).
public override void BeginContact(b2Contact contact)
Parameters
contactb2ContactThe contact.
EndContact(b2Contact)
A contact ends: _contact(contact, False).
public override void EndContact(b2Contact contact)
Parameters
contactb2ContactThe contact.
Exceptions
- KeyError
Thrown when a wheel loses a tile it did not have, as Python's
set.removeraises.