Saturday, January 3, 2015

Javascript Traffic Simulator

I wrote a javascript traffic simulator in which cars observe Left Hand Traffic give way rules (reference country: New Zealand).

My approach to modelling the give way rules is not for each car to know the rules, but for a car as it approaches an intersection to ask the intersection if it has right of way.  In real life this is akin to a controlled intersection where drivers wait to be directed by the intersection itself.  In uncontrolled intersections all drivers must understand and follow the give way rules, however if these are implicitly known the intersection effectively dictates who has right of way.