Teleo Reactive Programs
Nils Nilsson, one of the original pioneers of artificial intelligence, invented teleo-reactive programs as a framework for controlling robust mobile robots that are highly reactive and adaptable in dynamic enovirnments [1, 2]. The general idea of teleo-reactive programs is very simple, yet they are capable of compactly representing complex behaviors.
A teleo-reactive program is an ordered list of production rules, as shown below:
K1 -> a1
K2 -> a2
...
Km -> am
- The Ki 's are conditions that are evaluated with reference to a world model, and the ai 's are actions on the world. The conditions may contain free variables that are bound when the teleo-reactive program is called. Actions may be primitives, such as TurnLeft or Kick. Actions may also be executed in parallel, such as Forward and TurnRight. Actions may also be calls--or even parallel calls--to other teleo-reactive programs. Calling other programs or itself allows for what computer scientists call hierarchy and recursion.
The rules are scanned from top to bottom for the first condition that is satisfied, and then the corresponding action is taken. The rules are scanned continuously, so continuous or durative actions, such as TurnLeft at some rate, is possible. Ballistic or discrete actions, such as Kick, is also useful.
Generally, teleo-reactive programs are organized in such a way that K1 is the goal condition, a1 is the Nil action, and Km is true. The rules at the top of the list are usually the ones that are relevant when the robot is close to achieving a particular goal, and the bottom rules are relevant when the robot is far from its goal. The idea is that the bottom rules trigger actions that change the world in such a way that the conditions higher in the list become satisfied. For most humans, this way of organizing the rules in a teleo-reactive program is most natural.
For more information about teleo-reactive programs see:
http://www.robotics.stanford.edu/users/nilsson/trweb/tr.html
Sample Program
Below is a sample program written in the TRSoccerbots programming language that illustrates how teleo-reactive programs work. This program is an implementation of the "kiddie-soccer" strategy, i.e. run at the ball and kick it like crazy.
kiddiesoccer(): Close(ME,BALL,HI) AND DirectlyFront(ME,BALL) -> Kick(HI) Close(ME,BALL,HI) -> Face(BALL) DirectlyFront(ME,BALL) -> MoveForward(HI) True -> moveto(BALL)face(pos): DirectlyFront(ME,pos) -> Nil Left(ME,pos) -> TurnLeft(HI) True -> TurnRight(HI)moveto(pos): Close(ME,pos,HI) -> Nil DirectlyFront(ME,pos) -> MoveForward(HI) True -> face(pos)