Reactive Agent Planner for Inform Version 1.1, March 2000 by Nate Cull email: culln@xtra.co.nz MUD: lennier ifMUD (telnet ifmud.port4000.com 4000) lennier daveMUD (telnet zork.plover.net 4096) What is RAP? RAP is a simple goalseeking library for Inform NPCs. IE, you can use it to make your NPCs smarter - it gives them simple AI capabilities. This may or may not be a useful thing for interactive storytelling (smart NPCs are harder to control), but it should be fun to play with. Given a database of knowledge about the game world (implemented as Inform objects and method calls), and a single routine call specifying a goal to be achieved, a RAP-enabled NPC will sit down and logically plan the best move to accomplish that goal. It will also be able to react to changes in the game world - it's smarter than a scripted NPC, because each move it recalculates the optimal path, and doesn't waste time doing things that have already been done for it. Hence the name. Reactive Planning for intelligent agents. Out of the box, RAP can be used as a drop-in map walking algorithm (ie, you can use it to make NPCs find the shortest path from one room to another, with ease). However, that's just the beginning. RAP can be extended to represent *any* change in game state, not just movement from room to room. Possibilities I have high hopes for RAP, but I'm sure there are fundamental limitations in the algorithm. This is one reason for this early public release, so that people can play with it and test it, even though the demo world in 1.1 doesn't really do much except verify that the library works for trivial cases. There are several things that RAP really needs to be useful in advanced NPC applications: one is an Artificial Ignorance Engine (no, really - RAP needs to be taught what it *doesn't* know about the world, at the moment it just cheats and knows everything). Another is a Value Engine, for keeping track of quantities like hunger and thirst that vary. That one might be too trivial to worry about, though. I'll see. A third, and most important, is some way of teaching itself. The design of RAP at the moment is very much geared toward a precomputed knowledge base that does not change during the game. I'll leave creating a self-modifying database as an exercise to the reader. (IE, I have absolutely no idea how to even begin doing that, and it may be impractical in Inform anyway.) Version History This is the second public release of RAP. The first, RAP 1.0 for TADS, in 1998, (rap10.zip) is also available on gmd.de, though the code in that one is really ugly, completely undocumented, has a lousy demo world, and I really don't recommend it. It does, however, have a quite cute Alice in Wonderland essay which I wrote because I couldn't figure out how to logically explain how it worked. You may find it entertaining to compare the two releases. Origins and Rant RAP is loosely based on (read: I read some old white papers off the project website about five years ago) the HAP planning engine from Carnegie Mellon University's OZ project. Heck if I know what HAP stands for, and it was written in Lisp and I never saw the source, but I read a writeup of the basic algorithm and thought it was good, but messy. I tidied it up a bit (from my way of thinking), ported it to TADS and then Inform, and ended up with the fairly straightforward plan/step/opcode layout that RAP now has. (Straightforward as in, it makes sense to me, after five years of intermittent hacking on it. It still make my head spin a few times each time I look at the code though. I've now documented the code, so if you pay attention you should easily be able to work out what's going on. If you want to know the underlying theory, though, I recommend you dig up the CMU OZ papers on HAP and that should help.) Be aware, though, that I've changed the specs quite a bit from HAP. For some reason, HAP seemed to be geared toward keeping an actual tree in memory, rather than building it fresh each move, and it attached truth/success conditions to entire plans, rather than to each condition in a plan. That to me seemed a fundamentally backwards way of doing things (why would you not want to check, for example, whether a door was open, before trying to open it?), so I changed it. Maybe there were speed/efficiency reasons for their design. I can't see it myself. Also, HAP allowed steps in plans to be executed in random order, which was something that didn't seem useful to me at all, so I removed it. Also, and this might not be obvious to academics, but to me it's a biggie: HAP runs only on the OZ system, which I don't think *anybody* outside of CMU has ever seen, and judging from their sample transcripts, I don't think anyone except a couple of grad students has ever touched. The Internet IF community, however, even though we're working with what might seem like 1980s technology, has leaped ahead in the last couple of years. Inform might not be a cutting-edge AI language, but it's in the right place at the right time, and it's got a vibrant developer community who care about issues like immersion and mimesis. We might not have grants, but we've got eyeballs. So I'd like to throw this out as a challenge. Can the worldwide IF hobbyist community succeed where university research labs seem to have failed? Can we make the next Zork/Dungeon, an interactive storytelling system that makes the Infocom standard look like Colossal Cave? I think we can, and I think our hobbyist nature is what will let us do it. In short: I think RAP is cool, even though it doesn't do much yet. I also think my design's slightly better than CMU's, though I could be wrong and if so, will be very interested to find out why. However, without their very impressive work I wouldn't have even considered this project, and I owe a lot of the underlying conceptual design to them. So kudos to the team at OZ for the work they've done, and for making their documents available on the Web to anonymous hackers like me. I'll probably be digging through their white papers again soon, to get ideas for the next RAP add-ons, even though I have a few of my own. And of course, someone out there in the IF community (hi, guys!) probably has even more interesting ideas than I could imagine. If you do, please tell me. I want to make RAP the best NPC AI library for Inform that can be created. Also, I like a monkey. Awwk! Want cork nut! No parse found! Footnote: I haven't specified a licence in the source code, but consider it GPL-ish. If it ever gets useful enough to warrant it, I'll formally GPL it. For now, let's just say for the record that I grant full rights to copy and use the source in this package in any form required, and revoke all rights to hide the source for derivative works. Yeah, like there's actual money in text adventures anyway. (Hey Chris Crawford, how's that Erasmatazz thing working out for you? Still holding those patents?) Disclaimer: I currently work for a tertiary education institution. Therefore, I feel justified in ripping off CMU's work and passing it off as my own. I've pillaged from two sources (OZ and Infocom), so it's called 'research', not 'plagiarism'. :) Nate Cull February 28 2000