The traffic simulation is designed to run with no input from the user. Since we are deliberately avoiding the complexities of coding a graphical user interface, we will hard-code the length of time
(number of seconds) the simulation runs as well as the relative percentages of cars, buses, trucks, bicycles, and pedestrians in all directions.
- Set the simulation to run for 600 seconds (ten minutes). You will need to construct a
SignalMediator, the four vehicle queues and the four vehicle factories that go with them.
- Make 10% of the vehicles in north and south bicycles, and the rest pedestrians. Use the default frequencies of cars, buses, and bicycles for the east and west roads.
- Assume that a "vehicle" enters from the north approximately once every one hundred seconds, from the south once every fifty seconds, from the east once every twenty seconds, and from the west once every thirty seconds.
Note that these are only average times.
- For output, every second (simulation seconds, not real seconds) list the current time, and the length and number of vehicles in the east and west queues and the combined number of pedestrians and bicycles in the north and south queues.
(Since pedestrians tend to bunch up, their queue length will almost always be effectively zero.)
In the text area below, type in or paste your answer and click the Submit