You can assume that as the ArrayList of cars is iterated through, the
cars will move one at a time in the same sequence they were created.
One way to make the simulation insensitive to such
effects to to change the interface of agent from:
Agent { void run(double time); }
to
Agent { void setup(double time); void commit(); }
with the idea that these will always be called in alternation. The
main loop becomes:
for (t in times) {
for (a in agents)
a.setup(t)
for (a in agents)
a.commit()
}
And the car becomes something like this:
Car {
void setup(double time) {
_velocity = // newly computed velocity
}
void commit() {
_position += _velocity;
}

