The Traffic Light Example
You must encode, using Ticc, a traffic light controller. You can find a pre-built Ticc executable for linux at /projects/bubble/code/ticc/trunk/ticc . You can also copy /projects/bubble/code/ticc/trunk to any other machine and recompile. Follow the included instructions. The traffic light controller is composed of four units, which are identical except that signals may be renamed; you can use both local and global variables. Each unit is in charge of one of the 4 directions of traffic.
Inputs
Each unit has at least the following inputs. You may, or may not, do something when you receive one of these input actions: start from a minimal implementation that does not do anything, then improve it.
- walk_req: a pedestrial wants to cross the road.
- go_req: a car wants to go straight through the intersection (from a sensor under the road).
- turn_req: a car wants to turn left (from a sensor under the road).
Private variables
Each unit has at least the following boolean private variables, which in an implementation would be connected to lights. Some variables, marked with [1], are optional. First implement the rest, then worry about them.
- light_R : red light on
- light_Y : yellow light on
- light_G : green light on
- light_GL [1] : green left turn arrow on
- light_YL [1] : yellow left turn arrow on
- light_GW [1] : green pedestrial cross signal (otherwise, the red one is on)
Communication between units
You can use input and output signals (in addition to the above) for communication between units, as well as global variables.
Specification
Your solution should have the following properties:
- Each light (except for the pedestrial one) should follow the usual red, green, green and yellow, red, ..., cycle.
- A green straight light is compatible only with the green straight light from the opposite direction, or the green turn signal in the same direction.
- A green turn light is compatible only with the green straight light in the same direction, or the green turn light in the opposite direction.
- A pedestrian green light can be on only when no cars except from right-turning ones can cross the pedestrial walk, i.e., only cars turning right should be able to run over pedestrians.
