I. 150. There are N cars (a few hundred) waiting at a traffic lamp. The lamp shows green for 45 seconds, then red for 15 seconds. Make a program to graphically simulate cars crossing the intersection. Cars are depicted as rectangles: the shorter side (width) has a constant length, while the longer side (length) has a random length. The acceleration is inversely proportional with the length of the car. The shortest car has length of 2 meters and accelerates to 100 km/h in 4 seconds, while the longest one has length of 20 meters and accelerates to this speed in one minute. The first car at the traffic lamp starts immediately when the green signal appears, with its maximal acceleration, until it reaches the maximal allowed speed (50 km/h). The next car starts after 1 second and accelerates according to its preset parameters (but its acceleration can not exceed that of the first car). If a car approaches another car within 20 meters, it immediately brakes and stops exactly 2 meters behind the first car. If the traffic lamp changes to red when the car is already within stopping distance (20 meters), then the vehicle proceeds further and crosses the intersection. Otherwise, if the car has enough time, then it brakes immediately and stops exactly at the lamp. You should update the position of the cars in every second. A car disappears when it has crossed the intersection, while the other cars behind it appear gradually until the queue of cars disappears. (The random length of this queue is determined in advance.) Cars in front of the traffic lamp should fill approximately 80% of the screen, while cars that have already crossed the intersection should occupy the remaining 20%.
The source code with appropriate documentation should be submitted.
Deadline expired on 15 February 2007.