In a previous post, I mentioned Braitenberg vehicles; simple machines that exhibit life-like behavior. To better show the type of complex behavior that such simple circuits can yield, I made a simulator. I only tested it in Chrome, so apologies if it either does not work or look weird for you.

I made four preset examples to play with, but using the sliders you can do your own experiments. The vehicles can be dragged to move them, and rotated with the mouse wheel while dragging. You can also change the number of vehicles on the screen (hit apply).

no canvas for you!
Enter the number of vehicles for each color: red

The vehicles have the ability to sense each other, by color. Each vehicle is equipped with a left and a right sensor for each of the colors red, green and blue. By being colored themselves, the vehicles can respond to each other. The vehicles only sense forward. Their movement is directed by two driving wheels, that each are individually controlled by a mixture of their sensors. We can set how each of the sensors influence either wheel, by setting the ‘straight’ gain (left sensor to left wheel and right to right), and the ‘cross’ gain (right sensor to left wheel and the other way around). The gains go from -1 to 1, where -1 turns the wheel backwards, and 1 forwards. This quickly allows for very complex interaction.

The first example (attract & avoid) shows a blue vehicle that dislikes red vehicles, but loves green ones. For convenience, the red and green vehicles do not use their sensors at all, and thus do not move. The blue vehicle reacts to red vehicles by pushing all it senses on the left to the left wheel, and vice versa; this causes it to turn away from red. Conversely, it pushes all the sensor input from the green sensors to the opposite wheels; which makes it drive towards green. Mixing these signals causes the ‘navigation’ behavior.

The self-organize example makes the vehicles favor their own color, while disliking the others. This pretty quickly causes them to cluster in same-colored groups. In the scatter example the vehicles don’t like anybody, and drive away from anyone they can sense.