They're Behaving Like Monsters! An Introduction to Stimulus-Based Behavior in Computer Role-Playing Games
Applying the Stimuli
Prior to taking any action, a creature will automatically evaluate its surroundings within a certain radius. Everything it finds will influence the decision-making process. Once everything has been evaluated and the surrounding areas have been identified as safe or unsafe, the creature will act accordingly. Following is a simple example of this decision-making sequence, as influenced by the basic stimuli:
- The creature sees another of its kind, an ally. This sighting gives the creature confidence, increasing its self-perceived combat strength accordingly. The fear stimulus has been lessened. If the creature is a pack hunter, the aggression stimulus might have just been increased as well. As a result, the area between the creature and its ally is marked as "safe."
- The creature next spots someone who is not an ally. Due to the increased confidence of having a buddy nearby, our otherwise passive creature may have just become a bully. At this point, the aggression stimulus (weighted by the creature's self-perceived strength) is compared with the fear stimulus (see the next item).
- We calculate fear toward each non-ally the creature sees. This is based on the creature's estimation of the strength of the potential enemy, modified by distance (closer threats are more serious than remote threats). This is further modified by the number of non-allies, because groups would be considered more dangerous than a single enemy.
- If the creature still feels pretty good about its chances, it may consider attacking. This issue can also be influenced by other specific behaviors, such as an all-consuming hatred of trolls, or superstition (fear of the supernatural, perhaps) or the desire stimulus (see the next item). The area between the creature and the enemy would be marked as "good." On the other hand, if fear outweighs aggression, the creature would mark the same area as "bad." When the time comes to act, the creature will shy away from "bad" areas in favor of those marked as "good" or "safe." In this way, we represent fear as a desire to move away from a dangerous area. Extreme fear could be characterized by a desire to move away quickly, without regard for all other stimuli.
- The creature spots something that triggers the desire stimulus. The potential enemy has something that our creature wants, such as gold or food. We factor in the perceived value of the item(s). If the creature is hungry enough, we could consider the nutritional value of the prospective enemy's corpse. Objects on the ground should be calculated in the same way, with the proximity to "good" and "bad" areas taken into account. This consideration affects the creature's desire to move or act in a particular direction.
- The creature sees something that triggers its specific behaviors (as described earlier). In this case, we factor in the specific behavior. Examples might include staying close to an altar, a villager approaching a visiting hero, an archer making use of range and cover, etc.
- When the creature doesn't need to contend with any obvious threats or desires, boredom comes into play. The primary purpose of this stimulus is to make the creature a little less predictable.
- Finally, loyalty is a condition that would normally outweigh all other stimuli. That doesn't mean "completely ignore," however. If a stimulus is strong enough (such as fear or desire), or creature may disobey an order. The resulting behavior also depends on the strength of the order: Is it magical control? Is the creature afraid of its master? Is the creature within sight of its master? Is the creature surrounded by allies, and are they following the same order? All of these factors must be considered.
Compare all the stimuli, specific behaviors, and terrain values (bad/safe/good), and your creatures can easily determine a movement direction or action. Knowing which of the stimuli is the strongest will influence what the creature does once it actually reaches its destination.