I7: Disambiguation and plurals

A sword is a kind of thing.

Understand "blade/edge/sword" as "[blade]".
Understand "[blade]" as sword.

Definition: a thing is perfect if it is nowhere.
Understand the command "ask" as something new. 
Quizzing it about is an action applying to one thing and one visible thing. Understand "ask [someone] about [any thing]" as quizzing it about.

Does the player mean quizzing about a perfect thing: it is very likely.


The swordsmith is a man. Understand "smith" as the swordsmith.

The ideal sword is a sword.
Understand "blades/edges/swords" as the ideal sword.

The rakish fop is a man. The fop holds a sword called the wicked needle.
The dolorous monk is a man. The monk carries a sword called the keen instrument of DEATH.

After quizzing the swordsmith about the ideal sword, say "Yes, swords are the best!"
After quizzing the swordsmith about a sword (called blade), say "Hmm, [the blade]... not my best work, to be honest."

The forge is a room. All men are here. The player is the monk.

Test me with "ask smith about sword/ask smith about my sword/ask smith about instrument/ask smith about swords".

Result is the “You can’t use multiple objects with that verb.” error message.

I’d love to be able to ask about things in the general plural, but so far I’ve been frustrated. Does anyone have an idea of how to handle this issue gracefully?

Try adding this.

A sword is always privately-named.

Hope this helps.

That would work, but disallows us from asking specifically about, say, “the keen instrument of DEATH”. I’ll update the question to reflect this issue.

So, good effort, but not a solution I can use.

One not-very-graceful thing you could do is to allow quizzing to refer to multiple objects, and then do a Left-Hand-of-Autumn style check on the multiple object list; if the list is coextensive with the list of swords, you give the response for “swords,” and if it isn’t, then you give a graceful refusal. It would have the disadvantage that if the player listed every sword by hand they’d still get the “swords” response.

Add this.

Understand "keen/instrument/of/DEATH" as the keen instrument of DEATH.

Hope this helps.

Yeah, that was my thought. I tried something along those lines, but it was devilishly hard to generalize. I could try to do it anyway, maybe wrapped in some kind of extension. But I’d rather not.

Thanks. Unfortunately, I don’t see how it’s a workable solution if we want to generalize the understanding of subclasses. Throwing away the dictionary definitions of subclasses kinda obviates the point of even having them.

I’ve solved the issue with:

The plural of a sword is asdaafadf.

Basically it overwrites the “swords” plural with nonsense. I know you asked for a graceful solution but…

1 Like

Nice!

After testing it, I think Juhana’s solution is the best quick-and-dirty fix for the moment, as it fixes all my issues and retains the functionality I wanted. Thanks to everyone who jumped in to help.

[EDIT: I see Juhana has come up with something but I have a solution and I’m going to post it, darn it!]

You mean, you’d like to be able to write this so it applies to the plural of anything?

…OK, I see that one problem is that there’s no “[any things]” token. This seems like a lacuna. But I can fix it! Just dive into I6 to see whether we’re trying to parse a quizzing action and then add everything to the scope list by hand. Here’s what I got:

[code]A sword is a kind of thing.

Understand “blade/edge/sword” as “[blade]”.
Understand “[blade]” as sword.

Definition: a thing is perfect if it is nowhere.
Understand the command “ask” as something new.
Quizzing it about is an action applying to one thing and one visible thing.
Understand “ask [someone] about [things]” as quizzing it about.
To decide what action name is the action-to-be: (- action_to_be -).
After deciding the scope of the player when the action-to-be is the quizzing it about action:
repeat with item running through things:
place item in scope.

Does the player mean quizzing about a perfect thing: it is very likely.

The swordsmith is a man. Understand “smith” as the swordsmith.

The ideal sword is a sword.
Understand “blades/edges/swords” as the ideal sword.

The rakish fop is a man. The fop holds a sword called the wicked needle.
The dolorous monk is a man. The monk carries a sword called the keen instrument of DEATH.

After quizzing the swordsmith about the ideal sword, say “Yes, swords are the best!”
After quizzing the swordsmith about a sword (called blade), say “Hmm, [the blade]… not my best work, to be honest.”

The forge is a room. All men are here. The player is the monk.

Test me with “ask smith about sword/ask smith about my sword/ask smith about swords”.

Multiple quizzed already is a truth state that varies.
Every turn:
now multiple quizzed already is false.

Before quizzing when multiple quizzed already is true (this is the only quiz once per turn rule): stop the action.

Before quizzing when the multiple object list is not empty (this is the check for plural quizzing rule):
now multiple quizzed already is true;
if the multiple object list is the same list as the list of swords:
try quizzing the noun about the ideal sword;
otherwise:
say “‘One question at a time, please,’ says [the noun].” instead.

The announce items from multiple object lists rule does nothing when quizzing.

The only quiz once per turn rule is listed before the check for plural quizzing rule in the Before rulebook.

To decide whether (list one - a list of values) is the same list as (list two - a list of values):
repeat with tester running through list one:
if tester is not listed in list two:
no;
repeat with tester running through list two:
if tester is not listed in list one:
no;
yes. [/code]

This should be fairly scalable; if you want to add other plurals, just add another clause to the check for plural quizzing rule. The spacing winds up wonky but there’s probably a way to fix it.

(BTW, why oh why is it “announce items from multiple object lists”?)

EDIT: I think one advantage this has over Juhana’s solution is it doesn’t block “take swords.”

That’s a nice solution. I may end up using it. The “[any things]” token really should be a thing, though. I’d submit a suggestion to the UserVoice if only I had votes left.

I cruised on over to uservoice and I see that the suggestion has already been made, accepted, and implemented for the next release. Hooray!

fistpump Awesome!

Maybe I’m slow, but does that imply that the multiple object list would be accessible in the context of the action machinery? It seems to me that it would be really awesome to do something on the form of

Multi-asking about is an action applying to one list of things. Understand "ask about [any things]" as multi-asking about.

Instead of multi-asking about the list of swords, try asking about the archetypal sword.

Eleas: I’m only seeing your post on preview, but you can’t quite do that because when you type “ask about swords” what actually happens is that it executes the action of asking about the first sword, and then the action of asking about the second sword, and so on. So you have to check the multiple object list–which in fact can be accessed in the middle of the action machinery, even with a plain old “[things]” token–when you do the first action, and then cut off the remaining actions before they get started. Which is what The Left Hand of Autumn does, and what the below code should do more generally!

So I thought I would try to wrap things up in a general solution. Here’s a start on what might be an extension for handling acting on groups, with a reimplementation of the code example The Left Hand of Autumn. Now if you want examining to work on groups, and you want to write a special rule for when the objects you’re examining happen to be the objects in the fruit list, you can write:

[code]Examining is groupable action. Understand “examine [things]” as examining.

An action on groups rule for examining when the fruit list is the same list as the multiple object list:[/code]

and it’ll work. (I’d like to make that second formulation more elegant, so you could write “An action on groups rule for examining the fruit list” or something like that, but I don’t see how.)

Anyway, here’s the implementation! I ran into some weirdnesses, one of which was an abject failure and the other one of which I’ll probably post elsewhere so as to see if I’m making a stupid mistake.

[spoiler][code]“The Left Hand of Autumn, Refactored” by Emily Short with some changes from Matt Weiner

Section 1 - Acting on Groups and Stuff, Which could go in an extension if it were better organized

Multiple actions already taken is a truth state that varies.
Every turn:
now multiple actions already taken is false.

Action on groups is a rulebook. Action on groups has default failure.

An action-processing rule when the current action is groupable action and the multiple object list is not empty and multiple actions already taken is false (this is the check for group action rule):
follow the action on groups rules for the action name part of the current action;
if rule succeeded or rule failed:
now multiple actions already taken is true.

An action-processing rule when multiple actions already taken is true (this is the multiple actions preempt ordinary actions rule):
stop the action.

The check for group action rule is listed before the announce items from multiple object lists rule in the action-processing rulebook. [Could list it “first” but I want to leave open the possibility of another extension putting another rule first–all we need is to guarantee that it winds up before the announce items rule.]

The multiple actions preempt ordinary actions rule is listed after the check for group action rule in the action-processing rulebook.

The announce items from multiple object lists rule does nothing when multiple actions already taken is true.

To decide whether (list one - a list of things) is the same list as the multiple object list:
let list two be the multiple object list;
repeat with tester running through list one:
if tester is not listed in list two:
no;
repeat with tester running through list two:
if tester is not listed in list one:
no;
yes.

Section 2 - Some Other Code from “The Left Hand of Autumn”

[with a whole lot of stuff to handle multiple examining snipped]

After reading a command:
repeat through the Table of Collective Names:
let N be “[the player’s command]”;
let Y be relevant list entry;
while N matches the regular expression “[name-text entry]”:
replace the regular expression “(.*)name-text entry” in N with “\1[Y]\2”;
change the text of the player’s command to N.

Report taking something:
say “You pick up [the noun].” instead.

[and this next bit is commented out because it’d be too much work at the moment, but we might be able to do it by hand-changing the multiple objects list to L and then redirecting to examining]

[And as a bit of polish, because we’d like SEARCH TABLE to have the same effect as EXAMINE ALL ON TABLE:]

[Understand “look on [something]” as searching.

Instead of searching something which supports at least two things:
let L be the list of things supported by the noun;
describe L.
Instead of searching something which contains at least two things:
let L be the list of things contained by the noun;
describe L.]

Section 3 - Scenario

Eight-Walled Chamber is a room. “A perfectly octagonal room whose walls are tinted in various hues.”

The display table is a supporter in the Chamber. A twig of rowan wood is on the table.

The player carries an apple and a pear.

A glove is a kind of thing. A glove is always wearable. Understand “glove” as a glove. The player carries a left glove and a right glove. The left glove and the right glove are gloves.

[Now we define a few actual lists of items:]

Fruit list is a list of things which varies. Fruit list is { apple, pear }.
Glove list is a list of things which varies. Glove list is { right glove, left glove }.
Arcane list is a list of things which varies. Arcane list is { left glove, twig, pear }.

[The following code is commented out because it is superseded by the new group action stuff.]

[To describe (L - a list of objects):
sort L;
if L is fruit list:
say “Just a couple of fruits.”;
otherwise if L is glove list:
say “It’s a matched pair of fuzzy blue gloves.”;
otherwise if L is arcane list:
say “To anyone else it might look like a random collection of objects, but these three things – [L with definite articles] – constitute a mystic key known as the Left Hand of Autumn. They practically hum with power.”;
otherwise:
say “You see [L with indefinite articles].”

When play begins:
sort fruit list;
sort glove list;
sort the arcane list.]

[We sort the lists so that regardless of how we change the rest of the code (and the order in which objects are coded), the resulting list will always be in sorted order and ready to compare with the list of items the player wants to look at. And thanks to the “Reading a command” code we wrote earlier, we can also teach the game to understand the player’s references to “the left hand of autumn” as a specific collection of items.]

Table of Collective Names
name-text relevant list
“left hand of autumn” “[arcane list]”
“gloves” “[glove list]”
“pair of gloves” “[glove list]”

Test me with “x apple and pear / x left and right / put pear on table / put left glove on table / x all on table / put all on table / examine all on table / get apple, twig, pear / x all on table / search table”.

Section 4 - Handling the Scenario with Action on Groups

Understand “examine [things]” as examining.

Examining it from is an action applying to two things.
Understand “examine [things inside] in/on [something]” or “look at [things inside] in/on [something]” as examining it from.

Carry out examining it from: try examining the noun instead.

Examining is groupable action. Examining something from something is groupable action. Taking is groupable action. [We don’t actually have any action on groups rules for taking–this is just here to show that, when you don’t have any action on groups rules, you get the ordinary behavior]

An action on groups rule for examining something from something:
try examining the noun. [putting this here instead of relying on the “carry out” rule allows us to suppress the announce items from multiple object lists rule when examining it from–since this rule succeeds, the multiple actions already succeeds flag gets set.]

An action on groups rule for examining when the fruit list is the same list as the multiple object list:
say “Just a couple of fruits.”

An action on groups rule for examining when the glove list is the same list as the multiple object list:
say “It’s a matched pair of fuzzy blue gloves.”

An action on groups rule for examining when the arcane list is the same list as the multiple object list:
say “To anyone else it might look like a random collection of objects, but these three things – [multiple object list with definite articles] – constitute a mystic key known as the Left Hand of Autumn. They practically hum with power.”

Last action on groups rule for examining:
say “You see [multiple object list with indefinite articles].”[/code][/spoiler]

No, that’s clear enough. What wasn’t as clear was my response: basically, that was me in a moment of weakness, squeeing over the possibilities the “[any things]” token would offer and rampantly speculating. I guess the number of neat toys in the last couple of releases have spoiled me.

Cool, I think that’s a good take on it. Particularly the “groupable” idea is good; in my attempt to make it scale I didn’t look to individual object lists (I was writing a toy example for an extension and so it needed to be both general and succinct, which made me skittish). I like it as a starting point. Hm, I wonder whether Brady Garvin’s Object Kinds extension could be finagled into auto-inferring the kinds and their contents, to automatically populate the lists.

As for the “action on groups” rulebook, given the default rule, the only change I could think about would be to wrap the “when the [list of objects] is the same list as the multiple object list:” in syntactic “to decide”-sugar, but that seems trivial for what you have in mind.

So I’m totally going to make an extension out of this (perhaps this will be what finally gets me to figure out Github). Any more suggestions? I decided to change the phrasing of the check against the multiple object list as “To decide whether dealing with (list one - a list of objects)”, so the rule headings get written as things like “An action on groups rule for examining when dealing with the fruit list:”. Is that the kind of syntactic sugar you had in mind?

It turned out to be pretty smooth to implement the “search” mechanic in Left Hand of Autumn, by the way; altering the multiple object lists to L and then examining the first entry of L worked fine.

Anyway, any other ideas? I didn’t quite follow what you were saying about Object Kinds; if you’re talking about “list of swords” and the like it doesn’t seem like you’d need Object Kinds, “list of swords” should be fine.

Another thing I was thinking about was whether I should try to split the groupable actions rulebook up into multiple rulebooks, to mimic a before-instead-check-carry out-after-report mechanic; The Facts Were These uses rules from multiple rulebooks and so is a bit more complicated to implement using these rulebooks. On balance I think not; it’s better to have the simplicity, and I can take care of The Facts Were These by running through those rules in sequence.

Yeah, I think simplicity is for the best. One possibility is to put the rulebook’s guts into its own subheading, and make an example in the extension which extends and overrides it in the way you describe. That would give people the option without cluttering the main code needlessly.

Yep. As I said, it’s not a big improvement, but perhaps better than nothing.

As for Object Kinds, I’m honestly unsure what I meant. I’m strapped for time lately with a newly arrived baby in the house, so this is me parsing your code in my head and trying to make what I hope are educated guesses. I think I was talking about the lists-that-vary in the Left Hand of Autumn example.

I like that you’re making it an extension, though. My suggestions for any extension is to adhere as much as possible to DRY: the author should never have to repeat themselves, but should be able to define things in as natural a way as possible. If the basic behavior is also flexible, that’s a bonus.

Now this is strange.

yber-commando is a kind of man.

Some cybernetics are a kind of thing.
Some cybernetics are part of every cyber-commando.

A subject is a kind of thing. Regular cybernetics is a subject.

Rex is a cyber-commando. The printed name is "Rex 'Power' Colt". The description is "Just your average Mark IV Cyber-Commando." Understand "power" and "colt" as Rex.

There is a room. Rex is here. 

Quizzing it about is an action applying to one thing and one visible thing. Understand "quiz [someone] about [any subject]" as quizzing it about.
Personal-quizzing it about is an action applying to one thing and one thing. Understand "quiz [someone] about [any cybernetics]" as personal-quizzing it about.

Understand "his" as a thing when the item described is enclosed by a man.
Understand "hir" as a thing when the item described is enclosed by a man.

After quizzing Rex about regular cybernetics, say "'I don't remember what happened during the War, but those things saved the lives of a hell of a lot of Americans.'"

After personal-quizzing Rex about a random cybernetics part of Rex, say "'Me and Spider never got the latest upgrades.'"

Test me with "quiz rex about cybernetics/quiz rex about his cybernetics/quiz rex about hir cybernetics/quiz Rex about rex's cybernetics".

As far as my understanding of Understand tokens go, “his cybernetics” should be interpreted as the cybernetics kind, but instead it devolves to the subject kind. The interesting thing happens when we replace “his” with “hir”: it then works as expected.

What gives? This is a head-scratcher, I must admit.

Unfortunately, I believe that “his” is already hard-coded to act as a pronoun (like “my,” see here) and so there’s nothing you can do to prevent “his cybernetics” from regular cybernetics, at least not without I6 hacking or a friendly extension which may not exist.

The only plausible idea I’ve ever had for dealing with this is to use an after reading a command rule to replace “his” with something else like “hhis,” and then include the grammar you want for that.

Yeah, that was going to be my next step. Alternatively, it could be worth my getting down and dirty with the parser itself: as per the thread you linked in, from my reading of zarf’s reply, it could be done.