Creature Behavior

Started by
11 comments, last by AoS 12 years, 3 months ago
Okay so my game is mainly focused on PvE currently. I have developed an idea for how I want the creatures to behave to provide the proper PvE experience.
Creatures have a few standard behaviors regarding interacting with players. For standard PvE with wandering creatures monsters have a pretty standard aggro system. I am pretty sure I can handle that. What I am looking for advice on is the more complex system where creatures form into groups and launch raids on player settlements.

The basic building blocks of the system are here:
Creatures select locations for their lair. Each creature has a desired terrain type and a random chance to pick any square with that terrain as home. Social creatures are more likely to pick squares where there are creatures of the same type.
Lairs have a sort of level system. Beyond certain population blocks creatures have a random chance to level the settlement every time a new creatures joins or is born.
Individual or very small groups, 2-10, of creatures who are within a certain number of squares of a much larger settlement have a small chance every certain time period to move to that settlement.
Lairs have a certain area of operation centered around the lair. The size of the lair determines the area of operation. It also determines possible creature actions. Larger lairs have a larger area of operations and more actions.
Small lairs may only have sentries while large lairs will have patrols and scouts. The function of the scout is to search for human settlements. Larger settlements have more scouts with longer search ranges. Scouts sentries and patrols increase as the lair population increases. New actions are gained with larger sizes.
Raids begin to happen around 100 or more creatures. They in size and frequency as the lair grows. Raids can only happen if the lair has a creature who located a human settlement. As time goes by and raids don't happen a larger percentage of creatures will be sent out on scout missions.
Lairs at 500 population will start the seeding cycle. They will send out colony groups of 100 which will travel as a group and follow the standard lair algorithm. Sometimes creatures will come into the game as a large group on a colony mission, but generally they come alone.
Lairs with creatures of similar types are capable of forming social links. Generally any group of creatures of the same type with overlapping areas of operation have a chance every cycle to form social bonds. Groups which have a creature who has met a creature of the same type from another lair have a much smaller chance of bonding.
Socially bonded groups have an increased breeding rate depending on the level of the link. Higher links also allow for other actions. Each level of bonding has a smaller random chance of happening. Some actions of higher bonds are information sharing. Any human settlement location discovered by a group with social bonds will be spread across those bonds. Further, the groups who get the info through bonds will spread it through their own bonds with other groups. Groups with more than one secondary bond with another group have a small chance to bond with that group.
Groups with a bond over a certain strength will have a mutual defense pact whereby based on the strength of the bond they will send reinforcements to the territory of any invaded group. At very high levels groups will form kingdoms with the lair with the highest connection to all the member groups as the hub. Kingdoms will move beyond information sharing and mutual defense to become a single integrated unit. They will have higher birthrates even than groups with social linkages. Although lairs will still have their own sentries and patrols on borders that don't touch borders of other lairs in the kingdom, they will have a unified sentry and patrol system as well as garrisons. Areas of operation work in circles and groups who have no or minimal exposed borders will send their troops to the borders of the kingdom. Raids will be launched by the kingdom as larger groups. Kingdoms will send troops to any border penetration event as well to aid lairs in danger. The amount of assistance will be much larger than with mutual defense pacts.
Kingdoms and individual lairs and even groups of lairs can be connected to much larger networks by social linkage. Any creature group can be a part of this type of alliance with other groups of any size.
There is another type of creature society which is based on coercion. This is called an aura of authority. Very powerful individual creatures can posses these auras and anything within the aura radius belongs to those creatures. This aura supersedes a creatures type, so auraed creatures cannot bond socially with unauraed ones individually. Their leader must decide to accept any sort of agreement. Generally they will only ally with other aura based societies because equal auras create a stopping force. They cannot supercede one another. However they can take over non auraed societies.
Kingdoms have a special aura affect whereby if a group possesses significantly high level social bonds with many other groups the aura effect will not be able to affect lairs within that kingdoms area of operations. The higher the power of the AoA the more concrete resistors social bonds must be. Kingdoms gain power for their kingdom aura based on the population and age of the kingdom.
Colonies sent from social groups begin with a certain level of social connection to those groups. If their borders do not touch the borders of the kingdom they will not possess kingdom immunity to auras.
There are two types of auras. One type merely creates a kingdom like system, while the second type draws its victims slowly towards the center of the aura, the lair of the aura's originator. I may have forgotten to mention, creatures of different types will not settle within a certain distance of each other. All creatures assume a default type within an aura of authority and work together as if they were actually one group. By moving creatures closer this type of aura focuses the defenses and allows unsuspecting creatures to move into the territory and be taken over.
Auras have levels of power. Individual auras are more powerful the closer they are to the center. This affect only happens in regards to the collision of auras. Thus the farther an aura pushes into a territory the harder it is to push farther. Auras of higher levels of power can push through another aura based on the distance to the center for the weaker aura. Creatures that are dispatched on a raid retain their level of control based on their lairs position within an aura.

I was wondering if people had suggestions or changes for the system. There may be problems I haven't anticipated. Also any advice on the coding would help.
I was thinking that the code would be relatively simple, all that would happen is that a few integers would need to be compared for behaviors and interactions and some other integers in a database could indicated which aura or kingdom or lair a creature was part of an so forth. Also, creatures would have a list of locations of human lairs and these would be exchanged in the circumstances described above by simply adding new entries to a creatures list when their group gained that knowledge. However the knowledge would only be exchanged if the creature was in contact range with another of its group and would be passed to the group only when they entered the border of the society.
This would allow players to attempt to kill creatures prior to their getting intel back to their group and prevent the enemy from location them for raids.
Advertisement
Hmmm.. as stated in your other thread about this topic, I've tried a similar approach. I want to give you one advice and a thought.

The advice is to prototype your system first, this is the only way to get a feeling if and how it will work. Everything else will result in an endless discussion loop and refactoring if you rush into development of a complex system too early.

The thought is, that many game population simulations are based on really simple rule sets and that the behavior is a result of emergent events.
Seconding Ashaman73's advice, the whole "social" system of bonds between creatures and auras of influence and kingdoms seems not very visible to the player (who's simply going to meet more and better monster war parties in certain places: the difference is hard to notice, and highly constrained by difficulty concerns) and complex and prone to malfunction (for example, what happens to game difficulty when a large and more powerful organization coalesces or not randomly, depending on minute differences in settlement location or movements of an individual monster?).

Predefined factions of friendly monsters of various races that automatically live together and work together are a more natural and meaningful system: you can place, say, "goblins" and "human outlaws" at distant seeding points on the map, spawn appropriate monsters of different races and classes (stunted mutants, average warriors, giant hobgoblins, goblin children; archers, thieves, rare wizards and other character classes respectively), and simulate their colonization effort and the formation of a frontier between the respective territories until you reach a steady state (ready to be wrecked by the player).
Patrols and scouts, colonization, knowledge of player locations and raid organization could be managed globally by each faction, treating "lairs" only as an hint (for example, to build towns with a defense perimeter and certain buildings in the middle).

Omae Wa Mou Shindeiru

Adding on to what AshMan said,

Prototyping is definitely the way to go with this system. Don't go into detail with characters and all that, rather make colored cubes to represent the mobs and so on. Then prototype your system.

Afford way to think of it before you start is "How can I do this simply?" Then simplify it some more.

For example, take your idea of having the mobs create colonies. Instead of having the code decide on locations at runtime, have preseignated objects as waypoints that are acceptable for the mobs to colonize.

More things you can do to simplify. If you have questions, take this over to the AI forums.

I recommend Unity for this particular prototype.
Morley

Aspiring programmer, modeler and game designer.
Okay. I was planning to prototype it, and as you said just a colored square. I didn't even set up stats, just the columns for relationships.

I do not want to predefine locations and factions. That would be the whole point of a complex system to do it without my interference. Social links aren't really intended for the player per say. I might put some sort of flag system on the creatures so that players can see what groups are connected.

I would actually like to see large factions coalesce more or less randomly. The system should be able to conquer and destroy some player settlements. Whether or not the playes get smashed is somewhat dependent on them. If they organize properly they should win, with maybe a few losses of player towns. There is a circumstance where a whole world could be overrun by monsters, but there will be a lot of wiggle room for players.

I actually did get unity to try and test the structure, but my computer cannot handle a sufficiently large landmass on unity to do the test. I am running a test using php and mysql because it can handle the size more easily. It has all the necessary capabilities to do test for how the monster systems increase in complexity.

I guess if a mod checks this maybe move it to AI, I wasn't sure if it would be better there or here.
No, you were right to start here. Once the idea is roughed out, represent to the AI board and reference to this post.

I really do like the free roaming system, but do bear in mind the scale of this.

What I mean is, you are talking about controlling individual objects, each representing a single mob. And you are multiplying them by 100 or more. As is, many PC's could not handle that much. Most games get their AI working by "putting them to sleep" or Pausig/Breaking a loop if they are not seen or near the player to save cycles.

One solution is to control them as a group rather than individually.

Also, if you plan to make this multiplayer, then you most likely WILL have to strip it to the bones, because most servers are Authoritative in that they are in charge of making sure actions are legal, then calculating damage and so on...

Just some thoughts :)
Morley

Aspiring programmer, modeler and game designer.
Hmm. I figured with a good server and some pretty simply graphics having a lot of objects wouldn't be an issue. I dunno, I am not super big on hardware limitations.
The way most multiplayer games work is that the server handles figuring out where everything is, what things can and can't do and sending this information out several times a second. And when you have non player units moving around, that entirely falls upon the server.

So the client (the players) are responsible for initiating handshakes, asking the server to move and do things and render the game that the player sees.

So, if done right, you could support the scale of this game, but you may find you have to edit how the game is rendered so that only what the camera see's gets rendered (Unreal Engine does this).

The main issue is, like I've said, supporting the real time tasks of handling all the individual NPCs at once. Even MMO's don't handle each group individually, but more like trees.

For example, you have your colony, with subgroups of patrols and then the subunits of each group. So it may look like:

-Colony 1
-Group1
-Unit1
-Unit2
-Unit3
-Group2
-Unit1
-Unit2
Colony 2
-Group1
-Group2

Etc.

In my current position, we call this a control hierarchy. Only the low level (Unit) actions are called upon when they are rendered or a player comes close or when they are needed. Otherwise, we lighten the load by calling the highest level of the hierarchy we could get away with.

Hope that clarifies!
Morley

Aspiring programmer, modeler and game designer.
Well, the interactions could probably function without being fully rendered, after all they are interacting based on the database values and not visually. They don't need terrain either. We could just make them tiny cubes or maybe even not deal with them as anything but numbers in the code.
Here's a few things I'm wondering about.


Creatures select locations for their lair. Each creature has a desired terrain type and a random chance to pick any square with that terrain as home.

Are you speaking of where creatures will spawn, or where they will move? The latter sounds hardware expensive, but the AI we see in new MMO's (Rift, SWTOR) ain't exactly pushing it. Having fewer creatures would make it more viable.


Social creatures are more likely to pick squares where there are creatures of the same type.
Lairs have a sort of level system. Beyond certain population blocks creatures have a random chance to level the settlement every time a new creatures joins or is born.
Individual or very small groups, 2-10, of creatures who are within a certain number of squares of a much larger settlement have a small chance every certain time period to move to that settlement.

How will you prevent extreme concentrations? They gradually flock to a few tiles, just like mass is concentrated in giant spheres. It's something that needs to be considered. There can be many solutions to this problem, like attractiveness goes up to a top, and then degrades if the "settlement" gets to big.


Lairs have a certain area of operation centered around the lair. The size of the lair determines the area of operation. It also determines possible creature actions. Larger lairs have a larger area of operations and more actions.
Small lairs may only have sentries while large lairs will have patrols and scouts. The function of the scout is to search for human settlements. Larger settlements have more scouts with longer search ranges. Scouts sentries and patrols increase as the lair population increases. New actions are gained with larger sizes.
Raids begin to happen around 100 or more creatures. They in size and frequency as the lair grows. Raids can only happen if the lair has a creature who located a human settlement. As time goes by and raids don't happen a larger percentage of creatures will be sent out on scout missions.
Lairs at 500 population will start the seeding cycle. They will send out colony groups of 100 which will travel as a group and follow the standard lair algorithm. Sometimes creatures will come into the game as a large group on a colony mission, but generally they come alone.
Lairs with creatures of similar types are capable of forming social links. Generally any group of creatures of the same type with overlapping areas of operation have a chance every cycle to form social bonds. Groups which have a creature who has met a creature of the same type from another lair have a much smaller chance of bonding.
Socially bonded groups have an increased breeding rate depending on the level of the link. Higher links also allow for other actions. Each level of bonding has a smaller random chance of happening. Some actions of higher bonds are information sharing. Any human settlement location discovered by a group with social bonds will be spread across those bonds. Further, the groups who get the info through bonds will spread it through their own bonds with other groups. Groups with more than one secondary bond with another group have a small chance to bond with that group.
Groups with a bond over a certain strength will have a mutual defense pact whereby based on the strength of the bond they will send reinforcements to the territory of any invaded group. At very high levels groups will form kingdoms with the lair with the highest connection to all the member groups as the hub. Kingdoms will move beyond information sharing and mutual defense to become a single integrated unit. They will have higher birthrates even than groups with social linkages. Although lairs will still have their own sentries and patrols on borders that don't touch borders of other lairs in the kingdom, they will have a unified sentry and patrol system as well as garrisons. Areas of operation work in circles and groups who have no or minimal exposed borders will send their troops to the borders of the kingdom. Raids will be launched by the kingdom as larger groups. Kingdoms will send troops to any border penetration event as well to aid lairs in danger. The amount of assistance will be much larger than with mutual defense pacts.
Kingdoms and individual lairs and even groups of lairs can be connected to much larger networks by social linkage. Any creature group can be a part of this type of alliance with other groups of any size.

So, you meant to have very small groups involved in social bonding (2-10)? It may be better to keep this for the slightly larger groups, to reduce complexity of bonding.
Are you preventing settlements to be placed near one another? If not, how are you gonna make sure their area of operation doesn't overlap.
What are border events, and where is it possible that they take place? Sounds like you want a kingdom with a geographical area (no other lairs within). How wiill you implement this? Will you allow lone colonies far away? This needs to be taken into consideration when defining the border.


Also, creatures would have a list of locations of human lairs and these would be exchanged in the circumstances described above by simply adding new entries to a creatures list when their group gained that knowledge. However the knowledge would only be exchanged if the creature was in contact range with another of its group and would be passed to the group only when they entered the border of the society.
This would allow players to attempt to kill creatures prior to their getting intel back to their group and prevent the enemy from location them for raids.

Will every creature have a list of every human settlement it knows about, or just the settlements it's seen itself. In the first case, that's quite demanding. There's lots of creatures, and each will remember every human location. If individuals only remember thing's they've seen themself, which might be erased after sharing this with their group, then you reduce the problem, but it might still be to complex if you allow this with the very small groups.

I am somewhat skeptical about this. I believe it can easily be unstable, difficult to balance. It will require quite a bit of extra power, yet the players may see little of it. I think you could accomplish something similar with a more manageable system. If you want to have a deep complex dynamic system, I'd want to actually make it visual to the players in some way.

This topic is closed to new replies.

Advertisement