matthewp / robot

🤖 A functional, immutable Finite State Machine library
https://thisrobot.life
BSD 2-Clause "Simplified" License
1.92k stars 88 forks source link

Deadly traffic light #167

Closed hypeJunction closed 2 years ago

hypeJunction commented 3 years ago

https://github.com/matthewp/robot/blob/4f242ae4976215c58cdc367db1a7fc2bc63263d3/demos/stoplight.js#L3

So I was looking at that example and was lost for a minute. A traffic light goes from green to yellow to red to yellow to green. In your example it just loops.

matthewp commented 3 years ago

Is this a cultural thing? In the U.S. traffic lights do not go from red to yellow to green.

hypeJunction commented 3 years ago

Woah. I have learnt something new today. From a pedestrian perspective seems quite dangerous that there is no warning that cars are about to run over you, but then again US has no pedestrians, so I suppose it's cultural. https://m.youtube.com/watch?v=bznLyIHX7nA

matthewp commented 3 years ago

We have a separate pedestrian light that usually counts down from 10 when it is about to turn red. There's even an example of such a crosswalk here: https://thisrobot.life/guides/nested-states.html (though without the countdown)