Sign in to follow this  
  • entries
    90
  • comments
    66
  • views
    72513

Creating a Sensory Input-Based Monster AI

Sign in to follow this  
Tesseract

100 views

(copied over from my personal blog)

As a thought experiment I am putting together a generic artificial intelligence which I can use for bad guys/NPCs in a variety of different games. There are myriad paths I could follow in creating AI, so for right now I am going to concentrate on two inter-related tasks: awareness and morale. In other words, when does X become aware of another entity, and what does X do in response to that awareness?

For the purposes of this essay there will be two entities: a deer and a wolf. I will discuss the reactions of the deer.

The first step is to create a triggering event. In this case, proximity. Using whatever senses are available to it, somehow, at some point as the wolf approaches, the deer becomes aware of it. This could be something like a twig snapping, or movement in shadows, or wolf-smell on the wind. In any case, the first level of this system is Awareness.

Once the deer is aware that Something is out there, the next step is to determine what that thing is. It could be another deer, or a faun, or a human, or the wolf. Without making that determination the deer cannot react appropriately. It might run in terror from the faun, or stand still while the wolf attacks. So the second level of the system is Recognition.

Once the approaching entity is recognized, the deer can take the appropriate action; in this case, run in terror from the wolf. Or if the deer is protecting a faun, move to attack/distract the wolf while the faun flees. This level of the system is Reaction.

So: Awareness to Recognition to Reaction. Think of them as concentric rings centered on the deer. As the wolf enters these rings its proximity triggers different responses. These distances can be displayed as a sequence of numbers; for instance [20/10/5]. [Awareness/Recognition/Reaction].

Awareness will always be the largest number. Without being aware of something, the deer cannot either recognize or react to it.

Either recognition or reaction may be the next largest number, or they may be equal. In any case, neither of them may be larger than the Awareness number, although they may be equal to it.

So: [10/5/10] would be a "legal" description, but [5/10/5] would not.

Using this system a wide variety of behaviors may be put into place with little effort. The following are some examples:

[10/5/2] - Long-range awareness, medium-range recognition, short-range reaction. A semi-tame, slow-moving, not-too-bright animal. A farm cow, for instance. Knows you are there, knows who you are, doesn't much care.

[10/5/10] - Long-range awareness and reaction, medium-range recognition. Guards at a gate. Something is out there, so immediately set out after it. Once they are close, it may be recognized and perhaps another action performed.

[10/5/1] - Long-range awareness, medium-range recognition, extremely short-range reaction. A bored, disaffected clerk at a store. Knows you are there, knows who/what you are, doesn't do anything until you actually poke him in the shoulder.

[10/1/10] - Long-range awareness and reaction threshold, contact-range recognition. A rhinoceros during mating season, which charges anything it detects, and only stops when it recognizes "Ooh! That's a train!", or something of the like at extremely short range. Basically this is an unthinking reaction to the presence of another entity.

It occurs to me that this could be made less "broad" and more "deep" by changing to a two-level "awareness/reaction" and "recognition/reaction" system. For the purpose of simple- to medium-complexity games I like the three-level approach. In particular playing around with the distance between "recognition" and "reaction", allowing for simulating different levels of intelligence or bravery, and startle-reactions, such as an enemy suddenly appearing well within the "reaction" threshold, causing a panic reaction; or a particularly slow-witted (think "drunk") critter standing around gob-smacked while being charged by a bull.

Note that this AI system is for an "initial contact" situation, where another entity is first entering into awareness range, or has been outside of awareness range long enough that the "deer" has forgotten the entity was there. Reactions when actually interacting with another entity will be discussed in an upcoming essay.
Sign in to follow this  


1 Comment


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now