[Adventuron] Distinguishing between preposition1 and preposition2

It is quite common to have two prepositions in a command. Adventuron only seems to support one preposition. How do I distinguish between preposition 1 and preposition 2? The assumption is that preposition 1 occurs after the verb and before noun 1 and preposition 2 occurs before noun 2. For example:
> READ ABOUT TOPIC IN BOOK
ABOUT’ is preposition 1 and ‘IN’ is preposition 2.
> READ IN BOOK ABOUT TOPIC
IN’ is preposition 1 and ‘ABOUT’ is prepostion 2.

It is important that the position can be determined, as the subject and object are swapped, depending on the position. I propose to do the swap using set_sentence, but I need to know which preposition is which in order to work out whether or not to do the swap.

Oh, man. Adventuron’s multi-word input is driving me crazy. I couldn’t understand why my on_command routines weren’t working, so I added the following debugging code at the top of the on_command block:

   : match "_ _" {
      : mask {
         : print {("^n^verb = " + original "verb")}
         : print {("^n^preposition = " + original "preposition")}
         : print {("^n^noun1 = " + original "noun1")}
         : print {("^n^noun2 = " + original "noun2")}
         : print {("^n^adverb = " + original "adverb" + "^m^")}
      }
   }

This revealed some very interesting results:

> READ
verb = read
preposition = 
noun1 = 
noun2 = 
adverb =

That’s to be expected.

> READ ABOUT
verb = read
preposition = about
noun1 = about
noun2 = 
adverb =

That certainly wasn’t expected. Not only is ‘about’ treated as a preposition, it’s treated as noun1 as well!

> READ ABOUT BILL
verb = read
preposition = about
noun1 = 
noun2 = 
adverb =

This time, the noun was thrown away! No wonder my routines wouldn’t work as expected.

> READ ABOUT BILL IN
verb = read
preposition = about
noun1 = 
noun2 = 
adverb =

This time, both the noun and the second preposition were thrown away!

> READ ABOUT BILL IN BOOK
verb = read
preposition = about
noun1 = book
noun2 = 
adverb =

This time, both the first noun and the second preposition were thrown away and the second noun was moved into the first noun’s slot. What the?

After further experimenting, it appears that if a word is unknown, it is just ignored and continues on to the next word. This gives some really strange and unpredictable results. I found that if I put the unknown word in the vocabulary table, then all is well and good. So, in the case of my topics, if I put them in the vocabulary table, then they are magically in scope and I don’t need to create objects for them. However, I still have problems with the ambiguity of preposition 1 and preposition 2. I thought I might be able to use adverb in place of one of them, but it appears that adverb is never used.

Mind you, none of this is consistent. Sometimes, an unknown word is accepted, but most of the time it is ignored. For example, I have a jack-in-the-box with an object id of jack_box (just to distinguish it from another box) and a description of ‘a jack-in-the-box’. When I refer to it is as ‘box’ or ‘jack-in-the-box’, it works. I don’t understand why the latter works. Anything else fails.

Thanks for reporting these issues with examples. I’ll try to resolve as soon as possible, in the meantime might I suggest a workaround of simply remove adding the standard prepositions (which includes “about”).

About will then be ignored, and then your second preposition will be detected in the preposition_is “”, or you could (probably) set up “about” as an adverb (not correct, but a possible working workaround):

game_settings {
   add_standard_vocab_set = false
}

That didn’t make any difference, because I had the prepositions defined in the vocabulary section. If I comment out that chunk of code, then the prepositions are either ignored or treated as noun1, depending on the sentence. I think I’m better off leaving the prepositions defined.

It might help if you list the ‘standard’ prepositions in the doco so that authors know whether they need to add them to the vocabulary section. I’m guessing that using add_standard_vocab_set = false may also have an impact on the standard verbs. If so, that may have unintended consequences elsewhere in the game.

My experiments with adverbs weren’t very fruitful. It just moves the problem to a different area.

I discovered something else interesting. If the first noun is an unknown word and there is no preposition, then the unknown word is put in noun1, but if there is a preposition, the unknown word is ignored and noun1 is null. This looks like a bug to me. The unknown word should always be put in noun1 so that you have predictable results and the second noun doesn’t get put into noun1. Otherwise, the parser should spit the dummy and say, “I don’t know what you’re talking about.” The first approach is better, otherwise the player can use the parser’s weakness to get hints, as in the classic example:

> OPEN DOOR
It's locked.
> GET KEY
I don't understand that noun.

Aha, there’s no key in the game, so don’t bother looking for one. There must be another way to open the door.

One of my commands is TALK TO . I have ‘TO’ defined as a preposition in the vocabulary section, but my debugging code indicates that ‘TO’ is being discarded. ‘TALK’ is not listed as one of the standard verbs. So what happened to ‘TO’?

A simple question this time. When testing for the absence of a preposition, am I better off using preposition_is "" or original "preposition" == ""?

Similarly, when testing for the presence of a preposition, am I better off using !preposition_is "" or original "preposition" != ""?

I’ve tested both and both appear to work.

You’ll be pleased to know that I now have a fully functioning book. You can open it and close it, examine it and read it (each giving a different response depending on whether it’s opened or closed). If you read it when it’s open, it gives you a table of contents. You can then read about (or consult book about) anything in the table of contents. You can even consult book about book. If you try to read about anything that is not in the contents (either a word not in the game or a word in the game, but not in the contents), you get a sensible response. Some of this works by adding extra tests to work around the strangeness in the current Adventuron parser.

I’m happy now, as the book is crucial to finding information that is needed to solve puzzles in the game. There are plenty of in-game hints telling you how to use the book. Armed with this knowledge, I will now be able to ask characters about topics.

Incidentally, this is for the Adventuron Christmas Jam. See the intfiction post or the itch.io jam page for further details, if interested.

I think these issues are best dealt.with using input and parse examples together with a description of the parsing algorithm.

Before that I would like to rework preposition handling as it’s clear that a leading preposition should be able to be parsed differently than a preposition between nouns.

As such, keep your workarounds in place and mark them with comments as workarounds, so you can test then and/or replace with better code once it arrives

Cleaning up and documenting the parser is a high priority.

It’s not urgent. I know you have more important things on your plate at the moment.