Remarks about the sample run
Read through the example run
carefully to be sure you understand what's
going on at each time step.
Below are some things to notice about the output:
-
We begin with the crosswalk closed to pedestrians (and open to cars).
Therefore, the car that arrives at step 1 can go right through.
-
The acceleration of cars through the intersection is modelled.
For example,
After step 10, there are three cars waiting to go through
the intersection.
In subsequent steps, first one, then two
cars go through, as specified in the algorithm.
If there were any more cars left and the intersection didn't close to
cars, three would go through on the next step
(as occurs on steps 24, 25, and 26).
But there aren't any more cars and none arrive until step 15.
At that point not three, but five can go through
because this is the fifth step in which the intersection was open
to cars.
One could imagine other ways of modelling this situation,
but
be sure that you carefully follow the algorithm specified in the handout
when you write your code.
-
There can be many students with the same name.
For instance, there is a Tom with student ID number 1,
and another with ID number 20 (see steps 2 and 17).
They are two different people.
It is even possible for two people to have the same
name, college, and major,
but they can be distinguished by their ID numbers.
This is also true for cars.
-
The way the simulation is designed, the same student (or car) cannot
return to the crosswalk more than once.
-
Although the threshold for opening the crosswalk has been set to 5 students
by an input parameter,
there may be more than 5 students waiting when the crosswalk is opened.
At the beginning step 3, there are two students already waiting,
but then four arrive.
This group of six is more than enough to open the crosswalk.
-
Cars can be turned away.
At step 21, there are already three cars waiting in line
(with ID numbers 13-15),
and then three more try to arrive.
Only two can
(with ID numbers 16 and 17),
because an input parameter specifies that there is
only room for 5 cars on this piece of road.
The other car (ID 18) is assumed to have given up and taken another route,
so we forget about it.