Decision Based AI

Ladies and gentlemen,

I’m currently exploring Unity (free), and it’s possibilities compared to the UDK (Unreal Dev Kit).

I breaking my head over this issue (since most modern games utilize this type: decision based AI)
And it’s a must for my project… So if this is possible in Unity (hopefully with not much headaches), i might switch to unity for this project.

What is Decision based AI?
simply put… a form of AI applied to a NPC or object, that can depening on factors choose from several predefined options, on what to do.

E.g.:

NPC enemy can have these choices when spotting player actor(s)

  1. shoot at player on sight (uncovered)
  2. take cover behind object
  3. take cover behind object and fire occasionally towards player, and remaining in cover position. (other anims apply there)
  4. Flee to safety, (other waypoint that is out of player sight)
  5. flee and also blind fire to player during flee…

if player shoots back:

  1. npc enemy takes cover when player shoots npc enemy
  2. npc enemy stays in position when player shoot npc enemy
    etcetcetc

it’s possibilities are defined, but the NPC can randomly choose from the possibilities, and or blend several, as a sequence… e.g. first choose option 1, later choose 5 if hit more then x times by player etc…
it’s up to the npc itself, on what to do within the creteria setup.

How can this (if at all) get accomplished in Unity?
Haven’t found anything resembling this issue on the forums, and external tutorials or documentation.

Thanks in advance.

You could look at Behave from AngryAnt www.angryant.com which is a editor for designing Behaviour Trees.
Behaviour Trees let you design you AI and what types of actions it should take.
It is a powerful technique that is quite easy to understand, and you will have a much better overview of your AIs behaviour.
You can find much more information on BT on www.aigamedev.com

Behaviour trees (such as AngryAnt’s) are a good way to structure a character’s decisions over time based on the results of its actions. However, deciding which of a set of actions to take instantaneously is something different.

There are typically several pieces of “evidence” that the NPC uses in making the decision. For example, in the situation you describe, the following factors might be relevant:-

  1. Is the opponent armed?
  2. Is cover available nearby?
  3. Is there anywhere to flee to?

It might be possible to have a table of all possible combinations of these factors and have a course of action for each. When there are many combinations, it is more common to weigh the factors in sequence by structuring them as a tree. Each node of the tree essentially corresponds to a yes/no (or even multiway) decision based on a particular factor. For example, the NPC might always flee if there is anywhere to flee to. If not then he will only fire directly if there is no cover. The decision is reached by following branches of the decision tree.

It is often useful to have a random element in the decision, especially if some options are more likely to be chosen than others. There is a script attached to this thread which can choose items randomly, but with different probabilities set by the user.

I guess what you really want to know is if there are any existing solutions to construct decision trees, and unfortunately, I don’t think there are any.

Thanks, for the information :slight_smile:

I’ll dive into it, and perhaps i figure it out, with the pointers given, maybe not… we’ll see…
(it’s still a bit complicated for me, some information, but maybe it becomes more clear, when i experiment with it. Currently experimenting/testing two engines, with two different approaches/languages… :roll: )
Talking about: why doing it easy, if it can be done difficult :wink: