I. 182. Prepare your program to simulate the motion of cars in a roundabout using a character display. The roundabout connects two perpendicular roads. Roads are numbered from 1 to 4 anticlockwise. If a car plans to travel further on road nafter it has left the roundabout, it is marked with that number n. (A car can also turn back: the incoming road segment can be the same as the outgoing one after one full round.)
In each simulation step a new car appears with probability pi (i4) at the beginning of each lane on the border of the grid (provided that the first square of the ith road is free). These probabilities are real numbers between 0 and 1, and are given as the first four command line arguments to your program. Cars move with constant speed until the next square in front of them is free. If they catch a slower car, the faster one temporarily adjusts its speed to the slower one. Speeds are expressed by integers between 1 and 5. Value 1 means that the car moves forward in each step (if possible), while 5 means it tries to proceed forward only in every fifth step, otherwise it stays at rest. Cars waiting to enter the roundabout should give way to those already in there. Outgoing cars disappear on the border of the grid (see the figure).
When SPACE is pressed, the simulation should stop. Keys from 1 to 9 control the speed of your simulation.
The source code of your program (i182.pas, i182.cpp, ...) and a short documentation (i182.txt, i182.pdf, ...) should be submitted containing a description of your solution and specifying the developer environment to compile your code.
Deadline expired on 15 April 2008.