Skip to content

AGI Engine

Sierra's Adventure Game Interpreter

The Adventure Game Interpreter ran Sierra's 3-D Animated Adventures, from King's Quest on IBM's PCjr in 1984 to Manhunter: San Francisco in 1989: 16-colour rooms redrawn from stored drawing instructions, a walking hero who could pass behind the scenery, room logic in Sierra's own scripting language and a typed verb-noun parser. SCI replaced it from King's Quest IV, and fan-written interpreters such as NAGI, Sarien and ScummVM keep the games running.

In 1984 an adventure game hero got up and walked. King’s Quest, made by Sierra On-Line for IBM’s new PCjr, let the player steer a small knight around an animated kingdom, behind trees and in front of rocks, while still typing commands such as “take carrot”. Home Computer Magazine’s reviewer could hardly believe it: “Oops! Bumped into a tree. That’s okay, just walk behind it. What? Sir Grahame disappears behind the tree!” The system underneath was the Adventure Game Interpreter, AGI. For five years Sierra built nearly every adventure it made on it, Space Quest, Police Quest and Leisure Suit Larry among them, and the same game data ran on the PC, Apple II, Apple IIGS, Amiga, Atari ST and Macintosh.

Fast facts

  • Developer: Sierra On-Line. In 1987 Ahoy! credited Jeff Stephenson as “co-designer with Chris Iden of the overall system”.
  • First game: King’s Quest (1984), marketed by IBM for the 128K PCjr at $50.
  • Graphics: 16 colours at 160×200; Sierra told its customers its adventures “all run in 160 x 200 (AGI) or 320 x 200 (SCI)”.
  • Input: typed verb-noun commands, with the hero moved by joystick or cursor keys.
  • Versions: “a dozen different versions”, in John Williams’s words; Sierra’s own upgrade list of 1990 gives interpreter numbers from 2.917 to 3.002.149 on MS-DOS.
  • Last game: Manhunter: San Francisco (1989).
  • Replaced by: SCI, from King’s Quest IV (1988).

How King’s Quest worked

In February 1985 Donald B. Trivette of COMPUTE! wanted to know how King’s Quest could make a knight walk behind a rock “on a machine without sprites”, so he rang Sierra and asked. His article is the fullest period account of the system.

Rooms were drawings, not pictures. Artists traced each of the game’s 80 scenes on a Calcomp graphics tablet, which recorded the drawing as a list of instructions. When the knight walked into a new room, the PCjr read those instructions from the disk, drew the room line by line and filled in the colour, which took about four seconds. The castle, the most detailed room, needed 2,400 bytes of instructions and the simplest only 470. Storing finished images, Trivette explained, would have used much more disk space and cut the number of rooms.

An invisible skeleton sat behind every room. Lines drawn with the same tablet marked where the hero could and could not walk. Every object in a room also had a priority from 1 to 15, low at the top of the screen and high at the bottom. The hero’s own priority changed as he moved up and down, and each time he moved the program compared the numbers to decide what to draw over what. That was how he could pass in front of a tree and then behind it.

Only four things could move at once. Each moving object saved the patch of screen behind it in one of four save areas, so a room could hold no more than four animated objects, the hero included. Trivette found that this was why the magic beans could be planted in only about half the rooms: the rest already had four moving things. In the one room that seemed to break the rule, the programmer made the woodcutter vanish for a moment to free a save area.

Each room ran a script. The rules of every room were written in what COMPUTE! called the Game Adaptation Language. The program looped constantly through statements that worked “sort of like a group of IF-THEN statements in BASIC”. Trivette printed the one that moved a wandering goat into the next room:

Code
IF HAS-GOAT 0 AND OBJHIT-EDGE 14 AND EDGEOBJ-HIT 1 AND GOAT-GONE 0 AND
SHOW-CARROT 0 THEN ASSIGN GOAT-ROOM 11, ERASE 14.

That room alone had 180 lines of logic. Bugs lived there too: if the knight jumped while the goat crossed a bridge, the screen filled with horizontal lines and the game ended.

Playing it

The player saw a room and, beneath it, a command line. Home Computer Magazine noticed how the game drew in a whole family: “One person could control the joystick, while another enters commands at the keyboard”, and someone else could draw the map. Single keys made the knight jump, duck or swim, saved and restored the game, and an ECHO key recalled the last typed command. Sierra’s own versions for the IBM PC, Apple IIe and IIc and the new Tandy 1000 cost $49. On a PC’s RGB monitor the game ran in four-colour CGA, Trivette noted, but on a television it showed the same colours as the PCjr.

Reviewing the Atari ST version of King’s Quest II in 1987, Bill Kunkel of ST-Log summed up what Roberta Williams had done: she “made brilliant use of the extra memory to design a new type of joystick-driven adventure”, combining “the traditional text adventure (verb-noun commands) with sound and graphics more typical of an arcade game”. By then Ahoy! could describe Space Quest’s parser as one that “interprets compound sentences”, with pop-up text windows, a status line showing the score and, on the Amiga, a mouse to steer the hero.

The 3-D Animated Adventures

Sierra sold AGI to players under another name: the “3-D Animated Adventure”. Its winter 1988 newsletter claimed “over 3 million dollars in underlying technology” for the “3-D Animated Adventure game system”, and magazines used the label too. Antic’s Amiga Plus introduced Manhunter: New York in 1989 as “this Sierra 3-D Animated Adventure”.

The games built on it include:

  • King’s Quest (1984), King’s Quest II (1985) and King’s Quest III (1986), all by Roberta Williams
  • The Black Cauldron (1986), a Disney licence
  • Space Quest and Space Quest II
  • Police Quest, by Jim Walls
  • Leisure Suit Larry in the Land of the Lounge Lizards (1987), by Al Lowe
  • Mixed-Up Mother Goose, for young children
  • Gold Rush!
  • Manhunter: New York (1988) and Manhunter: San Francisco (1989)
  • the 256K version of King’s Quest IV (1988)

The Black Cauldron showed that the system did not need a keyboard. INFO recommended it as “a ‘no-keyboard-required’ game” for “youngsters who have long attention spans, but find text games difficult”, with “delightfully realistic animation in all 73, three dimensional screens”. Its drawbacks were the engine’s: loading the screens was “s-l-o-w”, and the reviewer had trouble keeping Taran moving because he “frequently seemed to stick”.

A dozen versions

AGI did not stand still. Looking back in 1990, John Williams wrote that “a dozen different versions of AGI” had launched the King’s Quest, Police Quest, Space Quest and Leisure Suit Larry series. Sierra’s product-upgrade list from the same issue shows the spread. On MS-DOS, Space Quest ran on interpreter 2.917, King’s Quest III and Space Quest II on 2.936, the AGI King’s Quest IV on 3.002.086 and Manhunter: San Francisco on 3.002.149. The Amiga versions had interpreters of their own, numbered from 2.176 to 2.333, and the Macintosh versions another series again. The fan-written AGI specification, which catalogues surviving disks, finds earlier interpreters too: 2.089 on an early Space Quest and 2.272 on early copies of King’s Quest and King’s Quest III.

The limits showed most clearly in colour. According to Wireframe, when Ken and Roberta Williams asked Sierra’s systems engineer Jeff Stephenson for more colours for King’s Quest IV, the AGI system “only supported 16”. Stephenson says the bigger problem was that almost any new behaviour “first had to be programmed into the game system itself before it could be used to write the game”.

Superseded by SCI

Stephenson’s answer was a new object-oriented language, the Sierra Creative Interpreter. King’s Quest IV shipped in both forms in 1988. Sierra’s Spring 1989 newsletter explained that “an older version of the interpreter, called Adventure Game Interpreter (AGI), was used to create King’s Quests I, II, and III and the 256K version of King’s Quest IV”. Looking back in 1990, John Williams wrote that the SCI game’s animation “was far superior to the AGI games”, and admitted that the AGI version “frankly, paled by comparison”.

AGI’s last stand was the Apple IIGS. In autumn 1989 Ken Williams explained that AGI “was converted to the Apple IIGS and made possible products like the King’s Quest series, Leisure Suit Larry and Mixed-Up Mother Goose”, but that SCI was “just too big and too complex for the relatively slow CPU”. Manhunter: San Francisco, “built using the AGI development language”, was expected to be Sierra’s last adventure for the machine. By 1990 Sierra was selling the original King’s Quest and Mixed-Up Mother Goose “rewritten for SCI”, with better graphics and sound-card music, and offering owners of the old versions a $20 upgrade for King’s Quest.

After Sierra

Fans took the system apart. The Sierra Adventure Game Interpreter Specifications, written by Lance Ewing, Claudio Matsuoka, Peter Kelly and others, describe the six kinds of resource a game is built from: pictures, views (animated images), sounds, objects, a dictionary of words and logic scripts. The scripts run on 256 variables and 256 flags, and each new interpreter version understood more commands. Nick Sonneveld wrote NAGI, a replacement interpreter made by disassembling Sierra’s own and rewriting it in C. The open-source Sarien interpreter became the basis of ScummVM’s AGI engine, added in ScummVM 0.10.0 in June 2007. ScummVM 0.11.0 in January 2008 added three “pre-AGI” games for children, including Winnie the Pooh in the Hundred Acre Wood and Mickey’s Space Adventure, and it also runs new games that fans have written for AGI.

Sources

  • Home Computer Magazine vol. 4 no. 5, 1984, pp. 54–55: King’s Quest review (IBM PCjr, IBM, $50, 128K; walking behind the tree; joystick and keyboard players; single-key actions; the ECHO key).
  • Donald B. Trivette, “Inside King’s Quest”, COMPUTE! issue 57, February 1985, pp. 136–139: the Calcomp tablet and drawing instructions, 80 rooms, four seconds per room, 2,400 and 470 bytes; walk lines and priorities 1 to 15; four save areas, the beans and the woodcutter; the Game Adaptation Language, the goat statement and 180 lines; the bridge bug; Sierra’s versions at $49 and CGA on an RGB monitor.
  • Ahoy! issue 45, September 1987, p. 54: Space Quest (Amiga) review; Jeff Stephenson “co-designer with Chris Iden of the overall system”; the parser and interface.
  • ST-Log issue 12, March 1987, p. 34: Bill Kunkel’s review of King’s Quest II.
  • The Sierra Newsletter (InterAction) vol. 1 no. 4, Fall/Winter 1988, p. 3: “over 3 million dollars in underlying technology” for the 3-D Animated Adventure system.
  • The Sierra Newsletter (InterAction) vol. 2 no. 1, Spring 1989, p. 21: AGI used for King’s Quest I–III and the 256K King’s Quest IV.
  • Sierra News Magazine (InterAction) vol. 2 no. 2, Autumn 1989, pp. 27–28: the Apple IIGS, AGI and Manhunter: San Francisco; hardware column (“160 x 200 (AGI) or 320 x 200 (SCI)”).
  • Antic’s Amiga Plus vol. 1 no. 2, June 1989: Manhunter: New York as “this Sierra 3-D Animated Adventure”.
  • INFO issue 23, November/December 1988, p. 44: The Black Cauldron review.
  • Sierra News Magazine (InterAction) vol. 3 no. 2, Summer 1990: John Williams, “Ten years: history of Sierra On-Line, Inc.”, pp. 6–12 (the release timeline, “a dozen different versions of AGI”, the AGI King’s Quest IV); the SCI rewrites of King’s Quest and Mixed-Up Mother Goose; product-upgrade list with interpreter numbers, pp. 60–61.
  • Jack Yarwood, “Once upon a time: the epic history of King’s Quest”, Wireframe issue 46, December 2020, pp. 28–33: Jeff Stephenson, AGI’s 16 colours and the move to SCI.
  • Sierra Adventure Game Interpreter Specifications, section 3, “AGI internals”, by Lance Ewing, Claudio Matsuoka, Peter Kelly and others (web, secondary): resource types, variables and flags, the table of interpreter versions. https://www.agidev.com/articles/agispec/agispecs-3.html
  • “NAGI”, The Sierra Help Pages (web, secondary): Nick Sonneveld’s interpreter, made by disassembling Sierra’s. https://sierrahelp.com/Utilities/Interpreters/NAGI.html
  • ScummVM release notes (NEWS) and AUTHORS file (web, secondary): the AGI engine added in 0.10.0 (20 June 2007); the pre-AGI games in 0.11.0 (15 January 2008); “Sarien Team – Original AGI engine code”; fan-made AGI games. https://github.com/scummvm/scummvm/blob/master/NEWS.md

See also

Checked. Verified against primary sources and signed off by a person.