This simulation is similar to the [url=http://www.phy.ntnu.edu.tw/ntnujava/viewtopic.php?t=226]traffic light contril[/url] I have created many years ago.
But I rewrited it with ejs.
Each square represent a car. It could be painted with three different color depends on it's acceleration a.
1. a>0 (yellow): when there is no car in front of it or the car in front is far away (the distance is more than d[sub]min[/sub]) and the street light is not red.
2. a=0 (green): it will keep move with the same speed when it reach maximum speed.
3. a<0 (red): when the street light turn red or the car in front is too close (distance < d[sub]min[/sub]).
d[sub]min[/sub]= v* t[sub]reaction time[/sub], where t[sub]reaction time[/sub] is the reaction time of the driver.
You can click the +/- sign to change the time delay between traffic lights.