Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: [1] 2  All

Author Topic: Complex dialog systems  (Read 9942 times)

0 Members and 1 Guest are viewing this topic.

lefthandblack

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile
Complex dialog systems
« on: March 26, 2008, 04:06:58 PM »

Hello. First, I would like to congratulate and thank Mnemonic for creating and providing such an amazing tool. I've looked at some of the games that have been made with the engine and was very impressed.

I've had an idea for a game buzzing around in my head for a couple of years now. I started building it in flash, but ran into a brick-wall due to the limitations of flash. The main concept of my game revolves around a complex dialog system. At it's core, my game is going to be an adventure game, but dialog will play a much more significant role than any typical adventure game. Much of the gameplay will be advanced through the user talking to the NPC's via keyboard "chat".

What it amounts to, is that every NPC in my game is going to be a unique chatbot with it's own personality.

I've looked through the engine's documentation and it seems that it may very well be suited to my purpose as it supports arrays and seems to have functions for file I/O.

This is how it would work:

User Input (string) is analyzed and a proper response (if found) is given.

Example:

The PC initiates a conversation with an NPC, let's call him Bob.

PC: "Who are you?"
--> The npc's script searches the request file(array) and finds the proper response to the string "Who are you?" in the reply file(array).
Bob: "My name is Bob."
--> If the request "Who are you?" is not found, a canned response is generated, probably something like:
Bob: "What do you mean, "Who are you?"
-->(What do you mean, 'userinput') Where 'userinput' is the variable for the string the user typed.

Every unique NPC would have their own request file and reply file which would be called from their script when the PC initiates dialog.

I've written a little console app that allows you to "chat" with your NPC's and build their personality through typing in plain English rather than putting hundreds of strings in a stringtable.

The resulting files are structured like this:

Request file:
Who are you?
What is your favorite color?

Reply file:
My name is Bob.
My favorite color is blue.

The NPC's script would read the request and reply files and store the resulting strings in an array for requests and another for replies. Once the user enters a string, the string is analyzed and matched, then the proper response is generated.

If I can get this basic system working, I have plans to add variables for disposition, etc. that would determine what information an NPC would reveal to the PC.

I actually had the system working perfectly in flash, but flash doesn't have the file I/O that I need to save an NPC's personality once I have it developed.

Do you think that I could implement a system like this in WinterMute?
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Complex dialog systems
« Reply #1 on: March 26, 2008, 04:08:17 PM »

yes. It's quite easily possible. (where easily as in not hindered by engine if you know how to code)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

lefthandblack

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Complex dialog systems
« Reply #2 on: March 26, 2008, 04:22:49 PM »

Thanks for the quick reply.
I'll get to work then.
Logged

loken

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
Re: Complex dialog systems
« Reply #3 on: March 26, 2008, 05:10:01 PM »

Reminds me of Starship Titanic.

Ever played that? It was created by Douglas Adams, of Hitch Hikers Guide to the Galaxy fame.

It was an adventure game on a starship, somewhat similar to Myst in gameplay, but with characters and dialog. Much of it was driven by a parsed text interpreter.

I thought of implementing something similar, but I'm a lazy coder. Don't feel like writing a parser, and if I were to do it, I'd give it some sort of fuzzy logic rather than plain conditional statements.
Logged
-loken

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Complex dialog systems
« Reply #4 on: March 26, 2008, 09:32:48 PM »

I think players are quite lazy for that. They become sort of point'n'click. Starship Titanic was funny game though. :)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

sychron

  • Wanderer zwischen den Welten
  • Global Moderator
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 223
  • There is no spoon. The enemy gate is down!
    • View Profile
Re: Complex dialog systems
« Reply #5 on: March 26, 2008, 11:54:30 PM »

point.

but it's cool, anyways!

I once began to code a simple eliza KI for the dialog contest, but stopped working on this due to time restraints. so be encouraged: It works.

Hint: Read the threads about UI , Windows and free floating buttons (and other UI elements) carefully, they might help you when it comes to coding the actual text input elements.
Logged
... delete the inner sleep ...

lefthandblack

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Complex dialog systems
« Reply #6 on: March 29, 2008, 03:43:53 AM »

I've never played Starship Titanic, but it does sound similar to what I'm trying to do.

After alot of attempts to figure it out myself, I'm throwing in the towel and asking for help.

This is what I have right now:
Code: [Select]
#include "scripts\base.inc"
#include "scripts\keys.inc"
//
// BRAIN FILES
var ReqFile = new File("AI\Req.txt");
var RepFile = new File("AI\Rep.txt");
// ARRAYS
var requestfile = new Array();
var replyfile = new Array();
// STRINGS
var control = this.GetControl("userinput");
var input = new String();
// TOGGLES
var sent;
var understand;
var analyzing;;
// READ TEXT FILES AND STORE CONTENT IN ARRAYS
function LoadBrain(){
ReqFile.OpenAsText(1);
RepFile.OpenAsText(1);
var RequestCont = ReqFile.ReadText(1000);
var ReplyCont = RepFile.ReadText(1000);
requestfile.Push(RequestCont);
replyfile.Push(ReplyCont);
Sleep (1000);
ReqFile.Close();
RepFile.Close();
Sleep (1000);
return;
}
//
LoadBrain();
//
// LISTEN FOR ENTER KEY
on "Keypress" {
   if (Keyboard.KeyCode == VK_RETURN){
   enterkey();
     }
// ANALYZE USER INPUT
   if (sent == 1){
        analyzing = 1;
analyze();
}
   // COMPARE USER INPUT TO STORED ARRAYS
   if (analyzing == 1){
   Game.Msg(requestfile[0]);
   }else if (analyzing == 1){
   Game.Msg("Huh?");
   }
   analyzing = 0;
}
//
// GET USER INPUT AND CLEAR EDITOR ON SUBMIT
function analyze(){
input = control.Text;
Sleep (100);
sent = 0;
control.Text = "";
return;
}
// RESET STATE
function enterkey(){
sent = 1;
return;
}


This is the script for my window/editor.

The first problem is that the resulting arrays end up with the whole file in one index.

Once I manage to get the files to translate to a properly indexed array, I imagine that
I'll need to loop through them with a for loop to match the strings, correct?

In flash, you can search an array of strings with Indexof, comparing your user input string with the strings contained in the array, but that doesn't seem to work with WM unless I'm doing something wrong.

Thanks for any assistance anyone can provide.
Logged

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Complex dialog systems
« Reply #7 on: March 29, 2008, 04:48:57 AM »

Have you got it functioning at all? Or just problems with the array stuff? I am very interested in how this might pan out. I never even considered using a text input in WME. I have always loved text input games form when i was a kid. I still think that they give you a great feeling of exploring .. spesh in detective games.. as asking the right questions can make all the difference.

Quote from: metamorphium
I think players are quite lazy for that. They become sort of point'n'click. Starship Titanic was funny game thoug
I do not agree with. Players WILL use advanced chat features if they feel that they are infact gaining stuff from it. I know many people click though log books, conversations whatever, only because it don't matter if they DO skip them. if you can make your conversations good enough that they can uncover clues.. even trick or bluff or bully the npc... then this method can give a better feeling of the player being in control.. of his/her own will affecting the game more than any point and click interface.... ..  not that it wouldn't be mucho hard

On a side note: I wrote as a learning thing a while back a text adventure game before i found WME and used a very sim method for analysing text. I found that searching for keywords was far more effective than sentence strings. Through the use of thesauruses arrays "linked" to keywords in a master array (so any word that means door / doorway / entrence  etc would return the same analyzed text value. These results were inturn sent to a coded array of numbers... so is code 10 returned (what?) then the NPC new it was a question ... 10/5 returned (What? / Doorway) You know it was a question about the doorway.. and.. well i think you get my point.

This allowed the suer to use a huge range of ways to express a question or action and still have it understand it... with out the need of sentence strings... meaning that the player didn't have to type the exact sentence.. (we all remember Zork yea? How much did that suck when you had the right idea but spent 20 mins typing it in different ways!!)

Good luck!!!

Please post tech demos!!!!
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

lefthandblack

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Complex dialog systems
« Reply #8 on: March 29, 2008, 06:40:54 AM »

Well, I'm kinda stuck until I figure out what I need to do to get the arrays sorted out and the proper method for searching them and matching strings.

I'm glad to see that I'm not the only one that thinks this might be an interesting thing to try. I know that I've wasted many more hours than I'd care to admit talking to various
chatbots. It occurred to me that you could create game NPC's with alot more depth if you
could get a system like this into a game.

As far as the keywords thing goes, the console app I wrote is very efficient in that you can
just chat with the bot full-throttle just as if you were talking to a real person via IM or
something. This allows you to create TONS of strings in a short period of time.
You can even leave your typos in to account for the inevitable typos that a user is going to make. If it becomes apparent that keywords are needed that can be something I can add.

I'm planning on much of the progress being tied to NPC alliances and disposition, i.e. an
NPC that likes you will reveal good, truthful information, an NPC that doesn't like you will
either reveal nothing at all or may even outright lie to you. The beauty of having the NPC's personalities in separate files rather than hardcoded into the game is that you can switch them out on the fly. So you could have different personalities for the same NPC that would depend on disposition/alliances.
Logged

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Complex dialog systems
« Reply #9 on: March 29, 2008, 07:27:09 AM »

this sounds so cool... i really hope you get it working... The thing i was talking about was just a key word filter i guess you would call it to enable the NPC to respond off a listed conversation topics... not a chatter box like alice or barry or something.
« Last Edit: March 29, 2008, 08:42:28 AM by Jyujinkai »
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Complex dialog systems
« Reply #10 on: March 29, 2008, 09:46:14 AM »

To read the file line by line, use the File.ReadLine() method. You are right, though, there's currently no method for looking up an array item.
I'm not really sure you can do a decent AI with fixed response strings, though. Typically the analysis involves synonyms and such...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

lefthandblack

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Complex dialog systems
« Reply #11 on: March 29, 2008, 10:25:39 PM »

Okay, thanks for the info.

Since I can't search an array, I decided to try reading directly to and from the files, but I've run into a problem with IndexOf there too.

When I try:

var test1 = new String("test");

  if (input.IndexOf(test1) != -1) {
   Game.Msg("works");
   }

Where input is a string containing the text passed from my editor.

I get the error: Call to undefined method 'IndexOf'. Ignored

If I try:

var test1 = new String("test");
var test2 = new String("test");


if (test1.IndexOf(test2) != -1) {
   Game.Msg("works");
   }

I don't get an error, so I guess IndexOf can only be used to match predefined strings.

If this is the case, then I'm probably out of luck, as the string from my editor is user
generated and could be anything.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Complex dialog systems
« Reply #12 on: March 29, 2008, 11:19:55 PM »

where's the input declared? Show me the declaration.

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

lefthandblack

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 8
    • View Profile
Re: Complex dialog systems
« Reply #13 on: March 29, 2008, 11:56:56 PM »

I'm still working off of the initial script I posted in the 'code' block above.
'input' is declared at the top of the script and then changed to the editor content here:
Code: [Select]
// GET USER INPUT AND CLEAR EDITOR ON SUBMIT
function analyze(){
input = control.Text;
Sleep (100);
sent = 0;
control.Text = "";
return;
}

I tried removing the part that clears the editor as well as the return, as I was thinking that I may not be giving it enough time to pass the string through, but that didn't help.

If I try:
Code: [Select]
if (input.IndexOf(test1) != -1) {
   Game.Msg("works");
   }
At the section // COMPARE USER INPUT TO STORED ARRAYS
With the variable test1 containing "test" declared at the top of the script, then start up the
game and type "test" into the editor and submit it, I get the error.

If I replace the variables for input and test1 with predefined strings, I don't get an error and my debug message "works" comes up just like it should.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Complex dialog systems
« Reply #14 on: March 30, 2008, 12:10:44 AM »

input = new String(control.Text);

or maybe

input = ToString(control.Text); // this I am not sure of.

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
Pages: [1] 2  All
 

Page created in 0.028 seconds with 24 queries.