Embrio is an “agent based” programming tool. The design and structure of an agent based program is significantly different than that of a traditional program. This post will discuss how to think about a programming problem from the perspective of implementing it with agents.
There are two important properties of an agent; each agent should do just one thing, and each agent is always running. This highly parallel architecture is very useful when it comes to embedded and embodied programming, significantly simplifying the complexity of the “program loop”.
The Three Types of Agents
In general there are three types of agents; perception, action, and control. In the Embrio application there are just agents, the three types are conceptual differences, not ones specifically modeled in the software.
You can think of the flow of data in an Embrio program traveling into the system from sensors up the perception agents, across the logic agents, then down the action agents out to the system outputs. Again, these are concepts to keep in mind when designing your program, Embrio doesn’t differentiate between the different types of agents.
Perception agents detect things about the world or the internal state of the program. They generally have an output activation which turns on when their state is detected and stays at 0 when it is not. Perception agents can exist in layers, with higher layer agents representing more abstract states.
For example let’s imagine we are making a program to automate controlling a light. A low level agent could read an ambient light sensor value which it converts to an activation, 0 being no light, 1 being bright light. Another low level agent could be a motion detector, it outputs 0 when it doesn’t detect motion, 1 when it does.
A higher level perception agent could be an “it’s dark out” detector, which takes the light sensing agent and passes its activation through a threshold node, then outputs a 1 if the light value is below a certain range.
An even higher level perception agent could be an “it’s dark out and there’s been no motion for a while” detector, which outputs a 1 activation when that particular state is active. This agent would take the “it’s dark out” detector, the motion detector, and combine them with some kind of timer to determine that “it’s been a while”. All of this logic would be encapsulated by this agent and simplified into a single activation value which can be used anywhere else in the program.
Action agents make things happen. Like perception agents, these also exist in layers with higher level agents being more abstract.
An obstacle avoiding car provides some good examples of action agents and their hierarchical structure. (This tutorial walks through implementing some of these concepts. It was made in an older version of Embrio but the concepts are the same.) Imagine a simple robot car, with a motor on each side, and a few distance sensors in the front.
The lowest level action agents would control the motors. In this program there would be 4 low level agents, left wheel forward, left wheel back, right wheel forward, and right wheel back. All of these agents would have an activation input which in this case would use the full value range from 0.0 to 1.0 to control the speed of the motor from off to full power.
The next level of activation agents would be things like move forward, move backward, turn left, and turn right. These agents would again have a full range input activation which gets passed through to the lower level agents. For example move forward would pass its input activation through to the left wheel forward and right wheel forward agents. Turn left would pass its activation to the right wheel forward agent and the left wheel back agent to turn the car.
Other action agents can take perception agent as inputs. For example an “turn away from obstacles on the left” agent would take the “left wall detector” agent and pass its activation through to the “turn right” agent, turning the car away from obstacles on the left. There would be another agent to avoid obstacles on the right, and a higher “avoid obstacles” agent which would turn on these and maybe other agents.
A higher level agent could be “wander”, which turns on the move forward agent, the avoid obstacle agent, and the random turns agent.
Perception and Activation agents are the most common in an Embrio program, a lot can be done by flowing data up and down a structure made of these agents. Logic or Control agents are another conceptual type of agent where data flows across, taking activation states from perception agents and determining based on some logic which action or other logic agents to turn on.
In the obstacle avoiding car example let’s say the car can have several high level behaviors; wander, escape, rest, look around, etc. Generally only one of these behaviors could or should be on at a time. We can use some higher level logic agents to decide which behavior to activate. The concept of state control deserves more attention that can be paid to it in this blog post, so there will be another post dedicated to it. You can also see this tutorial for an overview.
The general idea here is to understand the three different conceptual types of agents and how you would use them to create an embedded or embodied program with Embrio.