Seventeen characters share the world with the player, and every one of them takes a turn after each of the player's -- wherever it is, seen or not. A character is an ordinary object record with a slot in CHARACTERS pointing into a small script, and what it does is always an action tried as if it had typed it, through the same code as the player's (How a sentence is understood). This page is the machinery, and twenty real turns of it.

The slots

Seven bytes each, from CHARACTERS, read from the tape: the character, how many of its ordinary scripts a random switch may choose among, where its script has got to, its script table, and how many of the player's orders it takes at once. Three slots are empty on the tape and are filled in by arrival hooks when the story reaches their characters. The step names are the listing's labels.

SlotCharacterStarts atScriptsIts stepScript tableOrders
$CACBgandalftunnel like hall7GANDALF_FGANDALF_SCRIPTS5
$CAD2thorintunnel like hall2THORIN_ATHORIN_SCRIPTS6
$CAD9wood elflevelled elvish clearing2WOOD_ELF_AWOOD_ELF_SCRIPTS1
$CAE0vicious wargtreeless opening0VICIOUS_WARG_AVICIOUS_WARG_SCRIPTS0
$CAE7butler (empty on the tape)elvenkings cellar2BUTLER_ABUTLER_SCRIPTS1
$CAEEelrondrivendell2ELROND_BELROND_SCRIPTS5
$CAF5gollumdeep dark lake1GOLLUM_AGOLLUM_SCRIPTS3
$CAFCbard (empty on the tape)lake town1BARD_ABARD_SCRIPTS3
$CB03red golden dragon (empty on the tape)lower halls1RED_GOLDEN_DRAGON_ARED_GOLDEN_DRAGON_SCRIPTS0
$CB0Ahideous trolltrolls clearing1HIDEOUS_TROLL_BHIDEOUS_TROLL_SCRIPTS1
$CB11vicious trolltrolls clearing1HIDEOUS_TROLL_BHIDEOUS_TROLL_SCRIPTS1
$CB18nasty goblindark stuffy passage1NASTY_GOBLIN_ANASTY_GOBLIN_SCRIPTS0
$CB1Fhideous goblindark stuffy passage1NASTY_GOBLIN_ANASTY_GOBLIN_SCRIPTS0
$CB26vicious goblindark stuffy passage1VICIOUS_GOBLIN_AVICIOUS_GOBLIN_SCRIPTS0
$CB2Dhorrible goblindark winding passage1HORRIBLE_GOBLIN_AHORRIBLE_GOBLIN_SCRIPTS0
$CB34mean goblindark stuffy passage1HORRIBLE_GOBLIN_AHORRIBLE_GOBLIN_SCRIPTS0
$CB3Bdisgusting goblinbig goblins cavern1HORRIBLE_GOBLIN_AHORRIBLE_GOBLIN_SCRIPTS0

The steps

A script is a list of steps. The low four bits of a step's first byte are its opcode (read from CHARACTERS_ACT's own tests):

OpcodeBytesDoes
0, 24an action and its two objects, tried as the character's own sentence (SCRIPT_DO); $FF for an object means whatever fits
1, 34a routine, run first as a test with printing off and again for real only if it set SUCCEEDED (also SCRIPT_DO); the fourth byte is not used
42an action with no objects, which acts on whatever fits (SCRIPT_BARE); action $FF is a pause: nothing this turn
$0C2switch to its reaction script for the action that follows (REACT)
$0E3go to the address that follows, and carry on
$0F2switch to one of its ordinary scripts at random (SCRIPT_RANDOM): the lesser of the operand and the slot's byte 1 bounds the choice
other1back to its first script; the turn is over

and three more bits of the same byte change how it is taken:

BitMeans
4 ($10)a two-byte fallback follows: where the script goes on if the step is refused
5 ($20)used up: once it works SCRIPT_DO writes 0 over the step's first byte (only Thorin's remark about the small curious key has it)
6 ($40)an order from the player cannot interrupt it

The whole of every script is written out on the Characters page.

A character's turn

END_OF_TURN calls CHARACTERS_ACT, which goes through the slots in order. For each character (read):

  1. It becomes the subject of the sentence: ACTING, ACTOR and ACTOR_AT are set to it, and printing is turned off.
  2. If the player can see it, printing is turned on -- unless the player is in the dark, when the first thing anyone does is only heard, “you hear a noise.”, and nothing else is printed.
  3. If something holds it (CAPTIVE), it tries to climb out, or does nothing if that something is closed.
  4. If an order is waiting for it and the step it is on may be interrupted, it takes the order instead (TAKE_ORDER): that is its turn.
  5. Otherwise it runs steps from where its script has got to. A step that is tried goes through ACTOR_TRIES: WOULD_WORK tests it exactly as the player's commands are tested, and only then does DO_ACTION do it and NARRATE_ACTION tell it. A refused step (STEP_REFUSED ($99AA)) is counted and the script goes on at its fallback or the next step; one that works, a pause, or six refusals end the turn.

So what a character does is decided and done whether anyone sees it or not; the player is told only what happens in sight. The runs below show both, because the sentences were captured at PRINT_CHAR before its gate, while DOING_IT said the action was real, which is where the out-of-sight ones are composed and then not printed.

Twenty turns of WAIT

A game started as the build starts one, and WAIT typed at the first prompt 20 times, in Bag End, in SkoolKit's simulator. Probes on CHARACTERS_ACT's slot loop ($9826), each step it considers (SCRIPT_STEP, $9885), the refusals ($99AA), the random switches, DO_ACTION's call from ACTOR_TRIES ($9A32) and REACT recorded each character's turn; the places are the object records' location bytes after each turn. Gandalf, Thorin and the vicious warg:

gandalf

TurnSteps triedWhat it didWhere after
1$C8BE: OPEN: round green door (done)gandalf opens the round green door.tunnel like hall
2GANDALF_A: RUN (done)gandalf goes east.lonelands
3$C8C4: TAKE; if refused, on at GANDALF_B (refused)
GANDALF_B: RUN (done)
gandalf goes northeast. (out of sight: not printed)trolls path
4$C8D2: DROP (refused)
GANDALF_C: RUN (refused)
$C8D6: Call GANDALF_CHATTER (done)
gandalf says " you are doing a great job ". (out of sight: not printed)trolls path
5GANDALF_D: RUN (refused)
$C8DC: GIVE TO (refused)
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_B: RUN (done)
one random switch
gandalf goes south. (out of sight: not printed)trolls clearing
6$C8D2: DROP (refused)
GANDALF_C: RUN (done)
gandalf goes southeast. (out of sight: not printed)rivendell
7$C8D6: Call GANDALF_CHATTER (done)gandalf says " you are doing a great job ". (out of sight: not printed)rivendell
8GANDALF_D: RUN (done)gandalf goes east. (out of sight: not printed)misty mountain
9$C8DC: GIVE TO (refused)
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_B: RUN (done)
one random switch
gandalf goes north. (out of sight: not printed)narrow path
10$C8D2: DROP (refused)
GANDALF_C: RUN (done)
gandalf goes south. (out of sight: not printed)misty mountain
11$C8D6: Call GANDALF_CHATTER (done)gandalf says " hurry up ". (out of sight: not printed)misty mountain
12GANDALF_D: RUN (done)gandalf goes north. (out of sight: not printed)narrow path
13$C8DC: GIVE TO (refused)
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_A: RUN (done)
three random switches
gandalf goes south. (out of sight: not printed)misty mountain
14$C8C4: TAKE; if refused, on at GANDALF_B (refused)
GANDALF_B: RUN (done)
gandalf goes north. (out of sight: not printed)narrow path
15$C8D2: DROP (refused)
GANDALF_C: RUN (done)
gandalf goes east. (out of sight: not printed)narrow path
16$C8D6: Call GANDALF_CHATTER (done)gandalf says " you are doing a great job ". (out of sight: not printed)narrow path
17GANDALF_D: RUN (done)gandalf goes northwest. (out of sight: not printed)narrow path
18$C8DC: GIVE TO (refused)
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_D: RUN (done)
one random switch
gandalf goes southwest. (out of sight: not printed)narrow path
19$C8DC: GIVE TO (refused)
GANDALF_E: OPEN (refused)
$C8E0: Switch to one of its first 4 scripts at random
GANDALF_C: RUN (done)
one random switch
gandalf goes south. (out of sight: not printed)misty mountain
20$C8D6: Call GANDALF_CHATTER (done)gandalf says " hurry up ". (out of sight: not printed)misty mountain

Gandalf's first steps give the player the curious map and open the round green door (the map before the first prompt, the door on the first WAIT). After that he has five ordinary scripts (GANDALF_A, GANDALF_B, GANDALF_C, GANDALF_D, GANDALF_E), and they are one list entered at different places: each is RUN and one more thing, running on into the next, and the last ends in a switch at random. So he goes somewhere, tries to do something there -- take, drop, give, chat, open, close -- and goes on, and a refusal falls through to the next step. Where he is after twenty turns is chance: RUN picks a direction with RANDOM, and the switches pick a script.

thorin

TurnSteps triedWhat it didWhere after
1$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin waits.tunnel like hall
2$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin waits.tunnel like hall
3$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
4$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin waits.tunnel like hall
5$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin says " hurry up ".tunnel like hall
6$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin sits down and starts singing about gold.tunnel like hall
7$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
8$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin sits down and starts singing about gold.tunnel like hall
9$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
10$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
11$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
12$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
13$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
14$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
15$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin says " hurry up ".tunnel like hall
16$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin says " hurry up ".tunnel like hall
17$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
18$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin sits down and starts singing about gold.tunnel like hall
19$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
-tunnel like hall
20$C910: Go to THORIN_A
THORIN_A: FOLLOW: the player; if refused, on at THORIN_B (refused)
THORIN_B: TAKE: small curious key; if refused, on at THORIN_C (refused)
THORIN_C: Call THORIN_WHERES_THIEF; if refused, on at THORIN_D (refused)
THORIN_D: Call THORIN_CHATTER (done)
thorin waits.tunnel like hall

Thorin's script is a loop that tries the same things in the same order every turn: FOLLOW the player (refused: they are already together), TAKE the small curious key (refused: it is not here), ask where the thief is (refused: the player can be seen), and then his chatter routine, which always does something -- waits, says his line or sings -- and ends his turn. The script then goes back to the start. Only the last step is ever seen.

vicious warg

TurnSteps triedWhat it didWhere after
1$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes northwest. (out of sight: not printed)outside goblins gate
2$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes east. (out of sight: not printed)treeless opening
3$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes west. (out of sight: not printed)outside goblins gate
4$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes east. (out of sight: not printed)treeless opening
5$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes east. (out of sight: not printed)beorns house
6$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes northeast. (out of sight: not printed)forest gate
7$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes south. (out of sight: not printed)forest road
8$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes north. (out of sight: not printed)forest gate
9$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (done)
the vicious warg goes east. (out of sight: not printed)bewitched gloomy place
10$C93E: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (done)
the vicious warg attacks the wood elf. a fast blow knocks the wind out of the elf. (out of sight: not printed)bewitched gloomy place
11$C92C: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
12$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
13$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
14$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
15$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
16$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
17$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
18$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
19$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon
20$C943: Go to VICIOUS_WARG_A
VICIOUS_WARG_A: ATTACK WITH; if refused, on at VICIOUS_WARG_B (refused)
VICIOUS_WARG_B: FOLLOW; if refused, on at VICIOUS_WARG_C (refused)
VICIOUS_WARG_C: RUN; if refused, on at VICIOUS_WARG_D (refused)
VICIOUS_WARG_D: Pause: nothing this turn (done)
-dark dungeon

The warg's script is ATTACK WITH, whatever fits; failing that FOLLOW and howl; failing that RUN; failing that a pause. Every turn it could see nobody to attack, so it ran. Then it met the wood elf, attacked, and the fight is decided as on How a fight is decided. The elf's answer, on its next turn, was to capture it, and captives of the elf go to dark dungeon: there RUN is refused, and the warg pauses every turn.

Reactions seen in these twenty turns -- the calls of REACT from REACT_TO_ACTION whose target was a character:

REACT_TO_ACTION also calls REACT, harmlessly, for many actions with no target at all (a RUN, say): it tests the flags of whatever record TARGET_RECORD last held, and REACT then finds no character numbered $FF (read, and seen in the same run).

Where they went

The player stays in Bag End throughout; the location of each after every turn, grey where it did not change (the wood elf, whose turns are not tabled above, is added for the warg's sake):

TurnThe playergandalfthorinvicious wargwood elf
starttunnel like halltunnel like halltunnel like hallbeorns houselevelled elvish clearing
1tunnel like halltunnel like halltunnel like halloutside goblins gatebewitched gloomy place
2tunnel like halllonelandstunnel like halltreeless openingwest bank
3tunnel like halltrolls pathtunnel like halloutside goblins gatebewitched gloomy place
4tunnel like halltrolls pathtunnel like halltreeless openingforest gate
5tunnel like halltrolls clearingtunnel like hallbeorns housebewitched gloomy place
6tunnel like hallrivendelltunnel like hallforest gatewest bank
7tunnel like hallrivendelltunnel like hallforest roadwest bank
8tunnel like hallmisty mountaintunnel like hallforest gatebewitched gloomy place
9tunnel like hallnarrow pathtunnel like hallbewitched gloomy placewest bank
10tunnel like hallmisty mountaintunnel like hallbewitched gloomy placebewitched gloomy place
11tunnel like hallmisty mountaintunnel like halldark dungeonbewitched gloomy place
12tunnel like hallnarrow pathtunnel like halldark dungeonwest bank
13tunnel like hallmisty mountaintunnel like halldark dungeonwest bank
14tunnel like hallnarrow pathtunnel like halldark dungeonwest bank
15tunnel like hallnarrow pathtunnel like halldark dungeonbewitched gloomy place
16tunnel like hallnarrow pathtunnel like halldark dungeonwest bank
17tunnel like hallnarrow pathtunnel like halldark dungeonwest bank
18tunnel like hallnarrow pathtunnel like halldark dungeonwest bank
19tunnel like hallmisty mountaintunnel like halldark dungeonwest bank
20tunnel like hallmisty mountaintunnel like halldark dungeonbewitched gloomy place

Everyone, in sum

The same twenty turns for all the characters in play: how many turns each took, how many steps it considered and how many of those were refused, the random switches, how many places it was in, and how many of its turns the player was told about.

CharacterTurnsStepsRefusedRandom switchesPlacesSeen
gandalf204720792
thorin20100600110
wood elf2011358030
vicious warg208848070
elrond203010010
gollum208050040
hideous troll20140120010
vicious troll20140120010
nasty goblin203714030
hideous goblin205530030
vicious goblin204020030
horrible goblin208544090
mean goblin208040080
disgusting goblin2080400100

Almost everything happens out of sight: the trolls try their one step six times a turn and are refused each time until the player comes, the goblins patrol their tunnels, Gollum paces by his lake, and only gandalf and thorin were seen at all. Nothing in the scripts is tied to a place, which is why no two games play alike.

Reactions

A script table's entries keyed 0 are the ordinary scripts; any other key is an action code, and that entry is the character's reaction when that action is done to it. After an action for real, DO_ACTION calls REACT_TO_ACTION for each object that is a living character, and REACT looks the action up in the character's table and, if it is there, moves its script to that entry. Every table in the game:

TableUsed byOrdinary scriptsReactions
NASTY_GOBLIN_SCRIPTSnasty goblin, hideous goblin1ATTACK WITH: GOBLINS_ON_ATTACK_WITH
VICIOUS_GOBLIN_SCRIPTSvicious goblin1ATTACK WITH: GOBLINS_ON_ATTACK_WITH
HORRIBLE_GOBLIN_SCRIPTShorrible goblin, mean goblin, disgusting goblin1ATTACK WITH: GOBLINS_ON_ATTACK_WITH
GANDALF_SCRIPTSgandalf5GIVE TO: ON_GIVE_TO; CAPTURE: GANDALF_ON_CAPTURE; ATTACK WITH: ON_ATTACK_WITH
THORIN_SCRIPTSthorin1GIVE TO: ON_GIVE_TO; ATTACK WITH: ON_ATTACK_WITH
WOOD_ELF_SCRIPTSwood elf1ATTACK WITH: WOOD_ELF_A; GIVE TO: ON_GIVE_TO
VICIOUS_WARG_SCRIPTSvicious warg1-
BUTLER_SCRIPTSbutler1ATTACK WITH: BUTLER_ON_ATTACK_WITH; GIVE TO: ON_GIVE_TO
ELROND_SCRIPTSelrond1ATTACK WITH: ELROND_ON_ATTACK_WITH; GIVE TO: ON_GIVE_TO
RED_GOLDEN_DRAGON_SCRIPTSred golden dragon1ATTACK WITH: RED_GOLDEN_DRAGON_ON_ATTACK_WITH
BARD_SCRIPTSbard1ATTACK WITH: BARD_ON_ATTACK_WITH
GOLLUM_SCRIPTSgollum1ATTACK WITH: GOLLUM_ON_ATTACK_WITH
HIDEOUS_TROLL_SCRIPTShideous troll, vicious troll1ATTACK WITH: ON_ATTACK_WITH

Orders, and why Bard is different

What the player says in quotes is parsed into frames of its own and filed in ORDERS; TALK TO's handler, DO_TALK, gives the character a random number of them up to its limit (slot byte 6), and on its turn one replaces the step it is on, unless that step has bit 6. The whole path, from the quote mark to Thorin opening a chest, is followed on How a sentence is understood. A limit of 0 means the character never listens, and a random 0 means it refuses this time.

Bard's slot takes orders too, but his only ordinary script is BARD_TAKES_ORDER and one step at $C9E2, both with bit 6: no order can interrupt them. Instead the routine parses a waiting order itself and writes its action and objects into that step, which he then tries every turn until it works. So an order to Bard is not done once, on his next turn: it is kept, and carried out as soon as it can be -- which is how SHOOT THE DRAGON is meant to be given. On the tape the step reads: TAKE: wooden chest (an order cannot interrupt it). Because the game rewrites it, SAVE carries its three bytes, and a new game does not put it back (see Bugs).

What is confirmed, and what is not