CS5940 Model Map ⌂ Modules
Reactive agentWeek 24 techniques

Teleo-reactive programs

An ordered list of condition-action rules, checked from the top on every cycle. The first true rule wins. It heads for a goal (teleo) while reacting to whatever has just changed (reactive).

Kind: reactive agent (goal-directed rules).
Week: 2 (slides 12 to 15).
Book: not in Wooldridge. Source: Nilsson (1994) and the slides.
Techniques on this page: running a TR program, tracing it cycle by cycle, why the order of rules matters, implicit vs explicit goals.

The problem it solves

The deductive agent has two problems: proving things is slow, and its flat rule set has no goal in it, so every rule must guard against all the others.

A teleo-reactive (TR) program fixes both cheaply. It puts the rules in priority order, writes them for a named goal, and re-checks them every cycle. There’s no planning ahead: if the world changes, the next cycle simply picks a different rule.

Words you’ll hear

Word Plain meaning
teleo aimed at a goal (Greek telos, end)
reactive responds directly to the current situation, without planning
condition-action rule “if this is true, do that”: \(c \to a\)
cycle one check of the rule list, followed by one action
\(nil\) do nothing (the program has finished or is stuck)
implicit goal a goal the rules pursue without ever writing it down as a symbol

Technique 1: how a TR program runs

Problem it solves: choosing an action quickly and safely in a changing world.

\[c_1 \to a_1,\quad c_2 \to a_2,\quad \dots,\quad c_m \to a_m\]

On every cycle: check the conditions from the top, and do the action of the first rule whose condition is true.

The slides’ program for the goal “sweep and clean the room”:

\[sweep\_clean(X,Y): \begin{cases} dirty(X,Y) & \to do(clean)\\ \neg wall(front) & \to do(forward)\\ wall(front) \wedge \neg wall(left) & \to do(turn(left))\\ wall(front) \wedge wall(left) & \to nil \end{cases}\]

Read the priorities as: clean here beats keep moving beats turn at a wall beats stop, boxed in.

Technique 2: tracing cycle by cycle

Problem it solves: the exam exercise: given a world, list the actions.

Worked example: a 3-cell corridor. Cells \(x = 1, 2, 3\), robot at 1 facing east. Walls along the whole north side (so “left” is always a wall) and at the east end. Dirt on cell 2.

Cycle Cell dirty? wall ahead? wall left? First true rule Action
1 1 no no yes rule 2 forward
2 2 yes no yes rule 1 clean
3 2 no no yes rule 2 forward
4 3 no yes yes rule 4 nil (stop)

Reactivity: if someone drops dirt on cell 3 while the robot is on cell 2, it cleans it on arrival with no replanning, because rule 1 is checked first every cycle.

Technique 3: order matters

Problem it solves: explains the most common mistake when writing TR programs.

Swap rules 1 and 2 and the robot drives straight over dirt whenever the way ahead is clear: on cycle 2 above, rule “no wall ahead → forward” would be checked first and win.

Compared with the deductive agent’s flat set \(\rho\): the TR program is ordered (priority settles conflicts), re-evaluated every cycle, and written towards a named goal. The flat set has no priority and no goal, so each rule needs extra guards like \(\neg dirty\).

Technique 4: is an implicit goal still a goal?

Problem it solves: the slide 14 discussion question, which makes a good short exam answer.

\(sweep\_clean\) never writes “room clean” down as a symbol, yet every rule moves the robot towards it. A defensible position:

  • explicit goals are not needed for goal-directed behaviour;
  • they are needed for the agent to reason about its goal (drop it, swap it, explain it), and for a human to verify it.

Compare week 1’s thermostat: its objective is also implicit in its rule. Explicit goals come back with BDI intentions.

What to read in the book

Source Read? Why
Wooldridge n/a Teleo-reactive programs aren’t in the book
Slides 12 to 15 Read The only course source
Nilsson (1994), “Teleo-reactive programs for agent control” Optional The original paper, if you want more

The closest thing in the book is the reactive-agent material in 5.1 (see subsumption), which also picks the first applicable behaviour by priority.

Practice prompt

I'm studying CS5940 Intelligent Agents (week 2, Nilsson's teleo-reactive programs). I want practice on TELEO-REACTIVE PROGRAMS:
- how a TR program runs: ordered condition-action rules, checked from the top every cycle, first true rule fires
- tracing a TR program (like sweep_clean: dirty -> clean; no wall ahead -> forward; wall ahead and no wall left -> turn left; walls ahead and left -> nil) through small grid or corridor worlds, cycle by cycle
- what happens when the environment changes mid-run (new dirt, a door closing)
- what goes wrong when rules are reordered
- writing my own short TR program for a simple goal
- comparing a TR program with a flat rule set of a deductive agent, and with subsumption
- whether an implicit goal is still a goal

Please:
1. Use plain, everyday language and explain any term in one short sentence.
2. Give me ONE question at a time, easy first, then harder; for traces, describe the world precisely.
3. Wait for my answer, then mark it and show the full cycle-by-cycle trace.
4. If I get it wrong, explain the mistake and give me a similar question.
5. Every 5 questions, summarise my strengths and what to practise.