Need help with optional words in parser

Started by CUG, Sat 26/04/2003 12:45:42

Previous topic - Next topic

CUG

G'day.

As the help happily says, you can put a word you want to be optional into a pair of square bracket.  And this is good because nobody wants to add lots of ORs.

Since I am stupid and I want to make one of those "let-the-fool-user-believe-he-is-chatting-with-a-real-person" programs, like ECC-ELIZA or something like that, I thought that putting "ANYWORD" in square brackets would have been very useful. In fact, in these "pseudo-AI" programs it would be better to recognize a word into a sentence, no matter the position.

Thus, I put [anyword] into square brackets, but damnit, it doesn't work.

I put something like this

if (Said("[anyword] AGS")) DisplaySpeech(EGO,"It's a nice tool.");

if in the game I simply write AGS,  it comes out saying nothing, because the word AGS is in the dictionary, and it is recognized, but it doesn't have anyword before, and so EGO doesn't say anything.

Is there a way to work around this? I can solve the problem by ORing sentences, but is there some thing I have overlooked? Is this a bug or it was meant? I'm waiting.

Saludos.

CUG

RickJ

Have you tried something like this ...

  if (Said("anyword AGS")) DisplaySpeech(EGO,"It's a nice tool.");

I haven't done much with the parser but you probably can't use special keywords inside brackets the way you expect.  

Pumaman

Actually, it does work - but it's not doing what you expect.

It goes through the sentence from left to right, matching up words. So, it sees:

[anyword]

and compares it to the user input

AGS

and yes! AGS is any word, so that matched up! Now, it carries on, and tries to match

AGS

from your Said query, with nothing, because it has exhausted the user input. This, obviously, fails.

Basically, putting anyword in square brackets will have no affect, because any word will always match it.

You'll have to do this specific instance with ORing two Said's:

if ((Said("anyword AGS")) || (Said("AGS")))

CUG

Aha, stupid me. Thanks A-Lot, my "Fake chat" game can stride forth.

Saludos.

CUG

SMF spam blocked by CleanTalk