Commanding multiple actors at the same time

Yeah, commands to other actors are parsed depending on whether the first word is a verb (or direction?), so if you have a way of detecting “, verb” that should work. (All I know about the parser I learned from Ron Newcomb’s I7 implementation of the 6G60 parser, but that’s how I remember it there.) Seems like it might be harder or more I6y to parse, though.

Though my idea behind my third option was that we could just tell the player to type “waldo, take the rough device and the smooth device and the bubbly device.”

I’m looking through Parser.i6t right now, and it seems that it might be possible to add something like this:

  • If the parser would say “You seem to want to talk to someone…”:
  • Go back to the beginning of the command
  • Invoke the multi-noun parser routines on the first few words
  • If it gets somewhere before choking:
  • Change the token where it failed from a comma to a nonsense dictionary word (like $).

Then make I7 understand [things]$ [topic] as commanding it to. I’m really afraid to mess with the parser, but it shouldn’t be a huge change.

So far this seems to be working, although I spent a long time trying to figure out how ParseToken could return 2 (the list of return codes is wrong–2 means success, not 0). The biggest problem is the comma after the list of actors interfering with the list parser.

YES! It’s almost working! There are several bugs, but for the most part this is now what the parser does:

  • Is the beginning of the command a multiple object list?
  • If so, call the “multiple actor rulebook”, which copies the list somewhere else.
  • Set the actor to the player, clear the multiple object list, and continue parsing.

This works for commands in the form “IRIS, SENSA, WALDO, GO TO ALPHA FC” and “IRIS AND SENSA AND WALDO, GO TO ALPHA FC”, but not “IRIS, SENSA, AND WALDO, GO TO ALPHA FC”. I’m still trying to figure out why.
EDIT: Specifically, it breaks on “, AND” anywhere in the list. I don’t know why, but an “after reading a command” rule should take care of it.
EDIT2: It’s working pretty well now. I just need to plug in the code to convert the action. Here’s the relevant part (note that the I6 prints some debugging info to the screen, I’ll remove that later).

The multiple actor rules are a rulebook.
A multiple actor rule:
	say "Multiple actors: [line break]";
	repeat with the subject running through the multiple object list:
		say "    [the subject][line break]".
A last multiple actor rule:
	alter the multiple object list to {}.

Include (-
	! Only check for a comma (a "someone, do something" command) if we are
	! not already in the middle of one.  (This simplification stops us from
	! worrying about "robot, wizard, you are an idiot", telling the robot to
	! tell the wizard that she is an idiot.)
	
	if (actor == player) {
		for (j=2 : j<=num_words : j++) {
			i=NextWord();
			if (i == comma_word) jump Conversation;
		}
	}
	jump NotConversation;
	
	! NextWord nudges the word number wn on by one each time, so we've now
	! advanced past a comma.  (A comma is a word all on its own in the table.)
	
	.Conversation;
	
	j = wn - 1;
	
	! Use NounDomain (in the context of "animate creature") to see if the
	! words make sense as the name of someone held or nearby
	
	wn = 1; lookahead = HELD_TOKEN;
	scope_reason = TALKING_REASON;
! Here's where I'm changing things.
	l = ParseToken(ELEMENTARY_TT, MULTI_TOKEN);
	if(l == GPR_MULTIPLE){ ! Wtf -- the list of return codes for ParseToken is wrong! 2 is the code for success; 0 is the same as GPR_PREPOSITION.
		print "MULTIPLE ACTORS FOUND!!!^";
	}else if(l == GPR_REPARSE){
		print "Actor needs reparsing^";
	}else if(l == GPR_PREPOSITION){
		print "Preposition rejected^";
	}else if(l == -1){
		print "Error parsing actor^";
	}else{
		print "Actor found: ", (the) l, "^";
	}
	FollowRulebook((+the multiple actor rules+));
	wn--;
	print "WN is ", wn, "^";
	print "Verb_wordnum is ", verb_wordnum, "^";
	verb_wordnum = wn;
	jump BeginCommand;
! I cut the rest, since it's now redundant.
-) instead of "Parser Letter C" in "Parser.i6t".

Put code to deal with the actors in the “multiple actor rules”, replacing the simple list-printing rule.

The “, AND” problem was around for normal parsing at least in 6G60, so that’s probably just a limitation of the parser. As Sam said in that thread, you might just want to use a regex to zap the serial comma. (EDIT: I mean, zarf provides an I6 fix for it in that thread. Not sure if it works as-is in 6L02.) (On a quick but eccentric test it seems like it’s still there in 6L02 – “take apple, apple, and apple” gives a “you can’t see any such thing,” “take apple, apple and apple” takes one apple.)

Okay, I think I have a working system for multiple actors now. It completely replaces the standard “actor, action” parsing, so I’m going to do more rigorous testing before releasing it, but it seems to perform the way I want it to.

I’m surprised that parser problem has persisted for so long; since I’m rewriting bits of the I6 parser as it is, it shouldn’t be too hard to fix it there (if the previous token was “,” and the current token is “and” and we’re parsing for a MULTI_TOKEN, pretend we’ve parsed it and skip to the next word).

And it’s finished!

Include this extension to completely replace the standard I6 actor parsing. It requires a couple other extensions that are also in GitHub (although Debugging isn’t necessary at this point; comment out the “debug say” statements if you don’t want to use it), and one that isn’t: Serial And Fix by Andrew Plotkin is Zarf’s fix for the “x, y, and z” issue that he posted in the other thread.

This supports all of the following syntaxes:

JUMP
IRIS, JUMP
BOTH IRIS AND WALDO, JUMP
IRIS, WALDO, JUMP
IRIS AND WALDO, JUMP
IRIS, SENSA, AND WALDO, JUMP
IRIS AND SENSA AND WALDO, JUMP
ALL ROBOTS, JUMP
TELL IRIS TO JUMP
TELL IRIS AND WALDO TO JUMP
TELL ALL ROBOTS TO JUMP

(along with many variations on these.)

This also fixes the “leaflet problem”: if Iris and Waldo are in a room with two leaflets, “BOTH IRIS AND WALDO, TAKE LEAFLET” will make them each take a different one. TELL IRIS TO TELL WALDO TO JUMP doesn’t work, but now produces a reasonable error message* rather than going into an infinite loop. The same goes for other actions out of world.

Note: Certain parser error messages don’t look quite right, since the “player” variable is changed several times during parsing. I’m working on fixing this now, but it’s quite minor and doesn’t affect functionality.

Multiple Actors.i7x

Wow, I go away for a few days and come back to find a custom made extension. That’s amazing! Thank you!

1 Like