Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Sorry, I meant noun1.

You mean original "noun1"  or rationalized "noun1" ?

Happy to help if you provide me with sample code. 

Ball should not be a synonym of twine unless:

  • You set it up manually in the vocabulary {} section.
  • You used set_sentence to rewrite the sentence.
  • You set up a parser preprocessor step (in the vocabulary {} section).
  • Twine was somewhere else in the sentence, and the parser became confused (unknown preposition).

None of the above. The code is pretty straightforward. The stripped down code (with debugging code added) looks something like this:

start_at = room
game_settings {
   add_standard_prepositions = false
   experimental_new_parser = true
}
locations {
   room : location "You are in a room.";
}
objects {
   ball_twine : object "a ball of twine" at = "room" {experimental_matching_text_sequences = ["ball of twine", "ball", "twine"]}
   text_book : object "a text book" at = "room";
}
on_command {
   : match "_ _" {
      : mask {
         : print {("^n^verb = " + original "verb")}
         : print {("^n^preposition1 = " + original "preposition1")}
         : print {("^n^noun1 = " + original "noun1")}
         : print {("^n^preposition2 = " + original "preposition2")}
         : print {("^n^noun2 = " + original "noun2" + "^m^")}
      }
   }
  : if (is_present "text_book") {
      : match "read _" {
         : if (preposition1_is "about") {
            : if (noun1_is "ball") {
               : print "It says you only need rubber to make a ball.";
               : done;
            }
            : print "There's no topic on that.";
            : done;
         }
      }
   }
}
vocabulary {
   : preposition / aliases = [about]
   : noun / aliases = [ball]
}
To test it, enter READ ABOUT BALL. You can clearly see that noun1 returns the wrong thing.

Note that there is no object for the ball. It is a topic in the book. It has an entry in the vocabulary to work around Adventuron's inability to recognise topics or concepts that do not have objects, hence can never be in scope.

Hi Garry,

This is expected behaviour.

The following line does the following things.

  • It defines an adjective "ball" (via id 'ball_twine').
  • It defines a noun "twine" (via id 'ball_twine').
  • Every time it encounters the following text sequences "ball of twine",  "ball" or "twine", it replaces the text sequence with the registered noun for the object, "twine".
   ball_twine : object "a ball of twine" at = "room" {experimental_matching_text_sequences = ["ball of twine", "ball", "twine"]}

The long and the short of it is that every object needs a noun, and the last (non numeric) segment of the an object id is the noun. 

Any text substitututions you register take precedence over parsing the sentence, therefore 'noun' will return the substituted version.

Chris

I know what it does. I worked that out for myself, but what it does is wrong. I ASK ABOUT BALL, not twine. Why does noun1 return twine, when the primary noun for twine is 'twine' and the primary noun for ball is 'ball'. It simply doesn't make sense.

When both objects are in scope, 'ball' is a better match for ball, than ball of twine. When only the ball is in scope, 'ball' is the only match for ball. When only the ball of twine is in scope, 'twine' is the only match for ball.

It strikes me that it stops processing as soon as it finds the first match for 'ball' and that happens to be the ball of twine. It does not continue processing to see that there is a better match later on. In the real game, the ball of twine is not even in scope, yet it still returns 'twine'. I've got a feeling that if I was to define an object for ball BEFORE the twine (even though there is no such object), then it would find the ball first and use that, even if it's not in scope. And then I wouldn't be able to refer to the ball of twine as 'ball'.

So how do I work around these shortcomings?

You defined the "ball of twine" to have associated noun "twine". You made ball an alias for twine, therefore when you ask about ball, adventuron sees "ask about twine".

If you want things to be different, then define your "ball of twine" to have noun "ball".

If you were using s1() and disambiguate_s1()  then explicitly checking for one particular noun alias wouldn't be necessary. Adventuron is doing exactly what it should be doing. You created a mapping between ball and twine (from ball to twine). That's why Adventuron sees it as twine. If you don't want the associated, then don't make twine the primary noun for your ball.

e.g.

// Now the primary noun is "ball".
ball : object "a ball of twine" ...... ;

I don't think you understand. I don't want twine to be recognised at all when it's not in scope. The ball you read about in the book is a completely different ball. It's a rubber ball. It's NOT the ball of twine. You cannot read about the ball of twine in the book.

You're right, I don't understand. You are going to have to simplify it for me, because as I understand it, Adventuron is acting as-designed.

If the rubber ball is a different ball, then why is it not in your code snippet? I can only understand the elements you place in the code snippet.

It's in the code snippet. The ball is NOT an object. It's a topic in the book. When you READ ABOUT BALL, you're supposed to get told about the rubber ball. Instead, you get told about the twine. I didn't ASK ABOUT TWINE. How can I possibly make it any clearer?

This ensures that "twine" is never a primary noun and "ball" is not an alias.

start_at = room
game_settings {
   add_standard_prepositions = false
   experimental_new_parser = true
}
locations {
   room : location "You are in a room.";
}
objects {
   ball : object "a ball of twine" at = "room" ;
   text_book   : object "a text book" at = "room";
}
on_command {
   : match "_ _" {
      : mask {
         : print {("^n^verb = " + original "verb")}
         : print {("^n^preposition1 = " + original "preposition1")}
         : print {("^n^noun1 = " + original "noun1")}
         : print {("^n^preposition2 = " + original "preposition2")}
         : print {("^n^noun2 = " + original "noun2" + "^m^")}
      }
   }
  : if (is_present "text_book") {
      : match "read _" {
         : if (preposition1_is "about") {
            : if (noun1_is "ball") {
               : print "It says you only need rubber to make a ball.";
               : done;
            }
            : print "There's no topic on that.";
            : done;
         }
      }
   }
}
vocabulary {
   : experimental_replace { text = "ball of twine" with = "ball" }
   : experimental_replace { text = "twine" with = "ball" }
   : preposition / aliases = [about]
   : noun / aliases = [ball]
}