Assignment Problem: Knowledge Representation and Engineering
Intelligent Crossing Roads:
In the new era of the Internet of Things (IOT) and autonomous cars (AC), a change in the control of crossing roads is expected that will replace all traffic lights by peer-to-peer communication between cars and crossing road controls (CRC). With these new intelligent crossings, cars will arrive in one of four possible directions (North, South, East, or West), they will communicate their arrival, and will wait in line until they are given the way. Two types of CRCs are expected to coexist implementing two alternative preference policies: (1) straight-right crossing (SRC) and (2) straight-right-left crossing (SRLC).
While, SRC allows a car to cross either following the same lane or turning to the right (see left hand figure where, for example, a car arriving from the north can continue to the south or right to the west), the SRLC control allows a car to cross following the same lane, but also turning either to the right or to the left (see the right hand figure where a car arriving from the south can continue to the north, to the east, or to the west).
![1812_Straight right crossing.jpg](https://secure.tutorsglobe.com/CMSImages/1812_Straight%20right%20crossing.jpg)
SRLC control follows a "the first car arriving is the first car crossing" strategy, this meaning that cars cross in the strict order in which they communicate arrival to the crossing. On the contrary, the SRC control rotates the crossing from North&South to East&West, in alternate turns, communicating to the N first cars in each two directions that they can cross. For example, if the turn is North&South, the first N cars waiting in the north, and the first N cars waiting in the south receive a permission to cross. If there are less than N cars waiting in one direction, only the orders to the waiting cars are sent. When all these cars have crossed, the round is given to the other two directions. When a car crosses, it notifies that to the system.
Implement the SRLC and the SRC as two separate set of rules in a Rule Production System with CLIPS. Implement also the arrival of cars, randomly from the north, south, east, and west, and run both CRC systems separately, to check a correct behavior. Pay special attention to the representation of the tokens describing the different states of a car: car arrives, car is waiting to get permission to cross, car got permission to cross, and car has passed. Adjust the intelligent rules for the management of both systems according to these tokens and others that the system may require. Use printout messages to see the correct dynamic evolution of cars arriving and crossing. Please, pay attention to the priority of the rules implemented.