Road regulation#

A RegulatedRoad is a Road in which the behavior of vehicles take or give the right of way at an intersection based on the priority lane attribute.

On such a road, some rules are enforced:

  • most of the time, vehicles behave as usual;

  • however, they try to predict collisions with other vehicles through the is_conflict_possible() method;

  • when it is the case, right of way is arbitrated through the respect_priorities() method, and the yielding vehicle target velocity is set to 0 until the conflict is resolved.


class highway_env.road.regulation.RegulatedRoad(network: RoadNetwork | None = None, vehicles: List[Vehicle] | None = None, obstacles: List[Obstacle] | None = None, np_random: RandomState | None = None, record_history: bool = False)[source]#

New road.

  • network – the road network describing the lanes

  • vehicles – the vehicles driving on the road

  • road_objects – the objects on the road including obstacles and landmarks

  • np_random (np.random.RandomState) – a random number generator for vehicle behaviour

  • record_history – whether the recent trajectories of vehicles should be recorded for display

step(dt: float) None[source]#

Step the dynamics of each entity on the road.


dt – timestep [s]

enforce_road_rules() None[source]#

Find conflicts and resolve them by assigning yielding vehicles and stopping them.

static respect_priorities(v1: Vehicle, v2: Vehicle) Vehicle[source]#

Resolve a conflict between two vehicles by determining who should yield

  • v1 – first vehicle

  • v2 – second vehicle


the yielding vehicle