Simulating an Intelligent Traffic System in KSX

600px-Gridlock.svg_.thumb.pngThere are many concepts and methods available to us to perform a simulation in KSX. For the case of the Intelligent Traffic System we’re going to use some of the “agent” concepts previously discussed.

To begin with we’re going to create two prototype agents – a car and a traffic light and endow them with some basic behavior or rules and attributes. Here I’m showing the beginning of the creation of a system or simulation as we define it within KSX.

I have created a car and light object or agent which is seen in the attribute view within KSX.

Light attributes.png

So far I’ve given a light thirteen attributes: one for each direction for the amount of time in seconds that the light will be green, yellow or red. There is also an attribute for each direction that is the current number of cars in view and then there is an overall state attribute that describes the current state of the light.

car attributes.png

The car object or agent is very simple at this point. The x and y represent the car’s current position on a two dimensional grid. Then, the state of the car is defined by its current speed, direction and state such as breaking to stop, accelerating to speed lime, or slowing to turn right etc.

In my next blog I’ll start to write some simple rules for a light and car, thereby making them intelligent. Maybe we’ll ultimately even add a fuzzy speed controller for the car.