Traffic Simulation Applet
Written in Java, this traffic simulation applet illustrates autonomous vehicles. Requires Java:
Traffic Simulation Applet. Click to start and stop. Spacebar to add cars.
Each car drives autonomously and maintains a safe following distance.
With the default number of cars, they rapidly space themselves out and travel
smoothly at maximum speed. As cars are added, slowing behavior occurs, much as
we observe on a freeway as traffic density increases. Unlike a real freeway,
however, this simulation is only one lane and runs in a loop.
This Java source code is for educational purposes only. Viewing or downloading the source
implies your consent to obey the restrictions:
- Use the source code for educational purposes only.
- Give appropriate attribution in all executables and listings derived from this source.
- Reproduce these restrictions and conditions in any derived programs.
I agree to the restrictions and conditions on the source code.
Version 1.12, compiled July 4, 2008, with Sun JDK 1.6.
- Works around a bug introduced in the Java runtime engine (JRE) 1.5 that deflected the
focus for keyboard input (explicitly requests the focus after each mouse click).
- Reduces the starting lineup from 10 to seven cars.
- Adjusts simulation parameters to better avoid collisions.
- Inhibits overly rapid car creation.
This page established December 3, 2001; last updated July 12, 2010 by
Rick Wagner. Copyright © 2001-2010, all rights reserved.