Question: Our simulation is controlled by a discrete timer. The granularity of the timer units determines the granularity of the road surface and the atomic car
Our simulation is controlled by a discrete timer. The granularity of the timer units determines the
granularity of the road surface and the atomic car movement increments. Each car occupies two
square units of the road surface and can move one unit forward during one timer cycle. These
square units places form the basis of our simulation.
Place Class
This class is at the heart of the entire program. Each place represents one patch of asphalt on the
road. It contains four pointers to other places adjacent to this one. The pointers contain valid links
only if travel in that direction is permitted. So all places in the northbound lane except for the
last one will have links to their neighbors north of them, but no other links. When we start building
intersections, the places where two directions of travel cross will have links to both neighbors. A
place can be blocked if it is occupied by a car or if the light ahead is not green.
To display a place eg after a vehicle moved away we also need to record its physical location
in the display. Because the whole display can be treated as a grid specifying the row and column
information is sufficient.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
