Roadworks is an alternative traffic light control system. There is only one lane of traffic and lights have been put up at either end. Using the control table you need to allow traffic to pass through the lights without accidents. This system also uses sensors that sense if there is traffic present or not.
On the main screen of Roadworks you have a grid containing 7 columns and 99 rows. You don’t need to use the 99 rows, but you must use all 7 columns. From left to right the columns are:
You can assign the following states: In the Light columns :
And in the sensor columns :
In the Delay column: the delay can be anything between 0 and 50 (in seconds) Each row of the table you have defined is examined in turn. If the light states and heat sensors values match the current row of your table then the lights will change to whatever you have specified in that row. For example if you had:
In this example: when the lights are green on the left and red on the right and there is a car on the right, but not at the left. Then this line will trigger, causing the colour of the lights to change to Red on the left, and green on the right. If a car arrives at the left now, the next line could be:
WHy is this the next line of code?
The new light state from the first example was....
this means that the next line of instruction start with...
It must also take account of the fact that there are no cars on the right but there are cars waiting on the left. this means that the next instruction line must also have...
the rest of the line of code simply states what happens next hence the next line to be followed would be
Each line that you add must start by matching the previous new light state and sensor state for it to be run. When you have completed the control table start the simulation by clicking on the Start button. Initially the lights and delay will be set to what you have specified in the first row. Cars will come at different intervals - depending on what is selected on the Options/Traffic dialog. Cars pass at different speeds, but they will always obey follow what the light indicates. i.e. they will not wait if the light shows green and a car is already coming down the road. On the event of a crash the simulation will stop running.
Task 1 create a simple set of codes to let traffic through without build ups of more than 2 cars per side.
Task 2 change the settings - go to the options menu then traffic.
Change setting to rush hour traffic. Modify the code to stop cars building up to anymore than 3 per side.
Task 3 change the settings again but this time change initial car build up to 24. do not allow traffic to build up to anymore than 10 per side.
|