learning experience

I was wondering if anyone was interested in modifying this code i copied pasted from the internet as a learning experience for me and them.Here is the blend.another text game.blend (521 KB)

i not know much about it ,just should be more simply using some container list (or dictionary?)
to keep the string.


import bge,random




LIST=[
"My name is earl. And i have a wife named milly.That has a daughter named susan.Susan likes to play hopskotch.",
"She does but she does not like it.",
"Today's date is november 18,2013.",
"I don't know what you are talking about.",
"You know what i think it is "   +  "miss ebins.",
"This is a good year "   +  "bob.",
    ]


cont = bge.logic.getCurrentController()
own = cont.owner
if cont.sensors["SPACE"].positive:
    own.text = random.choice(LIST)

From what I grasp, the code checks some user submitted text and picks a predefined answer.
Unless I missed something it does so in a very complicate way but it is always hard to say why an idea gets translated in a awkward program.
How would you like to adapt that program? What kind of functions do you need to have or modify?

It was dialogue system but not an effecient one.
I want the the program to tell the person that it does not understand what is said?If the question or anwer does not match what it has stored.Identify if the sentence is a question by these words what, when,where,who,how and which.Then identify what or who the question is about.Then answer the question.Identify also if the sentence is a statement and what that statement is about.And then display a
sentence about that statement.I want to be able to talk to pioyu my dosal zombie female.The character i made.I made her into a girlfriend in my head.I want her to come to life somewhat.

It is a remarkable objective, but we’re talking about winning a Turing Award here. I can show you how to get from the user input to a function that processes that input but how to “understand” the meaning of what the user types requires at minimum some knowledge on the semantics of natural languages, and I know as much about it as about string theory: I know someone knows something of that.

Here’s a zip with a blender “talk to me” structure.

http://www.tukano.it/blender/TestTalk.blend.zip

Press P, type something, you can see the available question-answer pairs in the “convMap” dictionary (in the code)

The code should be straightforward. If the user is writing something and he’s not still writing it, it takes the sentence and “computeAnswer(input)” where input is the typed text.
Your purpose it to process that input value and return some text.
Instead of the simple substitution and hash check done in the actual computeAnswer method, you may start trying to split the text into words and decide what to do by parsing the first word first.
I don’t know if that will get you any closer to an expert system though.

When i changed the name to pioyu in the answer.It answered the question but afterwards it said that i do not understand.

I checked it and it works as it should, which, in software terms, means that it might well not work at all.
What’s the exact text you typed?

This is the text i used.

convMap = {
    "":"I'm eager to talk",
    "hello":"Hi there!",
    "whats your name":"My name is Pioyu"
    
}

That’s perfectly fine and you changed it as it should be changed to work. And it works here. I’m interested in the other string, the one you typed to try to trigger the answer. Notice that the code doesn’t remove all punctuation, just some. So if you write:

“what’s your name?” the answer is “I do not understand that” because there is a trailing “?” that doesn’t get removed.
The same goes for extra spaces: one more and the answer is nay.

I checkd here and if type:

“What’s your name”
“Whats your name”
“whats your name”

the answer is triggered as it should be.

Oh it was because i was pressing enter.Why can’t i add?

"Could you make me some tea please i am thirsty":"Okay i will"