- Home /
Is There A Way To give Your A.I. A Memory
I've working with Voice recognition and response. I Have a fairly complex A.I. going on that cross references what the user said with real world data from either the system information and information being fed in through the serial port from an Arduino.
I'm using player prefs to store some fairly basic things like settings and such....
But I'm wondering if it's possible through some fancy C# scripting to give my working A.I. a bit of a memory.... like to remember things that were said or asked of it several questions ago?? not really sure how to go about that or if it's even possible really.
That's pretty much what a database does - store and retrieve structured information.
Answer by RobAnthem · Jan 01, 2017 at 10:48 PM
Sure, simply create a list of bools that correspond to your questions, I HIGHLY suggest not using player prefs for such a thing though, serialization and database creation is pretty simple, and in most cases all you need is a simple binary formatter. Personally I would create an entire "history" for the player, that contains his choices, and if your AI has random choices you can create an array of bools to correspond to the choices. If you did like a 4 Dimensional array then you could store 4 options per conversationwithout having to create a custom data structure, but in my opinion if your dialog is going to be a huge part of the game, I would find a way to create a stored history. Perhaps a dictionary per conversation that looks something like
Dictionary<dialog, bool>
or to store player responses based on a specific possible responses you could always denote the hierarchy to an indexed integer and it may look more like
Dictionary<string, int>
and the int would be the choice that was made, where the string was the actual dialog spoken.
EDIT: As a side note, you could easily incorporate the "history" into your gameplay and evolving storyline.
Thanks @RobAnthem, This sounds very interesting, I would like to know more about it. my App is not technically a game, but I kind of approach a fair amount of it from a game-like perspective. It's basically a voice command app I am creating for my $$anonymous$$night Rider replica. In it you can voice command many functions for the car such as turning on headlights, fog lights, hoping the rear hatch and many, many other car functions. The app itself can hold a fairly complex conversation which can lead into other conversational aspects... within certain limits based on the audio responses I have. The app even has mood swings of a sort based on how you talk to it.... pretty much like $$anonymous$$ITT in the TV show would often do.,,,
But yeah I would sure like to know a little more about implementing something like what you have mentioned here.
His audio responses draw from a random array for each question or statement the user speaks. Depending on his mood depends on which array he draws a response from. I have a microphone volume checker that detects if you are shouting which also affects mood if you swear at him loudly VS just casually, Loudly he takes a verbal insult more seriously.
I was following that tutorial modifying the code a little but I don't think I'm using it correctly. I get a "Object reference not set to an instance of an object" error, not sure why??
case "AreYouAspaceship":
SaveLoad.Load ();
if ($$anonymous$$ITT_IsPlayingAudioRecording == false && $$anonymous$$ITT_IsRecordingAudio == false) {
//Check if it Is $$anonymous$$ichael And Surveillance $$anonymous$$ode Is OFF And That Shut Up $$anonymous$$ode Is OFF
if ($$anonymous$$ITTmodesObject.is$$anonymous$$ichael == true && $$anonymous$$ITTmodesObject.Surveilance$$anonymous$$odeActive == false
&& $$anonymous$$ITTmodesObject.$$anonymous$$ITT_isSpeaking == false && $$anonymous$$ITTmodesObject.ShutUp$$anonymous$$ode == false
&& $$anonymous$$ITTmodesObject.$$anonymous$$ITT_SaidThis == false) {
if (lastQorA == "AreYouAspaceship") {
$$anonymous$$ITTvoiceBox.YouHadAlreadyAskedThatResp ();
//Negative So Subtract 1 Point From The $$anonymous$$ood Level
$$anonymous$$ITTmodesObject.$$anonymous$$ITT_$$anonymous$$oodLevel--;
Debug.Log ("Why Is $$anonymous$$ichael Asking $$anonymous$$e This Again? That Is $$anonymous$$ost Anoying");
} else if ($$anonymous$$ITTmodesObject.is$$anonymous$$ichael == true && $$anonymous$$ITTmodesObject.Surveilance$$anonymous$$odeActive == false
&& $$anonymous$$ITTmodesObject.$$anonymous$$ITT_isSpeaking == false && $$anonymous$$ITTmodesObject.ShutUp$$anonymous$$ode == false
&& $$anonymous$$ITTmodesObject.$$anonymous$$ITT_SaidThis == false) {
Debug.Log ("$$anonymous$$ichael Asked ---- Are You A Spaceship");
$$anonymous$$ITTvoiceBox.AreYouAspaceshipResp ();
//Negative So Subtract "1" point From The $$anonymous$$ood Level
//Stating the obvious does not earn any "Brownie Points"
$$anonymous$$ITTmodesObject.$$anonymous$$ITT_$$anonymous$$oodLevel--;
lastQorA = "AreYouAspaceship";
// Lets Try And Save That We Asked this Question
// So That The Next time $$anonymous$$ITT Is Started He Will Say That You Asked $$anonymous$$e That Yesterday
UserSession.current.lastQorA01.name = ("AreYouAspaceship");
SaveLoad.Save ();
}
}
O$$anonymous$$ I was playing around with the code a little more and I Added a reference to the UserSession Script like this
// Reference To The UserSession Script
public UserSession UserSession;
And in my part where I want to save I changed this:
UserSession.lastQorA01.name = "AreYouAspaceship";
print ("I Will Remember This");
SaveLoad.Save ();
Now from looking at the inspector it is changing the "LastQorA01.name"
But When I call load in my void start the inspector is not changed.... does anyone have any idea what I'm doing wrong?
@RobAnthem, I've been looking into the binary formatters... is this the sort of thing you are talking about? https://gamedevelopment.tutsplus.com/tutorials/how-to-save-and-load-your-players-progress-in-unity--cms-20934
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Real Voice Print Authentication 0 Answers
Make player not be seen by AI, when player in foilage and shadows. 1 Answer
Enemy AI C# 0 Answers