Herewith source code accompanying the "Computing Science" column "Playing in Traffic," by Brian Hayes, American Scientist 103(4):260–263 (July–August 2015). The column is available on the American Scientist website in HTML or PDF. See also a related bit-player blog post.
And there's a publicly accessible running version of the simulator.