Tobias Solem

[GUIDE] How to configure the AI properly

11 posts in this topic

Posted (edited)

One of the most persistent reputations of AI in ARMA is that they either are dumb as a rock or robot death machines. The reason why is usually because they have been unappropriately configured or worse, not configured at all. Before we begin there are a few factors you need to be aware of that drastically determine AI behaviour, they are: brain and server performance.

Brain

The 'default' brain in ARMA 3 gets the job done. Basically in ARMA you can configure AI behaviour through a set of rules that define the logic of their brain. These sets of rules basically make up their decision making and work sort of like a chart of "what should I do if this happens". The more advanced the brain is, the more advanced the behaviour of the AI, which gives it opportunities to (for example) set waypoints to go inside a building and walk up stairs, clear rooms, throw grenades and such. But all of these rack up a lot of resources used, so in ARMA, multiplayer AI, these abilities usually aren't present because those who are skilled enough to program these AI-scripts (not me) try to balance the brain of the AI to do certain tactical actions, but not too many. If you see a more advanced AI-system that do more complicated stuff, it comes with the caveat that each instance of an AI will use more computing power. Meaning that you might have 20 decision-making super-tactical bots or 100 decently-capable bots using the same resources.

Server performance

One of the big things about AI-behaviour is that they need computing power. The AI tends to utilize the "CPS" (Condition evaluation Per Second) which directly affects the AI's ability to respond to a threat for example. The lower the CPS, the longer response time for the AI, 0 meaning that they do not respond at all, and stand around like frozen statues, and lower mounts meaning that they react slowly, and do really "dumb" stuff. Think of it like 15+ CPS is them functioning well, and every step under that means they're getting more and more drunk. The less resources available for AI, the worse they will perform and thusly become "easier"

Further info & optimizing a server here: http://goo.gl/fLSjg7

 

How to configure the AI properly

This statement implicates that you are familiar with the two above principles, because everything you learn from hereon will be affected by the two above. With that out of the way, lets get to the meat of configuring AI. AI are configured with the setSkill-command, which usually comes after a this (clientside definition) or a _this (global definition) setting (for more details, look into the ARMA 3-wiki, I'm by no means skilled at SQF, but reading there gives you better insight to why you do what when). This command then has a subset of parameters, they are: aimingAccuracy, aimingShake, aimingSpeed, reloadSpeed, spotDistance, spotTime, courage, commanding, and general. 

Each setting uses a percentage setting ranging from 1.0 (100%) to 0 (0%) usually meaning that the higher the better. This is all set by the following syntax (for example):

this setSkill ["aimingAccuracy", 0.75];

In the above case we set the "aimingAccuracy" to 75% of maximum. Roughly calculating a probability that 3 out of 4 bullets the AI fires strike the intended target. Note that these numbers are modified by other factors, such as movement, range, cover, etc. - but that's the base attribute. Using the same syntax you can set the individual AI-criteria, see below for details:

* aimingAccuracy - Affects the probability of the AI hitting a target with its weapon(s)
* aimingShake - Affects the AI weapon sway, in this case meaning that 0.10 for example sets the weapon at 90% sway
* aimingSpeed - Affects the AI's ability to place its crosshair/iron sight exactly where it needs to hit the target, higher means quicker aim
* reloadSpeed - How quickly an AI reloads his weapon, higher means faster reload time
* spotDistance - How many percent out of maximum view distance can the AI spot the target from?
* spotTime - How quickly does the AI spot the player with a direct line of sight? 1.0 being immediately.
* courage - How courageous is the AI? This is affected by a number of criteria, such as friends dead. 1.0 means that it will never try to run away.
* commanding - How effective is the AI at, if it can, communicate that it has spotted a hostile target and its position to the other AI? 1.0 = 100% effective.
* general - Overrides any of the above settings (if they are not already set) and sets the values at the specified setting.

Using the above syntax, you can set all of these skills in an array, like DMS does, like so: 

[["aimingAccuracy",0.10],["aimingShake",0.70],["aimingSpeed",0.75],["spotDistance",0.70],["spotTime",0.50],["courage",1.00],["reloadSpeed",1.00],["commanding",0.50]];

Defining settings like this greatly affects the AI behaviour, meaning that depending on how much or little of a challenge you want the AI to pose, you need to balance these to find a sweet spot that is to your liking. A good way of doing it is by spawning in a group of enemies in the Eden editor and set their skills (it uses a slider to define their skillsets, but that slider is exactly like the above, it sets the %). Then engage the AI and watch their behaviour. 

 

Groups

When you add AI in a mission system, every new "instance" of AI you add forms a group. Normally each mission in Exile for example has one single group. Depending on the mission system, these groups do not communicate with each other, or does not communicate with each other over distance. Which is good, imagine having two missions running on the same map, and the AI mission from one site starts moving away from ... defending the bunker, or whatever, to move to the other group. The bad part about having just one group per mission is that group will not split up into two groups where one flanks for example and the others take position. Splitting into more groups also uses slightly more resources.

So, that's it for my little guide. Do with it what you will. But please, before you criticize the AI of a certain mission system. Know your details. :)

 

Edited by Tobias Solem
10 people like this

Share this post


Link to post
Share on other sites
Advertisement

I would also look at AI locality as it reduce server load by offloading AI calculations to clients.

Share this post


Link to post
Share on other sites

Posted (edited)

Another thing to add is the fact that the AI evaluate their targets before firing. This can be seen when you drive an Ifrit or any other heavily armored vehile past AI. They will not engage it 9 times out of 10 because the "brain" says that they cannot destroy said vehicle. Giving the AI RPGs does not help either for the more armored vehicles and increasing their quantity of AI does not help either. Basically, if the AI can destroy it with rifles then they will engage, otherwise they ignore it.

AI locality to players generally performs better than a headless client. If using locality change, keep in mind that the target players computer will affect the skill of the AI. If the player has bad fps then the AI will perform worse and vice versa.

If you spawn in AI they will be set to group as Tobias mentioned, however they will generally be enemies with each other and you have to make them friendly.

[_unit] joinSilent _group;

 

Edited by Defent
1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

2 hours ago, Defent said:

If you spawn in AI they will be set to group as Tobias mentioned, however they will generally be enemies with each other and you have to make them friendly.


[_unit] joinSilent _group;

 

"Friendliness" between groups in general is mostly controlled by the "setFriend" script command, as shown in the screenshot below (from DMS)

bSDTa9u.png

This makes all factions hostile to each other (and even their own faction, when not in the same group). Therefore, if you allow a faction to be "friendly" with itself, then 2 groups of the same faction *shouldn't* attack each other. EG:

EAST setFriend[EAST,1];

 

Edited by eraser1
1 person likes this

Share this post


Link to post
Share on other sites
On 3/30/2016 at 1:09 AM, eraser1 said:

"Friendliness" between groups in general is mostly controlled by the "setFriend" script command, as shown in the screenshot below (from DMS)

bSDTa9u.png

This makes all factions hostile to each other (and even their own faction, when not in the same group). Therefore, if you allow a faction to be "friendly" with itself, then 2 groups of the same faction *shouldn't* attack each other. EG:


EAST setFriend[EAST,1];

 

As side info on that:

I got groups attacking eachother with are Both East and the following was executed server side:

EAST setFriend[EAST,1];

The following code puts the ai in the correct group

_dummyGroupEast = createGroup east;

_unitAI = _dummyGroupEast createUnit ['O_G_Soldier_F', _posAI, [], 0,"FORM"];

[_unitAI] joinSilent _groupAI;
deleteGroup _dummyGroupEast;

_unitAI is also an EAST group.

I tried it this way( With 2 groups) as it was the last thing i could find to make it work:
https://community.bistudio.com/wiki/Side_relations

2 people like this

Share this post


Link to post
Share on other sites

Posted (edited)

Question, might it be possible that I need to run the following code also on client side since the AI is offloaded  to the clients? ( Makes sense since i'm typing this out)

EAST setFriend[EAST,1];

Will try that.

Edited by Zupa

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.