CHAPTER 4. CODING PROCESS
tions are done. The length of the road is set by CurveUtils.setupRoadSizes which
is called by EditModel.addRoad. To enlarge the length of the road, the length of
a block needs to be smaller. This is specified by Infrastructure.blockLength.
18
The change of the block-length has an influence on how the roadusers are drawn in
the simulator. The size of the roadusers are too big. Because the blocks shrinked
with a factor 10, the roadusers also should be a factor 10 smaller, but because of
visualization issues the width and length must be at least 1. The roadusers are
made a factor 3 smaller. With this configuration it is possible that roadusers seem
to get over eachother, but this is because of this problem. In the internal represen-
tation can be seen that the roadusers move correct.
The first testing gave strange results. When running the simulator it has been
observed that cars are staying in the middle of the street for some time. The inter-
nal representation of the positions of the road users were correct. The bug had to
be found where the road users are drawn. This is in the class Road. In the method
paintRoaduser the blocklength was hard-coded, which needed to be changed in
Infrastructure.blockLength. After testing it for a second time, everything worked
correctly.
4.3.2 Acceleration and deceleration of road users and respect-
ing stop-distance
Every road user has to respect the laws of physics. They accelerete and decelerate
when they are driving. The roads need a maximum allowed speed. When road
users enter a road with a higher maximum allowed speed than their current speed,
the cars need to accelerate. When a car in front of a road user is driving slower
and if the stop-distance has to be respected, the road user needs to slow down to
the same speed as the car in front of him and keep some distance.
Changing the code Every roaduser needs a rate at wich it can accelerate and
decelerate, the rate is called acceleration. Here the assumption is made that the
acceleration and deceleration have the same rate. The support of an emergency