Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Help me clever people! (Sentence deciphering)

Author
Message
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Apr 2009 02:06 Edited at: 30th Apr 2009 02:09
I have been planning a Mafia based game for a while but it just felt like something was missing. Then the other night I had an idea...
I want to have an input system similar to text adventure games so instead of clicking orders you'd actually speak to your men.
The problem I have is I'm very inexperienced at this sort of thing, I've only ever made a very simple adventure game with one-word input.
This Mafia game would require being able to type a whole sentence and the program extract meaning from it. i.e. "Carlo, take Mickey and Paulie to Old Barzini's place and shoot it up!"
Is it possible to write a program that could actually understand that sentence and carry out the orders?

The purpose of using this system is to make it seem real, like you are actually talking to people. There aren't many subjects to talk about as gangsters so they don't have to be Shakespeare or anything.

Has anyone done something similar?
Any suggestions on how to structure this?

btw this game will have no graphics at all.

1337 - "That's Numberwang!"
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Apr 2009 02:22
Check out this thread. Should get you on the right track:

Zork

And I remember messing around with a chat bot years ago... seemed not too bad and it "learns" any language. Check out:

Dante

Enjoy your day.
thenerd
16
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 30th Apr 2009 02:58
here's my way:

before doing anything,convert everything to lowercase (It's easier)

then I would first sort out all the verbs (actions that could be performed in the game), like run or take.
Next, I would filter out all known characters in the game at that time.
Next, known places.
All these would be stored in variables (character="bob",action="take",place="bank")

example:
input -> Take Bob to the Bank.
verbs -> take
people-> bob
places-> bank
translation: take bob bank
you could code in a few simple functions, like take,run,shoot,, and anything else that applied to the game. when those words were recognized, the program would execute the appropriate function. The function would take the variable for the character and the variable for the place, and use them to find out what to do.

all other unknown words would be ignored.
If no words were recognized, it would simply printsentence,"? "What?"
This would end up with this output:
go tak bobf to the bafk? What?
It would then ask again.

complicated enough?
I know this strategy works, because my first DB program was a text RPG. The thing never got going, but the text recognition was excellent.

Now is better than never.
Although never is often better than *right* now.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Apr 2009 03:00 Edited at: 30th Apr 2009 03:04
awesome latch thanks
i've bookmarked it for tomorrow.
Those direction arrays are very clever. I love/hate it when you read something so simple and logical but yet you never thought of it yourself.

Thanks nerd that also helps "mmm IC beer aarrrgullgg"

1337 - "That's Numberwang!"
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 30th Apr 2009 03:03
Yeah, I did it once for a text adventure, though I don't think that I still have the code.

Here is the idea:

All together there are 7 word banks:
1) A general list of all words (used for correct spelling and is downloadable)
2-7) A list of different words for different actions based off 1 for each of the 5 senses and 1 extra for the GO category (since go doesn't fall into anything else, but is still necessary)

Then, there is a file that contains a list of available nouns (names for your mafia members or whatever)

The code works like this:

First sweep of the command breaks the sentence into words by scanning through until a space is found and it stores each word into an array for easy referencing.

Second sweep checks the words against the word bank to check for appropriate words (so the user won't be able to type "Vinny adsfsdf;lsafd Carlos shdlf;ajsd;f attack sdl;fakjsd;fl them" and get Vinny and Carlos to attack someone). If a word fails, everything is done and the bad word is returned with a "That does not compute" style message.

Third Sweep will find the action to do. This is done by comparing each word to the words in your 6 actions word banks (You could probably deviate from the 5 senses and a go but this is how mine was structured). Once the verb is identified, a flag is set to the appropriate action code. If no verb is found, all further sweeps are considered done and the return message is something along the lines of "Whaddya wan us ta do boss?"

Fourth sweep will check the words to identify the nouns. In your case, the nouns BEFORE the action (which you have the word number for stored in a variable) will identify the Mafia members and the nouns AFTER the action will identify the target. If either a Source (Mafia Members) or a Target are missing, you get a "WHO??" message. To figure out which nouns are which, the words are compared to the noun files (could be split into "Mafia" and "Enemy" or even a file for each possible target, should you want a diplomacy aspect to the game, so that you could keep track of families).

So, the structure after would be: Source Action Target, thus eliminating useless words like "THE" "and" and "uh". Also, as each source/target is found, its flag should either be stored in a variable or an array (depending on if you want to have multiple sources and targets for any give command).

This worked for the text adventure quite well. I was able to type "Walk west" to have my character move west or "Look at apple" to well, you get the idea.

It could probably be simplified further and done in a single check, but I made it at school and wrote it all down in a spiral bound notebook, so it was kinda messy to begin with. The important thing is that it worked.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Apr 2009 03:17 Edited at: 30th Apr 2009 15:25
there are five tenses?? now I feel tense heehee
thanks BN2 I'll look into it properly tomorrow I'm going to run out of beer at this rate
and another for latch
the best gifts in life are free... and you can't drink, touch or possess in any way.

that dante reminds me of Virtual Hal that I downloaded, it was kind of creepy because it protested it was a human, oh and I also had a 3D frog that would learn things you told it.

anyway see you on the flip side homies [ic:cooldude] lol

[edit]
"5 senses" - ahh I miss read that as tenses.

1337 - "That's Numberwang!"
Gosub
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 10th May 2009 23:41
Programming eventual conversational contexts would surely take a large ammount of time?
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th May 2009 00:19
@Gosub
This doesn't need to be so elaborate, I don't need to be able to have a conversation with the AI just enough to establish actions that are to be performed.

I do plan to include a few customery things, like people responding to you saying "good morning" or "how are you?". This would make people like you more if you are polite to them.

The reason why I want to do this game with text input is you'd have to think about what you say to people. Every person you meet has 3 emotions towards you: Respect, Fear and Love (in fact the entire game is based around Mind, Body and Soul) people's emotions will effect their actions, but different people respond differently. Each person has 3 aspects of their personality: Intelligence, Bravery, Loyalty (again Mind, Body, Soul). So for instance someone could have hig Respect for you but still betray you if they are naturally disloyal.
I want the differences in character and emotion to come out in the dialogue so you get little clues to their true intentions.
Ambitious!

Riddle: The more you take, the more you leave behind. What are they? Answer

Login to post a reply

Server time is: 2025-06-08 05:37:30
Your offset time is: 2025-06-08 05:37:30