Dropping one leaf from a bunch of leaves

Today’s problem concerns leaves. It’s pretty headache-ish to read, but I hope you’ll bear with me.

I’ve got an immovable pile of leaves. The player can take from it one leaf, or an armful. If they take one leaf the first time, they can either stick with their one leaf or take an armful next time. The pile never runs out.

If they go elsewhere, I want them to be able to throw away either all their leaves (the armful), or one leaf.

If they’re carrying one leaf, throwing away one leaf leaves them with nothing.

If they’re carrying the armful, throwing one away one leaf should have no real effect – they should retain the armful, and a message will say something like ‘You drop one leaf. It blows away. You have a zillion left.’

I coded 95% of all this behaviour successfully using “leaves” for the armful and “leaf” as the name of the individual leaf (two items which magically zap back to the home location if used or dropped, ready for re-use) . The 5% I haven’t been able to do is the ‘throwing away one leaf’ part.

… If the player is carrying the armful, I can’t get the parser to catch the singular word “leaf” when the player tries to drop one leaf from the armful, because the word “leaf” refers explicitly to the single leaf object, which isn’t in the room or the player’s inventory at the time when they type “drop leaf”.

I tried allowing “leaf” to refer to both the armful and the one leaf, but this created a mass of disambiguation horror which kicked down all my programming.

It occurs to me that the moment you let the singular and plural versions of a noun both refer to the plural noun, the parser can’t tell me which one the player typed, can it? It just jumps to matching the object. Like ball and balls, stick and sticks, etc.

What I’d really like is for the program to seize on the word “leaf” (after “drop”), and then jump to some routine I write that could easily sort things out, before it even tries matching the word “leaf” to an object in the game.

Is there a way to do that? Or, as is often the case, some solution I’m completely unaware of which you knowledgable folk will impart to me? Thanks.

How about making the single leaf part of the pile? Here’s how I’d do it:

[code]The Forest Glade is a room. The Meadow is south of the Glade.

The pile of leaves is in the Glade. The pile is fixed in place.

Instead of taking the pile:
if the player carries the armload-of-leaves:
say “You’ve already got an armload of leaves.”;
otherwise:
now the player carries the armload-of-leaves;
now the leaf is part of the armload-of-leaves;
say “You scoop up an armload of leaves.”

An armload-of-leaves is a thing. Understand “armload”, “of”, “bunch”, and “leaves” as the armload-of-leaves. The printed name of armload-of-leaves is “armload of leaves”.

Instead of dropping the armload-of-leaves:
if the location is the Glade:
remove the armload-of-leaves from play;
say “You dump the leaves back into the pile.”;
otherwise:
continue the action.

A leaf is part of the pile.

Instead of taking the leaf:
if the player carries the armload-of-leaves:
say “You’ve already got a whole armload of leaves.”;
otherwise:
now the player carries the leaf;
say “You select a single perfect leaf from the pile.”

After going in the Forest Glade:
if the player carries the armload-of-leaves:
now the leaf is part of the armload-of-leaves;

Instead of dropping the leaf:
if the player carries the armload-of-leaves:
now the player carries the leaf;
continue the action.

After dropping the leaf:
if the player is in the Glade:
say “You drop [leaf-article] leaf, and it drifts back onto the pile.”;
now the leaf is part of the pile of leaves;
otherwise:
say “You drop [leaf-article] leaf, and the wind picks it up and carries it away.”;
if the armload-of-leaves is enclosed by a room:
now the leaf is part of the armload-of-leaves;
otherwise:
now the leaf is part of the pile of leaves.

To say leaf-article:
if the player carries the armload-of-leaves:
say “a”;
otherwise:
say “the”.[/code]
Getting all the circumstances right is not easy, and I may have missed something, but it seems to do what you’re talking about.

Thanks a lot Jim. The example has a few little bugs when run, but before I even ran it, I stared at it for quite a while and it seems that the ‘part of’ business is likely to be the solution to the problem. And the basic logic is in your code, so I will try this out in my game.

I wonder if the Multitudes extension I’m working on would be useful to you. It contains code for parsing and managing an individual item which is part of a collective (although in my case, you can’t take the collective).

If you have any suggestions for the extension I’d like to hear them.

eyeballsun.org/i/Multitudes.i7x

It requires Conditional Backdrops, which is a very short extension:

eyeballsun.org/i/Conditional%20Backdrops.i7x

I had another look at your multitudes extension. I read about it earlier, but I confess I didn’t really understand what it did. I have now read the documentation again, and still don’t know entirely, but I have a better idea!

After adding the “part of” shtick to my arsenal, I was able to get all the programming for the leaf/leaves to work, so I think I’ll be okay.

By the way, I’m surprised that inform is capable of slowing down a modern desktop computer in any circumstances (except super super extreme ones). You were saying multitudes was capable of inducing slowing in particular circumstances.

I’d like to hear more detail, if you’re willing. I strive to write good documentation but I don’t know how often I succeed.

Yes. It’s a drag. Something’s going on with the parser there. Yet another reason why I’d like to take a stab at rewriting the parser…

After looking at the Quarry example code and running the test, and noticing how much functionality a person gets from the few lines of code, that’s the moment I understood what it did.

I think your doc details are very good, but the capsule summary (“Provides a kind of backdrop representing a collection of objects, such as gravel or a crowd of people, that may spread across many rooms.”) didn’t sell me on what it did. I guess I think of any backdrop as spreading across many rooms. And “representing a collection of objects” doesn’t sound like being able to have the player pull out and muck around with individual bits of gravel from a pile without the author having to program all the details. It sounds a bit abstruse.

So, while I’m only a sample space of one, I found the capsule summary of the extension and the first summarising paragraph in the documentation didn’t sufficiently explain to me what the extension could do. (Allow the player to manipulate individual bits of the backdrop)

Thanks - that’s very useful to know! Can I borrow your “manipulate individual bits of the backdrop” explanation?

I have a plan for a second example, by the way, that will work out quite differently. Here’s the scenario:

You’re at a buffet table covered with pastries. Of course you can pick up pastries, eat them, and leave them lying around in other rooms. But at some point, you discover that there are roaches under the pastries, and the roaches start to spread to every room. The roaches are animals, so you can fight them and maybe even talk to them, but you can’t pick them up - their spreading is determined by a mechanism beyond the player’s control.

How would this sound?

Allows the player to interact with individual parts of a backdrop, such as stones in a pile of gravel or characters in a crowd of people. The extension will keep track of how many there are in each room, even if the pieces are moved around.

My two cents: What the extension does is allow the player to interact with a collection of objects that spreads across many rooms. It happens to do this using a backdrop, but maybe that shouldn’t be what you emphasize about it. (NB in this, “Provides a kind of backdrop representing a collection of objects, such as gravel or a crowd of people, that may spread across many rooms,” I think you meant “that may spread” to modify “objects,” but severedhand naturally took it to modify “backdrop.”)

So maybe you want to say this: “Gives a way to implement collections of objects that may spread across individual rooms, like stones in a pile of gravel. The player may interact with individual objects from the collection, and the extension will keep track of how many of these objects are in each room. The extension does this by implementing a new kind of backdrop.” – Modified for accuracy, of course.

–By the way, about slowdown, maybe it has something to do with dynamic object creation? “Under, in Erebus” had dynamic object creation (I’m pretty sure), and it seemed to slow down; I was playing it in Quixe where the slowdown became pretty catastrophic, but I heard from other people that it slowed down on the usual interpreters.

Though on a look at your source, that probably isn’t what’s happening. Might be worth talking to Brian Rapp anyway.

No, there’s no dynamic object creation. There’s a restriction that the player can only ever interact with one instance of the collection. The speed problem is with an Understand line that uses a conditional relation. It seems to be testing every pair of objects in the world with every grammar line, or something on that order.

This one?

Understand "[something related by specimen absence]" as a multitude when a visible multitude is abstract.

Exactly. The “when” clause prevents it from happening most of the time, but if you leave your specimen in an inaccessible place, you’ll notice that everything slows way down whenever you refer to something out of scope.

Yeah, I think Matt’s definition -

“Gives a way to implement collections of objects that may spread across individual rooms, like stones in a pile of gravel. The player may interact with individual objects from the collection …” etc.

  • is looking really good.

In that case, could you both pm me with the names you would like used in the credits? :smiley:

Hrm, I was wondering whether you could fix this by folding the “multitudinous” property into the understand token, but apparently you can understand “[a multitudinous thing]” and you can understand “[something related by specimen absence]” but you can’t understand “[a multitudinous thing related by specimen absence]”. Oh well.