Traffic simulation based on Nagel-Schreckenberg model with:
- n lanes
- traffic lights
- speed limits
- obstacles
- intersections
To run simulation:
python nagel.py config.someLights
Copy existing simulation in config
directory, and read the comments in sample configs.
In each iteration
- Car checks maximum speed it can achieve on it's current position (x, lane) and adjacent lane (x, lane+1).
- If the potential maximal speed on lane+1 is higher it checks safe conditions:
- There is no car car on (x, lane+2) to avoid collision caused by two parallel cars changing lane to lane+1.
- Distance to previous car on lane+1 is greater that it's speed to avoid emergency braking of previous car.
- Change lane with probability P.
Same steps for lane-1