Jump to content
  • Advertisement
Sign in to follow this  
Abbacabba

Making autonomous "people"

This topic is 4997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Background: I've been playing Black and White recently, and really enjoyed the aspect of the game where the villages can run themselfs(somewhat) and you can give an overall influance. Where I'm going with it: I would really like to make a game/simulation using the "god" aspect. But I want to have as independant and autonomous "people" as possible. I would greatly enjoy setting up a secton of land, placing a village and just watching it grow. My main issues with a game like B&W is the village has been -in theory- running itself for possibly hundreds of years, then you come along and they can't do a darn thing on their own. I guess this is borderline simulation, the people would need to have a great deal of detail, more so than "the sims" but also be able to interact with the environment, much like B&W. Where I need Help: In the past I've made a simple time schedule for AI's to follow, and offset actions baised on "Personality" and their unique wants/needs. It gave a decent illusion of AI but I *really* want to dig into this and make something that appears to be living and able to take care of itself. What ideas, help or comments do the rest of you offer before I go down this road of designing an AI that might be able to pull this off.?

Share this post


Link to post
Share on other sites
Advertisement
I've been thinking about a similar system, though a little different and more group than individual simulation.

Why do people do things? Mainly because they are compelled to be emotions and instincts. If your AI's get hungry and know to get food when hungry, or sleep when tired then thats a start.

Simple decisions when layered may lead to more complex behaviour.

Share this post


Link to post
Share on other sites
Thats what I had awhile back;

I should clarify my post:

I would like to know what attributes a "person" might have and what those attributes might affect.


My old simulation had a 50x50 grid and was ascii text graphics.

*warning/ bad psudo code to follow*
a "Person" had attributes like:
{
Person_ID;
pos x;
pos y;

people_known[];
food_sources_known[];
shelters_known[];
jobs_known[];

health;
hunger;
energy;
personality[];
}

a person started off knowing nothing, it would wander around the grid until it found something, once it found something it would add it to its known list(Shelter, food, jobs, entertainment)

If two people met they would share information based on personality info.

Some people never found anything and died off.
Some would find food but could not pay for it so they would go find a job, then "work" for a time and go get food, then go find a place to rest.


Sometimes I would load it up and everyone would just die real quick. Sometimes though it really surprised me and I could watch my little ascii people move from jobs to food to shelter. This is what I'm wanting to get to but have a lot more environmental stuff for them to interact with. ALso each AI needs a much more complex internal information set. The problem is I don't really know what direction to really head off in to make this good from the start.


Hope this give alittle more insight.

Share this post


Link to post
Share on other sites
there has been discussion of a virtual village in the game design forum, in fact this seems to be a pet project of technogoth... the ideas discussed are mainly for an RPG-like environment (or maybe tha's my bias?), but there's some good stuff in there.

Share this post


Link to post
Share on other sites
This seems relatively straightforward, but ultimately if you're going to program it all, there will be quite a lot of complex rules.

Depending on how much detail things are modelled in, potentially it can get quite complicated.

Ultimately you're going to need

- Pathfinding
- Some sort of task queueing / distribution system
- A system to handle unexpected events - if an unexpected event (emergency) happens, tasks have to be put on hold and resumed afterwards.

Suppose half your village are working in the fields etc, some are in houses, others are out hunting. If one of the huts catches fire, they should all help put it out.

If Bob happened to be wielding a hoe at the time, an inappropriate implement for extinguishing fires, he should be able to put it down, remember where he put it, grab a bucket and help extinguish the fires.

Then of course, once the emergency is over, bob should be capable of going and getting the hoe back and resuming hoeing duties.

It would be quite a fun project, but I feel that a lot of the low-level nitty gritty would really start to get complicated.

Also debugging errant behaviour would get incredibly awkward. Perhaps you'd need built-in capabilities for the software to "self-heal" - that's to say, if a particular goal was not being achieved by an algorithm, have some sort of alert handler which detects this, and temporarily abandons that algorithm to re-enable it later.

If it's going to run for long periods without any human intervention, it's got to be capable of self-healing in some respects, otherwise small bugs will just cause the entire village to be wiped out within a relatively short time.

A single bug which causes Bob to forget to eat, will eventually wipe out the village.

Mark

Share this post


Link to post
Share on other sites
You might consider reading the article "Varieties of Learning" by Richard Evans. It's in the book AI Game Programming Wisdom. It'll give you some insight into how they did it in Black & White, and that may give you ideas for your own project.

Share this post


Link to post
Share on other sites
What you can have is something like this:

Per character:

Interestsa
Likes
Dislikes
People liked
People disliked

Now from that, you have an evaluation function which returns how good a state is.
A state is a current world state, from the perspective of the character.

What you do, is you store landmark states.

So, when x happened, and y happened (They were the only importaint things that happened that day), and this and that and the other, i liked it x amount.

After that, z happened, then j happened, then a whole lot of other stuff happened. Now i like it x1 amount.

Now, you have causality. This happened, than this other thing has a probability of happening (from my experience) of 13.12412451352873519273%.

When deciding on wether something is good or bad, you look at the things that follow, and you see the most likely events, and use that to change how well you think of your something.

Now what you do, is you find the best state to be in, which is findable from your current state, and you go and do what you have to do to do this. (this is, on average. Sometimes cutting down wood doesn't get you a bottle of milk, but if you want it, then it will happen.)

This i my main idea, of cource there are many other things which you willdo, but this will at least help a bit.

From,
Nice coder

Share this post


Link to post
Share on other sites
Quote:
Original post by Nice Coder
What you can have is something like this:

Per character:

Interestsa
Likes
Dislikes
People liked
People disliked

Now from that, you have an evaluation function which returns how good a state is.
A state is a current world state, from the perspective of the character.

What you do, is you store landmark states.

So, when x happened, and y happened (They were the only importaint things that happened that day), and this and that and the other, i liked it x amount.

After that, z happened, then j happened, then a whole lot of other stuff happened. Now i like it x1 amount.

Now, you have causality. This happened, than this other thing has a probability of happening (from my experience) of 13.12412451352873519273%.

When deciding on wether something is good or bad, you look at the things that follow, and you see the most likely events, and use that to change how well you think of your something.

Now what you do, is you find the best state to be in, which is findable from your current state, and you go and do what you have to do to do this. (this is, on average. Sometimes cutting down wood doesn't get you a bottle of milk, but if you want it, then it will happen.)

This i my main idea, of cource there are many other things which you willdo, but this will at least help a bit.

From,
Nice coder


What you've described is dynamic programming reinforcement learning (henceforth referred to as DP-RL). For trivial problems, DP-RL works great, and there are a bunch of mathematical guarantees that it will do the Right Thing[tm]. However, for any state described by more than a handful of dimensions, DP-RL struggles for a number of reasons.

First, in the implementation you described, the learning agent needs to learn the state transition probabilities and learn expected value rewards for states at the same time. This is generally considered a bad idea, and often won't work. If you don't know the state transition probabilities a priori, it is best to stick to monte carlo RL or temporal difference RL.

Second, the state space grows exponentially as the dimensionality of the state space increases. This means that for any non-trivial problem, you will need to invest a lot of effort into learning how to generalize. This isn't impossible, but it's a huge field and finding a suitable method for your domain will be an important choice.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think it would actually be possible to code something, but for animals, in Basic. Keep it simple, and it works, as it has been proved numerous times. Moreover, since I am completely unable to code or understand anything to C#, I'll just stick to what I know works, Basic.

Let's imagine your basic animal has different needs, five primary needs or desires to be precise: the desire to feed, the desire to sleep, the desire to find shelter, the desire not to die as an individual, and the desire not to die as a species that is, to mate.

Let's imagine now that ALL those desires receive counters that count the passing of time. Each cycle of clock adds a different value to the counters, in order to get the FOOD counter up to limit level faster than the SLEEP level, and the desire to find SHELTER faster than the desire to MATE.

Let's imagine now that the animals come in different types. The first difference is of GENDER nature: Male and Female. In order to ensure the fifth desire, the Mating must happen between two animals of both genders. This value should be implemented in 0 and 1.
The second difference is of BEHAVIORAL nature: the animals are either Herbivorous, or Carnivorous. The difference in code means that the Herbivorous animals don't have the FOOD counter that rises until they happen to be in certain "desertic" zones, which triger the FOOD counter. Each animal has a set value of food, which allows the killer to lower its FOOD counter by each unit it takes out of the animal, exactly like in the "Age of" saga, where animals can be slain and used to gain food.
The third and last difference between animal should be of SOCIAL nature. Some animals are lonesome, whereas some others are social and live in packs (wolves) or hordes (usually Herbivorous). This value, set to either 0 or 1, would determine the behaviour of the animals in relation to others of his own species. The species should be determined by numbers, so as to ensure that a rabbit doesn't mate with a fox. Mating can only happen with another animal of a different gender but of the same species. The social carnivorous animals may be able to tackle with bigger game than solitary or lonesome carnivorous ones, precisely because they hunt in groups. (You don't often see two tigers together, except for mating, whereas you don't often see a wolf alone...)

One last thing is the ability to remember the "combat value" of any given animal specie for any other specie. It could be implemented, still in Basic, as a limit upper value as a trigger for the "engage combat" action. Any lower value than the upper value trigers the combat as well. (if X< trigger then goto xxxx). The "combat value" of any animal is known to the program, but not of the other animals. It may vary from individual to individual, for a random 5%, or 3 or anything, and the "attacking" animal should try to evaluate the "combat value" of opponents before triggering "engage combat". this evaluation should have a wider range than the variation of "combat value" individual to individual, and the level of FOOD should make the higher value vary by a percentage, in order to allow for "hunger craze". After a combat, the actual true "combat value" of the dead animal is updated to the database of the killer, and if the value hapens to be higher than the accepted "upper value trigger", then the value changes. The combat value of the winning animal is updated to the database of the dead animal species as an "upper value flee".

The effect of the "desire not to die as an individual" is that each species have an "upper value flee trigger". If they come in a range from any other animal, they check the "combat value" of the other animal. If that value is higher than the "flee trigger", then they flee, be they carnivorous or herbivorous. If they are carnivorous and the "combat value" of the other animal is under the "flee trigger", then they check their "FOOD trigger". If the FOOD value is above a certain level, they engage combat, i.e. hunt. If not, they continue to roam, in a certain circle around "Shelter point". If "Shelter point" is menaced by anything, then the animals using the point as Shelter now move around the circle, the circle expanding by a certain percentage each set number of clock cylces, in order to find a new suitable "shelter point". When the new shelter point is found, then its location x;y is updated to the group or animal, and the "hunting ground" circle radius is set back to its original value.



So what do you think? Anything like this has any chance of actually working?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I suppose one interesting aspect is that people should be able to refer to others for help (such as bob with the pitchfork or whatever it was should decide to go and see the most medically qualified person he knows because he's just amputated his arm with the forementioned pitchfork - hence you should see bob drop the pitchfork & run to the doctor's/quack's hut/house/cave/cardboard-box)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!