Conversation Simulation Module

Started by Ali, Wed 15/08/2007 22:17:48

Previous topic - Next topic

Ali

I've been working on a basic script for simulating conversations as in the game Starship Titanic, in which the player can type their own dialogue. It is based on this tutorial. It is not intended to evolve by learning new words, like Alice, but rather to simulate the responses of a character in a game.

The module refers to a .dat file and searches the user's input for keywords, then chooses responses accordingly. It is also able to feed the user's input back to them to create the illusion that it understands more than it does. The module can choose certain responses over others based on trust, and can alter trust levels and run scripts during conversation. It is very easy to add to and expand upon the .dat file.

So far I've produced a simple demo in which the player can interrogate an old man called Crookshanks about a recent crime in order to discover the name of the culprit. The game folder can be downloaded here:

http://www.filefront.com/15731565/Dialogue_Parser_Demo.zip.

You've 'won' once you know who did it, and you can bring up the quit dialogue by saying bye.

I would really appreciate the input of more experienced programmers. I feel my scripting is probably not very efficient, and I would be very interested to know how it could be made more effective too.

At the moment it cannot do the following things:

Recognise pronouns, particularly 'it' and interpret them to mean the key subject of the previous line.

Gather information about the player.

Encrypt the data file.

I think I can use monkey_05's module for the last point, but I would appreciate suggestions regarding the other two. I would also like to know if you feel other important features are missing.

Edit: I forgot to say, he doesn't know any expletives yet. Feel free to edit the data file and teach him some.

Recluse

Quote from: Ali on Wed 15/08/2007 22:17:48At the moment it cannot do the following things:

Recognise pronouns, particularly 'it' and interpret them to mean the key subject of the previous line.

Gather information about the player.

Encrypt the data file.

I'm never good for code, but I can help with the general concept of how the above COULD work.

The pronouns thing could be solved by having the dev assign each noun a gender (male would look for he, him, his, female she, her, her's, and neuter would look for it, it and it's.) It would be helpful if this could also be extended by having synonyms for each noun as well, so if I had a dirty old pirate named Bob I could refer to him as either Bob, or dirty pirate, or old pirate, or perhaps just pirate.

Gathering information about the player is more difficult, and therefore more fun. I would have the interpreter look for any personal pronouns referring to the player, such as "me", "I", "myself", and then have a way to parse it. The parser would then look for verb-noun pairs that can be attributed to the player. For example, if I said "I like ponies" The parser would store this information in the format "Player likes ponies." This could then be retrieved, and would be a good way to have gossip spread about the player. Other NPCs could randomly state, upon being introduced to the player, "I know you, you like ponies!". It would make the player more cautious about the random things he/she tells NPCs, because he/she knows that it could very well come back to haunt them.

Encryption is more of a code thing, like I said I'm not really keen on that. However, I know there are some encryption modules that you could possibly make use of.
All your verbcoin are belong to us.

Snarky

#2
I don't know to what extent your code uses standard algorithms (Edit: sorry, I overlooked the bit where you said you were basing it on ELIZA), but binding pronouns to their referents is a major topic in natural language processing (NLP), and there are a number of well known techniques for it. However, the general problem remains unsolved (i.e. there is no known automated method that can reliably identify what a pronoun refers to).

When I was studying computer science we only had one class in linguistics, so I'm a bit hazy on the details, but the problem you're describing sounds like anaphor resolution (binding pronouns to preceding terms). From what I remember, people tend to approach this by performing a grammatical analysis on the sentences, identifying possible referents, and assigning probabilities depending on the distance (in grammatical units) between the pronoun and the potential referent. I vaguely recall a rule of thumb that you only need to look at three things to find the likely match.

I would look for lecture notes on NLP or linguistics that talk about anaphora and cataphora. MIT put theirs online, and since a lot of the important work in modern linguistics came from there, they're probably pretty good.

Edit: A Google search found this (PDF), which includes a discussion of the various methods in the literature (starting on p 37), with references to the relevant research papers.

Ghost

#3
If you need some in-depth information about parsing sentences with english grammar, the Inform Manual has some very interesting background details. The Inform parser is a freeware, highly extended remake of the original Infocom parser, and it is quite versatile. You can find it here. Somewhere in the appendixes.


BTW, the whole idea sounds very interesting, and useful too. I especially like the idea to "spread gossip" about a player. That would really create some additional immersion. Good luck on yer!

Ali

So Recluse, I hear you like ponies...

The idea of gossip spreading is very interesting. It suggests that the module ought to create a pool, or pools, of local knowledge about the player and their quest which all characters can access. I'll have to think about how that could work, but it might be very interesting.

The script currently does allow synonyms for keywords. The data file is just a text file formatted like this:
Code: ags
@KWD@ //What follows is a keyword.
My name is
@SYN@ //What follows is a synonym for the keyword above.
My name's
@SYN@ //Another synonym.
I am called
@SYN@ //And another.
I'm called
Pleased to meet you,* //This is a response, becuase it wasn't preceded by '@KWD@' or '@SYN@'.
Welcome to the Museum of Teeth. //This is another response.
//
@KWD@
I am
@SYN@
I'm
Oh are you?
I bet you are.
I wouldn't have guessed you was*


When the parser finds the asterisk in the response it substitutes part of the player's input.

The resources you guys have pointed me towards seem very interesting, but also very complex. I'm afraid they might be over my head, but I'll give them a go. I'm working on a simple version of pronoun recognition that simply substitutes 'it' for the keyword in the previous sentence. It's far from elegant but it seems reasonably effective. I'll upload an update when I get it working.

I appreciate your feedback.

Recluse

Quote from: Ali on Sun 02/09/2007 12:03:48
So Recluse, I hear you like ponies...

Don't believe everything you hear...   ;)

Here's a problem I've come across in many "dynamic dialogue" engines that I've found to actually accentuate the game's computer logic more than a simple "choose your answer" engine. If an engine is looking for a particular word, and doesn't have sufficient logic to ignore the surrounding words, it will eventually become easier for a player to simply type in words prompted from previous discussions and hope for the best.

I've had to deal with this in Exile 3, an RPG that uses a dynamic engine, I would get something like the following:

"Tell me about the stone."
"Huh?"
"What about the stone?"
"Huh?"
"Stone"
"The stone is an ancient artifact that will help you complete your quest..."

Having to find exactly the right word to type is one of the biggest issues I have found with these sorts of engines. It's currently a burden on the user to provide all the synonyms, but perhaps you could supply a function that searches the entire sentence for the synonym, perhaps with a second part (such as a question-word, or question mark) and ascertain that the player wants to know about that noun.
All your verbcoin are belong to us.

nihilyst

I don't see much benefits from such a complex system. What does the player gain, when he doesn't type in "stone", but "tell me about the stone". I can't imagine any gaming sequence, where that would make sense. A simple system like in "Trilby's Notes" should suffice, something like "ask XY about Z" oder just typing in a single keyword.

edit: ... although this is an interesting approach on game designing, I must admit.

Ali

Quote from: Recluse on Mon 03/09/2007 00:05:54
Having to find exactly the right word to type is one of the biggest issues I have found with these sorts of engines. It's currently a burden on the user to provide all the synonyms, but perhaps you could supply a function that searches the entire sentence for the synonym, perhaps with a second part (such as a question-word, or question mark) and ascertain that the player wants to know about that noun.

If you have a free moment, please try out the demo I've created. It does have the functions you're describing, though only for a limited number of keywords which relate to the 'story' of the demo.

The module will look for two keywords, if it finds two it checks to see if there is a special entry for those keywords together, like 'what, stone'. Otherwise it responds to the first keyword.

The data file's keywords are written in order of significance. This means that 'Can I see your hat?' should pick up on 'hat' rather than responding generically to 'Can I'.

Quote from: nihilyst on Mon 03/09/2007 00:11:44
What does the player gain, when he doesn't type in "stone", but "tell me about the stone".

I would say, a sense of first-hand interaction with a character. Also, in the example you use, the opportunity to ask 'which stone?' or 'what is dangerous about the stone'.

Quote from: nihilyst on Mon 03/09/2007 00:11:44
A simple system like in "Trilby's Notes" should suffice, something like "ask XY about Z" oder just typing in a single keyword.

I find ask X about Y to be very limiting in contrast with choosing from a list of dialogue options. The idea of this module is to allow the player to create their own dialogue options, which I think might be fun.

riseryn

Sorry to post on this old topic but im wondering how such a module make translation harder?

SMF spam blocked by CleanTalk