Writing Natural Typed Conversations

kyromatic
18 Aug 2016, 01:12

I have found resources on the forums and Documentation, but nothing quite hits what I am looking to do.

My game is a conversation between two people the first being the player and the other being an AI. Both characters move between rooms and the player can interact with objects.

The type of dialogue I do not want is:

"TALK TO BORIS

  1. Where is key
  2. Who is the Queen
  3. How do I defeat the troll"

What I want is for the NPC to ask a question, trigger a dialogue tree that can switch responses and options on/off depending on what the character asks or responds with. Eg:

"Hello, Player. How are you today?"
I am doing well
"Glad to hear it!"

or

"Hello, Player. How are you today?"
I am sad
"Sorry to hear that."

Is something like this possible within Quest? Thanks for you help :)


XanMag
18 Aug 2016, 02:22

Quick question - what triggers the NPC to ask a question? Is it a talk to; speak to verb or an event or some established attribute?


hegemonkhan
18 Aug 2016, 07:44

that requires some very advanced/complex parsing coding... to be able to handle such conversational complexity...

it can certainly be done... but not something easy to do, you've got to be a good programmer, to be able to handle the parsing of human language sentences/conversations (questions and responses based on those questions and additional questions based on those responses, etc).

I'd look into Pixie's and Jay's dialogue/conversation libraries. Jay also has a game 'spondre' that probably has some advanced parsing, and he's made the game/source code available publically too. they got the expertise to help you with this level of coding that you're requiring for what you want to do. So, get help from them, as parsing/handling of human-level conversation/dialogue, isn't something that is easy to program.


actually... getting a computer to understand and/or learn human level dialogue/conversation/language, is extremely high sci-fi-esce level of A.I. programming, that we're just recently being able to get some small progress into.


if you just want something much more "simple" ...

then you just need to look into using Commands/'get input' Script/Function, learn how '[EXPRESSION]' (using TEXT and VARIABLES) 'print a message' Scripts/text processor commands work, learn the string manipulation Scripts/Functions, and/or learn using List/Dictionary Attributes:

http://docs.textadventures.co.uk/quest/elements/command.html
http://docs.textadventures.co.uk/quest/scripts/get_input.html
http://docs.textadventures.co.uk/quest/guides/character_creation.html
http://docs.textadventures.co.uk/quest/text_processor.html
http://docs.textadventures.co.uk/quest/guides/using_lists.html
http://docs.textadventures.co.uk/quest/using_dictionaries.html
http://docs.textadventures.co.uk/quest/functions/ (scroll down to the very bottom, to the 'string functions' section, for the string manipulation functions)


kyromatic
18 Aug 2016, 15:04

XanMag - The NPC is like a narrator pushing the story forward. There would be instances where the user is required to respond to questions or ask them.

hegemonkhan - Before trying Quest, I was actually messing around with using a ChatBot. Hahaha

In my head, what I would need to do is lay out a number of different ways the player could respond using if/and/or statements. For example, if the question is "How are you doing?" the script would look for a phrase that included "good, great, okay, fine, happy" or "bad, meh, sad, tired" and ignore text before or after the key words, then send out a response according to the key words. I would have a few basic responses set up if the player did not use one of the key words that would be "I'm sorry, I'm not familiar with that phrase." Or something. Not trying to pass a Turing test, just trying to get the program to accept player input with "I'm feeling good" or "I'm okay" or "great" and send out the same answer of "Glad to hear it!" based off of the key words.

The way I am doing that in Quest, but not doing it very well, is limiting dialogue trees to rooms and hidden objects, then creating objects that are words like "good" that have 'other names' and a list of 'verbs' that are possible phrases the player could type. I feel like there has to be an easier way, even if it's writing out the code to do it.

Does that make sense? :P


hegemonkhan
18 Aug 2016, 20:10

this type of stuff is way beyond my ability, you should wait for Pixie or Jay to help you, as they got the expertise to do so.

if I were to take a guess, you'd want to look into (learn) using lists/dictionaries and the string (manipulation) functions and also regular expressions (regex) stuff.

(there's two ways to get typed-in input with quest: the 'get input' Script/Function and Commands)


XanMag
19 Aug 2016, 02:44

Is it possible to embed commands into a Get Input? This seems like it wouldn't be too hard if it is possible, but... I'm not so sure you can? I've been wrong before though. lol Or maybe you can use the text processor to check for those key words?

@Uber-coders... does that make sense?


The Pixie
19 Aug 2016, 06:50

You should be able to do this using the "active conversation" feature of ConvLib:
http://textadventures.co.uk/forum/samples/topic/5510/updated-convlib

You do need to be using the off-line editor to use libraries however.


Jay Nabonne
24 Aug 2016, 11:43

It's not even that this is tough to do in Quest - it's tough to do period. Any keyword lookup is going to be a problem. Consider answers to "Hello, Player. How are you today?"

"Magnificent!"
"Glorious!"
"Excellent, thank you!"
"I don't want to say."
"F**k off!"
"I've had a good dose of misfortune lately" (Matches "good", so gets response "Glad to hear it!")
"Good god, why are you talking to me!"
"I've been a bad boy lately! :evil:"

Not to mention that there are no constraints for the player whatsoever. The examples you gave above are trivial. If you want this to be your overall interface, how would you extend it to deeper levels of conversation?

I would say that unless you want to devote a lot of time to working out a true natural language processing solution, that you think twice about heading down this path. Not that I want to sound negative - I am all for encouraging people to try things! But if your solution is going to be keyword matching, I can guarantee that you'll end up frustrated and unhappy. I had a bad experience with keyword matching, and I wasn't even being as extensive as what you want to do. When the user can type "I love you" vs "I'll never say I love you", then you have a lot of context to try to work out to have responses that aren't laughable.

And the more leeway you give players, the more they'll take. They love to push the edges of a system, doing things you have probably never thought of and could spend a lifetime trying to compensate for. :)