• Register
Post news RSS Behavior of occupants in Blood & Bullet

I go through a bit of the current artificial intelligence in Blood & Bullet, implemented with behavior trees. Skip to the end for lots of animations.

Posted by on

Behavior of occupants in Blood & Bullet

There's quite a lot of graphics in this one. Feel free to skip ahead for all the animations.

Since I moved over to Unity I've implemented the artificial intelligence (AI — the code that runs the computer controlled characters) in Blood & Bullet using behavior trees. I feel they are a good match in that they do what I need and they are easy enough to build and maintain. Behavior trees are made up by actions and conditions that can be organized into sequences. When linked together they form a tree structure, and that's where the name comes from I suppose.

This is a rough schematic of the behavior tree that an operator in B&B uses to open a door:

Behavior tree for opening a door


Most recently I've been working on the occupant AI, that is the AI for the opponent characters that reside in the building. Specifically I have worked on its "avoidance mode". An occupant will not simply flee when it is in this mode; it will act in different ways depending on some values stored on its character. I have started simple, so for the time being there are only three such values. Let's call them the behavior values:

Aggression - How likely the character is to resort to violence.
Avoidance - How likely the character is to try to avoid confrontation.
Morale - Determines for how long a character needs to think before taking action. It also decides how likely the character is to surrender.

In the sandbox the behavior values are randomized for each character. The player can set the lower and upper bounds for the randomization before starting a mission.

Behavior values for sandbox mission

The sliders may look a bit confusing now. There are two for each value: one for the lower and one for the upper bound. They will be clearer before I release anything.

The avoidance behavior serves to keep the occupant away from the entry team operators and preferably out of sight. How far it is willing to go to acheive this goal depends on the character's aggression value. When the occupant is forced into action, the aggression value is used to decide what the occupant will do. It is a choice between aggressive and non-aggressive action. For now the morale value is not part of this but I will make it so that the occupant can also decide to surrender in some of these situations.

Below I will go through some of the situations that force the occupants into action and what the possible outcomes are.

Backing away

When the occupant sees the operators, first of all it does not attack on sight when it runs the avoidance mode. It will try to put distance between itself and the operators. It doesn't want to turn its back on them when they are close though, so it starts backing away.

Backing away


Backing through doors

When the occupant goes through an open door while backing away, it will attempt to close the door. When the door is closed it breaks the line of sight and the occupant feels confident enough to turn around and run.

Backing through a door


Being cornered

If on the other hand, the occupant backs into a closed door or any other obstacle it will feel cornered. It will act to get out of this situation. In the animation below, on the top the occupant has a low aggression value and chooses to run toward and then past the operator. This may in turn prompt computer controlled operators into action. The occupant in the animation on the bottom has a high aggression value and chooses to attack.

Becoming cornered


Being overrun

The occupant has a rather similar reaction to that above when an operator advances quickly. Here the operator is first advancing on the occupant by walking speed, and the occupant can maintain the distance while going backwards. But then the operator starts sprinting. The occupant with a low aggression value, again on the top, turns around to run. The one with high aggression decides to engage.

Being overrun


Being shot

A low aggression occupant will try to run away when being shot. If backed against a wall when this happens it will attempt to dash past the operator. A high aggression occupant fires back. The same reaction is also triggered when a nearby ally to the occupant is attacked.

Being shot at


Turning your back

For the same reason the occupants don't want to turn their back toward you if they can avoid it, you shouldn't turn on them either. They will take advantage and either run away or shoot you in the back. Again the aggression value of the occupant governs the outcome.

Turning your back


Stun grenades

Finally they will run away when confronted with live grenades. This is regardless their behavior values.

Confronted with grenade


That's it for this time, thank you for reading. I always appreciate a comment!

Comments
Ardman55
Ardman55

Man this game came so far already. Cant congratulate you enough, thanks for the hard work and I can't wait to play this masterpiece!

Reply Good karma Bad karma+5 votes
isbeorn Author
isbeorn

Thanks for sticking around :D

Reply Good karma+4 votes
stevie231
stevie231

Absolutely incredible Isbeorn!

Reply Good karma Bad karma+1 vote
isbeorn Author
isbeorn

Thank you :)

Reply Good karma+2 votes
Pe†eR-KuN
Pe†eR-KuN

NIce Flow chart there man!

Reply Good karma Bad karma+1 vote
isbeorn Author
isbeorn

Thanks! And now you know how to open a door :D

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

News
Browse
News
New
Post news
Share
Related Games
Crisis Response
Crisis Response Tactical Shooter
Related Engines
Unity
Unity Commercial