Sunday, April 10, 2011

Using Lanes to Determine Traffic Flow

Since The last post I have included the concept of lanes to direct traffic because it is more realistic and will make the results of tests more accurate.  I will explain how this works through an example.
The concept of lanes is evaluated during the execution of the DIRECTION_SELECT event.  At the beginning of the event, the car is in the lane represented by the blue arrow, and came from the arrow represented by the red arrow.  The blue arrow represents the incoming right turning lane on the east side of intersection 1.  Because the blue lane is a right turning lane, the car can only go either north or back east, the objective of DIRECTION_SELECT is to determine which of the north three lanes the car wishes to enter or sending the car back east.  To choose one of the outgoing north lanes, the event first checks if the car wants to go north or south to get to its destination, if it wishes to go north and the center green north lane is free, it will enter that lane, the same is true for the left and right turning lanes.  If the car however cannot enter either of these three lanes going north it will be sent back east to simulate a traffic jam.  To determine which lane the car enters of the three outgoing east lanes, the event must determine how the car arrived at the previous intersection (intersection 2) this is to ensure that there is not an excess of cars in any lane.  The orange arrows represent the possible ways the car arrived at intersection 2 and by determining which of these was true, the car is placed in the appropriate outgoing lane to send the car back in the direction it came from.

The next step in coding is to code the reverse event handler which is used to "undo" events when rollbacks occur, this should bee done by the end of the week.

No comments:

Post a Comment