Advertisement

Modelling human behaviour

Started by February 22, 2013 09:21 PM
11 comments, last by wodinoneeye 11 years, 8 months ago

Hello,

I am trying to model simple human behaviour. In a way I am trying to do a sim person.

I have a series of internal variables:

Fatigue level

Nutrition level

Hydration level.

Every simulated minute results in the variables changing based on the current action.

When the variables get to a certain threshold they trigger a motivation, When there are more than 1 motivations present the highest value motivation rules and the sim person performs the required action.

e.g. Nutrition leads to a Hunger motivation which leads to an eat action.

I am reducing the nutrition value by an amount in order to make the sim eat every 7 hours. When he does eat he takes 20 minutes and that restores him to full nutrition level. The nutrition level goes down by a lower amount when the sim is sleeping. This is timed so that when he wakes up from 8 hours of sleep he has 0 fatigue but needs to eat straight away.

Does this sound like an appropriate approach or has anyone any other ideas?

My fear is that it will all come a bit contrived when I add other variables, motivations and actions and I will have to tweak the existing ones to make them reflect "normality".

Any ideas or thoughts gratefully received.

The foundations you're working on are a pretty standard approach to this sort of thing (utility theory is the general category you're working with).

You are correct that it can become complex quickly when you add more variables to the mix; the "art" of designing a simulation like this is to identify the most critical factors you want to simulate so you can focus on them without being distracted by superfluous features.

There's been a lot of good work done on mitigating that complexity, though. I'm sure Dave Mark will be by shortly with a laundry list of great recommendations for where to research next :-)

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Advertisement

I have googled a bit but trying to find something concrete is not so easy. Are there any sites you can point me to?

Thanks for the reply. At least I know now that i am sort of on the right lines.

Funny you should ask. GDC just made both of my AI Summit lectures on utility theory (from 2010 and 2012) available for free on the GDC Vault. They are both an hour each. (Co-speaker is Kevin Dill, by the way.)

http://intrinsicalgorithm.com/IAonAI/2013/02/both-my-gdc-lectures-on-utility-theory-free-on-gdc-vault/

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

There's been a lot of good work done on mitigating that complexity, though. I'm sure Dave Mark will be by shortly with a laundry list of great recommendations for where to research next :-)

I am amused by this.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

There's been a lot of good work done on mitigating that complexity, though. I'm sure Dave Mark will be by shortly with a laundry list of great recommendations for where to research next :-)

I am amused by this.

Would this be categorized as Expected Utility Theory?

Advertisement

Hello,

I am trying to model simple human behaviour. In a way I am trying to do a sim person.

I have a series of internal variables:

Fatigue level

Nutrition level

Hydration level.

Every simulated minute results in the variables changing based on the current action.

When the variables get to a certain threshold they trigger a motivation, When there are more than 1 motivations present the highest value motivation rules and the sim person performs the required action.

e.g. Nutrition leads to a Hunger motivation which leads to an eat action.

I am reducing the nutrition value by an amount in order to make the sim eat every 7 hours. When he does eat he takes 20 minutes and that restores him to full nutrition level. The nutrition level goes down by a lower amount when the sim is sleeping. This is timed so that when he wakes up from 8 hours of sleep he has 0 fatigue but needs to eat straight away.

Does this sound like an appropriate approach or has anyone any other ideas?

My fear is that it will all come a bit contrived when I add other variables, motivations and actions and I will have to tweak the existing ones to make them reflect "normality".

Any ideas or thoughts gratefully received.

I would actually rethink this a little. Motivations should be recomputed at the end of any action instead of trying to queue them up. I say this as someone who works on sim games a lot and also loves that style of game but hate when it is done badly. A rule of thumb with any AI is that you want it to look kinda smart but never totally stupid. If you simply queue up actions it is very likely that you will end up with stupid sims to the point of annoying the player. I have a good example of this in terms of a game I tried out recently: "Towns". It's a very fun game initially for a sim game, but it quickly becomes an exercise in frustration due to stupidity in the sims.

Anyway, basically, your "internal" variables are the only ones that matter and "motivations" should not be separated or any variations would be based on them. I.e. Hydrated = 10%, well that sim next time it makes a decision on what to do should be go get a drink 90% of the time. And in the case that it is a hit zero and die sort of thing, it should be near 100% that it will do that. If you queue up motivations though, intelligent reaction becomes problematic as the time to perform queued action might be longer than the obvious "I'm going to die if I don't drink" type of thing.

Motivations are basically inverses of your variables. You don't want to queue actions unless you check each motivation during the action. Let's say cooking dinner takes 30 seconds player time and is about 1 hour simulation time. All of the player variables will change over that time, if nutrition or hydration drop below zero, you kill the sim. This is bad.. So, you want to weight your actions against the basic attributes, going to die of hunger before you can make dinner, make a snack instead at lower time cost but a benefit to the nutrition level. If the balance is correct, after making the snack the sim makes "dinner" and fully refills the nutrition need.

You can play all sorts of design games at this point. But the key is to not be so stupid as to die.

Hello,

I am trying to model simple human behaviour. In a way I am trying to do a sim person.

I have a series of internal variables:

Fatigue level

Nutrition level

Hydration level.

Every simulated minute results in the variables changing based on the current action.

When the variables get to a certain threshold they trigger a motivation, When there are more than 1 motivations present the highest value motivation rules and the sim person performs the required action.

e.g. Nutrition leads to a Hunger motivation which leads to an eat action.

I am reducing the nutrition value by an amount in order to make the sim eat every 7 hours. When he does eat he takes 20 minutes and that restores him to full nutrition level. The nutrition level goes down by a lower amount when the sim is sleeping. This is timed so that when he wakes up from 8 hours of sleep he has 0 fatigue but needs to eat straight away.

Does this sound like an appropriate approach or has anyone any other ideas?

My fear is that it will all come a bit contrived when I add other variables, motivations and actions and I will have to tweak the existing ones to make them reflect "normality".

Any ideas or thoughts gratefully received.

I would actually rethink this a little. Motivations should be recomputed at the end of any action instead of trying to queue them up. I say this as someone who works on sim games a lot and also loves that style of game but hate when it is done badly. A rule of thumb with any AI is that you want it to look kinda smart but never totally stupid. If you simply queue up actions it is very likely that you will end up with stupid sims to the point of annoying the player. I have a good example of this in terms of a game I tried out recently: "Towns". It's a very fun game initially for a sim game, but it quickly becomes an exercise in frustration due to stupidity in the sims.

Anyway, basically, your "internal" variables are the only ones that matter and "motivations" should not be separated or any variations would be based on them. I.e. Hydrated = 10%, well that sim next time it makes a decision on what to do should be go get a drink 90% of the time. And in the case that it is a hit zero and die sort of thing, it should be near 100% that it will do that. If you queue up motivations though, intelligent reaction becomes problematic as the time to perform queued action might be longer than the obvious "I'm going to die if I don't drink" type of thing.

Motivations are basically inverses of your variables. You don't want to queue actions unless you check each motivation during the action. Let's say cooking dinner takes 30 seconds player time and is about 1 hour simulation time. All of the player variables will change over that time, if nutrition or hydration drop below zero, you kill the sim. This is bad.. So, you want to weight your actions against the basic attributes, going to die of hunger before you can make dinner, make a snack instead at lower time cost but a benefit to the nutrition level. If the balance is correct, after making the snack the sim makes "dinner" and fully refills the nutrition need.

You can play all sorts of design games at this point. But the key is to not be so stupid as to die.

Hi Thanks for the reply

I would actually rethink this a little. Motivations should be recomputed at the end of any action instead of trying to queue them up. I say this as someone who works on sim games a lot and also loves that style of game but hate when it is done badly. A rule of thumb with any AI is that you want it to look kinda smart but never totally stupid. If you simply queue up actions it is very likely that you will end up with stupid sims to the point of annoying the player. I have a good example of this in terms of a game I tried out recently: "Towns". It's a very fun game initially for a sim game, but it quickly becomes an exercise in frustration due to stupidity in the sims.

What I am doing for the moment cycles through all the internal variables of mý sim: Based on the current action the variables are changed. As a result of this each variable has the chance to propose a motivation. Once all variables have been processed there will be a list of motivations. Depending upon the weighted motivations an action is selected. So actions are not queued up and there may even be compromise actions such as "eat" and "drink" (which is normal) at the same time.

Motivations are basically inverses of your variables. You don't want to queue actions unless you check each motivation during the action. Let's say cooking dinner takes 30 seconds player time and is about 1 hour simulation time. All of the player variables will change over that time, if nutrition or hydration drop below zero, you kill the sim. This is bad.. So, you want to weight your actions against the basic attributes, going to die of hunger before you can make dinner, make a
snack instead at lower time cost but a benefit to the nutrition level. If the balance is correct, after making the snack the sim makes "dinner" and fully refills the nutrition need.

My current problem is conceptual I think. We normally eat at say 6am, 1pm and 8 pm. We normally sleep from 10pm to 6am. So should my motivations be time based or internal variable based?

If I base it on time and the sim does something that makes him hungry (a burst of energy usage like running) then I think I should be time based nd say as it is outside the normal time for a meal I will have a small snack.

If the time is approaching 10pm and the sim is not below the tired threshold should he sleep anyway as if he does not then he will not have recovered enough by the following morning 6am.

What I am trying to do is keep the motivations loose so that the sim does not get "out of synch" but not be so scripted that he eats his main meal 10 minutes after he snacks !

I am leaning towards having an internal variable which when it becomes the highest motivator will propose an action based upon time ... snack or meal, nap or sleep.

When I get conceptually stuck I sort of have to think "how would it be for me?" If I go to bed late I still have to get up at 6am (tired) to go to work so I will go to bed erly the next night to recover.

I will then have to feed in external variables like the noisy neighbour shooting his cat at 3am which will wake the sim up (interrupt the sleep action) increases his anger emotion so that he cant get back to sleep for 2hours and wakes up thoroughly exhausted!!

I will give it another go until I am happy with just a few basic variables.

Ultimately I want my sim to go shopping when he runs out of food, go get a job when he runs out of money, live in a town which has an economy based on the sims working in different jobs as producers and consumers.

Funny you should ask. GDC just made both of my AI Summit lectures on utility theory (from 2010 and 2012) available for free on the GDC Vault. They are both an hour each. (Co-speaker is Kevin Dill, by the way.)

http://intrinsicalgorithm.com/IAonAI/2013/02/both-my-gdc-lectures-on-utility-theory-free-on-gdc-vault/

You're site is behaving weirdly... If I click that link, I get a 404, but when I click through your site (I click the IAonAI-link on the 404-page), I find it, and end up at the same url, that now suddenly works!

have both the 404 page and the normal one open in separate tabs here, and I can't find any difference at all on the URLs...

Edit: Ok, I tried it several times while writing this post, with the same result, but now the link works for me after posting....

Does this sound like an appropriate approach or has anyone any other ideas?

My current project is a caveman simulator. Sort of a cross between the people simulation in The SIMs, role-playing like Oblivion, and realistic simulation like a flight simulator.

I track:

food

water

sleep

mood

hp

damage

has_disease

hygiene

social

fatigue

intoxication

NPC relations

God relations

fatigue goes down at a rate of 1.05% per second

water goes down 1% every 10 minutes

food goes down 1% every 15 minutes. + 1% per hour in cold weather (increased calories required to maintain body temp).

sleep goes down 1% every 10 minutes

mood is affected every 15 minutes by food, hygiene, water, encumbrance, disease, social, rain, heat, and cold.

hygiene is reduce by 1% every 7 minutes if active, by 2% if running, and by 1% every hour if active.

NPCs heal at a rate of 1:5000 chance per minute to heal 1 point of damage. An average NPC has about 12 hit points.

NPC and God relations move towards zero at 1% per day.

sleep recharges at 1% every 2.77777 minutes. this is affected by quality of bedding, and weather (if sleeping outdoors).

it takes 9 seconds to eat one unit of a given type of food. the amount of food boost you get depends on the food eaten. from a low of 1 for fruit juice, to a high of 15 for meat and veggie stew.

drinking one unit of fluid requires 2.66666 seconds. the chance to get a water boost of 1% is a function of the quality of the water (100% quality = 100% chance). you also get a food boost from drinking things like fruit juice.

I don't try to sync the player to the game clock. just like real life, if you don't go to bed and get up at regular hours, you'll find yourself living on the timezone of someplace you're not.

mostly, i make it so they go down at a correct rate for death. IE water goes down at a rate which makes them die of dehydration in the same amount of time as they would in real life (about 3 days). and it takes about 3 weeks to starve, etc.

in the end, all you can do is make a first best guesstimate of what the rates should be, then test and tweak til things seem ok.

as for "freewill" AI to undertake actions based on these:

In the previous version of the game, I used an expert system that would go down a checklist of prioritized needs. water first, cause that's the fastest way to die, then food, etc. I got it all the way up to where they would explore the world, find resources, gather resources, and use the resources to manufacture weapons and equipment. at that point i decided that "free will" was programming the computer to play the game for you, and decided not to implement it at all. Instead, the checklist was used as the basis for the interactive tutorial, advising the player as to what they ought to do next, based on the current state of the world simulation. it would guide you from a new character with nothing to the point where you had food, water, shelter, resources, had made a weapon, and had all the skills to do these things.

Every simulated minute results in the variables changing based on the current action.

timewise, i model things in periods of 66 milliseconds, not one minute. for my game engine, this is analogous to using a frame as the unit of time in a shooter title running at 30 fps.

My fear is that it will all come a bit contrived when I add other variables, motivations and actions and I will have to tweak the existing ones to make them reflect "normality"

if you're shooting for realism in your simulation, there will be no substitute for testing and tweaking. try to come up with a good model or formula or set of rules based on reality first. then put in your best estimate of what the rates of increase and decrease should be. and then you have to dial it in, to balance it.

it can be done. i have 6 core stats, 14 variable stats, over 200 objects, 10 types of environments, 50 skills, 75 types of animals, and over 1000 actions implemented by 100 separate action handlers. and everything affects everything. 13 months into the project, and i still tweak stuff. with each tweak, it becomes more realistic. come up with a good model, put in realistic numbers, test and tweak.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement