NPC Learning

Started by
32 comments, last by dwarfsoft 23 years, 8 months ago
I am just pondering over here in my side of the world about how would someone go about making an NPC that learned things about its environment. If we were to have our Scripted NPC who has knowledge about its surroundings (such as "an apple is edible") how would we make this NPC learn more about it''s surroundings. I saw a post a while ago that proposed that if the NPC saw another NPC eating some kind of food, then the NPC could learn to eat that kind of food. I am leaving this fairly open ended, you may even have an idea that does not incorporate scripting, but I would like to see if I can get some more feedback on this so as to further the development of NPC''s on a whole -Chris Bennett ("Insanity" of Dwarfsoft) Check our site: http://www.crosswinds.net/~dwarfsoft/ Check out our NPC AI Mailing List : http://www.egroups.com/group/NPCAI/ made due to popular demand here at GDNet :)
Advertisement
quote: Original post by dwarfsoft

I am just pondering over here in my side of the world about how would someone go about making an NPC that learned things about its environment.

If we were to have our Scripted NPC who has knowledge about its surroundings (such as "an apple is edible") how would we make this NPC learn more about it's surroundings.



Here are some thoughts on learning to consider.

Learning in AI really could be made up of several concepts: Exploration, Evaluation and Reinforment.

Exploration means that the NPC is placed in a world in which it is free to explore new relationships among the objects. For instance, "eat apple" or "eat rock".

Evaluation is a means by which the NPC can determine the effect of some action. For instance, "eat apple" lowers hunger, while "eat rock" damages teeth.

Reinforcement is a means by which the NPC can associate the positive (or negative) result of an action, to that action.

I believe that by using these simple concepts, an NPC can be made to "learn". Implementation details will probably be game specific and are left open for discussion.

Eric


Edited by - Geta on August 5, 2000 9:29:13 AM
More importantly: How would you implement this?

Scripting, I can see a use... The NPC would go to object "apple" and call script item "eat". Apple would return a satisfaction value for such. NPC goes to object "rock" and calls "eat" and the script causes damage...

This is still too difficult as it requires scripting each and every object and action. Maybe there are shortcuts such as inheritance, but that adds to the complexity...

Ideas?

-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
Check out our NPC AI Mailing List :
http://www.egroups.com/group/NPCAI/
made due to popular demand here at GDNet :)
First of all, In the database of different objects, there should be a list of allowable commands to perform on those objects.
Thus, an apple would be eat, throw, etc... That would be a list of everything CAPABLE, not just things that would want to be done. (Poison can sill be eaten.)

BUT, the NPC should only know what is considered common sense. So an NPC should know that an Apple can be eaten, but perhaps not know that the "green fungi that grows on lilly pads" is really good. (fictional here people...)

how the NPC know things is simple. Something like a "Linked list tree." If the NPC sees another NPC eating the wonderful green stuff, he/she can associate it under the "food" branch of the tree, and thus creating a new option for his/her dietary needs...
If you have a database of "what is possible" and your poison still allows eat, then there should be some restriction on eating the poison. Maybe if the NPC was just "tasting" it, then they would become ill... but not die.

About the fungus. If the NPC already associates fungus with mold or "disgusting" then the NPC may be less likely to learn that the fungus is edible (Hell... I know I would! ) so would there be restrictions like this, or is this getting too detailed (and therefore difficult to implement).


-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
Check out our NPC AI Mailing List :
http://www.egroups.com/group/NPCAI/
made due to popular demand here at GDNet :)
Maybe some NeuralNets? I know I started wondering since that post about the learning simulation and the wizard... I searched, but found nothing... I think NNs ca be used, but I don''t know how... Maybe in combination w/ a database: for each player, a db:

object
{
action1 var_that_changes how_much(float);
action2 var quantity;
}

e.g.
    *************human.gdb************apple{  eat hunger -10;}poinson{  eat lifefix 0;  taste life -20;}pear{  eat hunger -75;}peach{  eat hunger -125;}sword{  fight damage -50;}shield{  protect life +100;}***********treespirit.gdb************wood{  eat hunger -50;}fireball{  fight damage -75;}    

but i don''t know how to link these things to a learning Neural Net...

"Everything is relative." -- Even in the world of computers.
everything is relative. -- even in the world of computers... so PUSH BEYOND THE LIMITS OF SANITY!
Hmm... Seeing as I do not know how Neural Nets work (well, I know how they work, but I don''t know how to implement one properly ) I think I can leave it to egerlach or awh to give us the news (news: you can''t use NN for that! ).

Databasing is the only way I can think of doing it. Hmm. Is this the way that you did it for that db of yours? I wouldn''t mind seeing how exactly you went about it

-Chris Bennett ("Insanity" of Dwarfsoft)

Check our site:
http://www.crosswinds.net/~dwarfsoft/
Check out our NPC AI Mailing List :
http://www.egroups.com/group/NPCAI/
made due to popular demand here at GDNet :)
Yeah, Neural Nets are complicated. (I''m in the same boat as you there, dwarfsoft...) I don''t know how to make one learn.

Anyway, How would a NPC know that he/she shouldn''t eat poison? The initial common sense that each of them start out with in their memory tree. But, if they don''t KNOW something is poison... That''s the beauty of it. IF they know that a certain food is eatible, and they see another person die from eating that food, then they would suspect something and not eat it.
As long as an NPC doesn''t suspect it''s poison, they would assume it''s water, or juice, etc...

About just tasting it and just becoming ill, that sort of thing depends on the game, not just the AI or the NPC.

hmmm...disgusting. how would an NPC determine that fungus is disgusting... I guess it would be a learned behavior, that some icky slimy thing is disgusting. but how to represent disgusting in the memory tree, without pre-coding for it extensively.

btw, dwarfsoft are you asking to see my database? Well, at the moment the layout is in a giant notebook. (no, not a computer notebook...) But basically, there are a limited number of commands in the game, each can be represented by a number and held in a database as a flag. Something along the lines of:

object Apple
{
Desc=Apple
Graphic=.\graphic\food\fruit\apple\
Command=CMD_GET | CMD_DROP | CMD_THROW | CMD_EAT
SVT=.\savethrow\food\fruit\apple.svt
Attrib=.\attrib\food\fruit\apple.atb
} ;Apple''s eating data is in attributes file
object EFPurse
{
Desc=Ever-full Purse
Graphic=.\graphic\acc\purse\
Command=CMD_OPEN | CMD_CLOSE | CMD_GET | CMD_DROP | CMD_THROW
SVT=.\savethrow\acc\purse.svt
Attrib=.\attrib\acc\EFpurse.atb
} ; EFPurse looks and saves just like a purse, but
; your money doubles overnight... >:->

Bear in mind that that is the pre-pre-pre-alpha prototype version. I''ll start a post when I finish it somewhat... I havent coded any AIs using my newer theories... Only this old one that I got frustrated with...I think I deleted it. I was doing scripting with that one.
OOOH, this post got long....!
Yay! More talk about Neural Nets! Time for another huge post! (j/k, if you want to see it, look at me first post in the Artificial Intuition thread)

Well, my name has been called, and so I answer the summons (or more accurately, this thread is neat and I''m going to contribute, but then I seem less cool). Breaking out my Cognitive Science textbook from last term, there are about a billion ways to do this. Neural Nets are one, yes, but I don''t know of any learning algorithms that are complex enough to do what you want (though I will endeavour to explore).

However, I think a simple rule-based system is enough. If you have a series of rules representing what the NPC knows about the world, then given a goal (see NPCAI mailing list, yes dwarfsoft, I''m one of the lurkers) algorithms can be applied to those rules to decide what the NPC should do. For example, given the rules:

IF eat apple THEN less hungry
IF eat rock THEN get hurt

If the NPC is hungry, it will eat an apple. If it wants to get hurt, it will eat a rock.

You might ask: "But Eric! What if there are two rules that apply to the same situation?" and I''d answer: "You assign weights to each of the rules depending on it''s effectiveness" so consider this:

IF eat apple THEN less hungry (0.5)
IF eat steak THEN less hungry (0.8)

Since the steak is better than the apple, the NPC will eat that. Now what if the NPC doesn''t have a steak. Well then "eat steak" becomes a goal for the NPC, and the following rules apply

IF want eat steak THEN order steak
IF want order steak THEN goto restaurant

assuming that the NPC has lerned about all of this.

I hope that makes sense. And my critics will be glad to know I only mentionned ANNs twice. (Crap! That makes three!)

Eric
==============="Or a pointed stick!"
The only problem egerlach, is that IF...THEN scripting will take LOADS AND LOADS AND LOADS X 1000 of code to make it work well. Whereas in my own system, discussed in "why make scheduling so strict?", If the NPC gets hungry, the Memory tree is searched for any possibilities of getting food and is then narrowed down by the next layers of Logic (what places are close by) and personality (preference of quality and price).

eg: If an NPC working in his armor little shop on main st. and get hungry(instinct layer). He closes shop for a lunch break(possession protection directive) after his memory is consulted for a list of places to eat. There are 2 places close by: The expensive resurant across the street, or a tavern at the end of the street(Memory>Logic). Business has been a bit slow for poor Bob and he goes to the tavern.(Personality>Logical Constraint)

Not only is this method dynamic, but doesn''t require tons of coding either.

This topic is closed to new replies.

Advertisement