Creating AI Chatbot for character.

Started by FanOfHumor, Wed 05/01/2022 00:38:40

Previous topic - Next topic

FanOfHumor

I am attempting to create a very basic AI chatbot for a character.I don't know if this is possible or not but i'd like to attempt it.I know that in order to create a chatbot It has to be able to search for particular words in the input and to store unknown words in a dictionary.Then if I could get this to understand just yes,No commands I could slowly teach it words.I thought that maybe using integers and creating a file It could store words.But first I need to figure out how to let it search typed input for known words and store new words in a dictionary .

Any help with this would be appreciated.

deadsuperhero

#1
AGS does in fact have support for a Dictionary object. Maybe you could start by creating two: one for known words, and another for words to be learned? Maybe you could also somehow define a large list of synonyms for your known words?

It should also be possible to split up phrases word by word using something like Substring. Here's also some documentation for the Text Parser and some related functions.

Maybe you could do something like this:

1. Take player input from a text parser interface and save it as a variable.
2. Split up the sentence word by word, and check if any of them are in the Known Words dictionary, checking against known synonyms for each word.
3. Add Unknown Words not found in the dictionary to a Learned Words dictionary.

I'm not really sure how to progress beyond that point - AI Chatbots have progressed a lot in the past 20 years or so thanks to advancements in Sentiment Analysis and language models like GPT-3, but I think AGS is pretty limited in terms of what can be done here. You might be able to get away with creating a Markov Chain-style chatbot, which builds a table of seen responses to existing words and tries to create new responses to your prompts accordingly.

You could also borrow some ideas from AI Dungeon, which is open source and offers a seemingly comprehensive manual on how its GPT-2 based system works for generating realistic responses.
The fediverse needs great indie game developers! Find me there!

FanOfHumor

#2
How do you save player input as a variable?

deadsuperhero

Quote from: Pajama Sam on Wed 05/01/2022 04:01:43
How do you save player input as a variable?

In a nutshell, you first need to have a GUI with a TextBox in it.
Once you have that in the GUI, you'll need to click into the Events pane (the lightning bolt) to generate an _OnActivate event handler for that GUI element.
So, assuming your TextBox element is named TalkBox...

Code: ags

 if (IsKeyPressed(eKeyReturn)) { // Only submit text after player hits "Enter"
   String sentence = TalkBox.Text; // Save it as a local variable of the String type
   Parser.ParseText(sentence); // Parse the entire sentence
  }
}


That's a pretty basic starting point for text parsing - obviously, that doesn't do very much on its own, but you can use some of the documentation I pointed to earlier to extend it.
The fediverse needs great indie game developers! Find me there!

FanOfHumor

Thanks for explaining it. I'll get back to this when I have a chance.

SMF spam blocked by CleanTalk