Reactive Agent Planner

From IFWiki
Jump to: navigation, search

Reactive Agent Planner (or RAP for short) is a library extension originally written in 1998 for TADS 1.0 by Nate Cull. It is usually described as "a goal-seeking library for NPCs". Versions of RAP have also been ported to Inform 6, Inform 7, and TADS 3.


RAP is loosely based on the HAP planning engine from Carnegie Mellon University's OZ project, as described in white papers, but somewhat modified and simplified.

RAP is presented in two parts: the goalseeking module and the planbase module. The goalseeking module does the heavy lifting of figuring out what ought to be done, and as the core of RAP, most authors probably won't want to alter it much, if at all. By contrast, the planbase module is where typical planning relations and planning actions are defined, and authors will usually need to modify or override this module when the barebone default definitions are inadequate.

The goal of an NPC is defined as a planning relation, a relationship between two objects in the game. Relations must be defined with a way of testing whether or not the relation is currently true. (A relation is sometimes also called a "condition".) Relations are also defined with one or more plans that can be followed in the event that the relation is not true.

Plans, in their turn, are defined (roughly) as a series of steps. Each step in a plan is either a planning relation (to make true) or a planning action (to perform). Authors must make sure that NPCs won't be persuing a circular chain of relationship dependencies.

Some caveats:

  • RAP cheats a bit; by default, NPCs know everything about the world that they need to manipulate. Giving NPCs a false or incomplete worldview is an exercise for the programmer.
  • NPCs don't know what happened in previous turns. With every turn, they are a blank slate and recalculate their plan anew.
  • NPCs can't be taught new plans in mid-game.



Reactive Agent Planner 1.0, by Nate Cull, 1998. RAP is a goal-planning library for NPCs implemented in TADS.

Inform 6 (Version 1.1)

Reactive Agent Planner version 1.1, a goal-seeking library for NPCs, by Nate Cull, March 2000.


  • rap.txt - Note from the author on Origins, Rant, and Disclaimer.
  • rapcore.h - The goalseeking module.
  • rapdemo.inf - Source code for RAPDEMO, a demo starring Widget the Puppy who wants to find and play with a red rubber ball.
  • rapplans.h - The planbase module.

Footnote by the author: "I haven't specified a licence in the source code, but consider it GPL-ish."

Inform 6 (Version 1.2)

Reactive Agent Planner version 1.2, a goal-seeking library for NPCs. Updated with a perl preprocessor by Sam Denton. February 2004.

TADS 3 (Version 1.2)

The TADS 3 Reactive Agent Planner, which automates complex NPC behavior. Original TADS 2 module by Nate Cull. Updated TADS 3 version 1.2 by Steve Breslin.

Inform 7

The extension was renamed to just "Planner" for Inform 7.

See Planner [1] and Basic Plans [2], both by Nate Cull.

Basic Plans contains the demo game Alchemy where an NPC called Bob the Wizard attempts to make soup.

Games known to use Reactive Agent Planner

Further Reading

  • "Hap: A Reactive, Adaptive Architecture for Agents". A. Bryan Loyall and Joseph Bates. Technical Report CMU-CS-91-147, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, June 1991. Downloadable postscript version available as of 2006-05-28 from