IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Small AI Guide to Adjust Attack Teams
Mizo
post 14 Dec 2017, 2:02
Post #1


AI Coding Expert
Group Icon

Group: Dev. Team
Posts: 1846
Joined: 9 May 2014
From: Poland
Member No.: 10450



I write this guide to give you all just a brief tip on something that I've been recycling/testing over and over to see exactly how it works. It's regarding the AI attack teams , and how Complimentary Teams and Attack Timers play a role all together, as well as give a few cautions on what can happen if you do X or Y.

Main purpose of this is to give the AI good performance as well as preventing unit base clogs. Note this is only focusing on Skirmish AI development.


First lets define a few things regarding how the AI build teams :

- Priority is how likely the AI is to pick team, Even the smallest difference in those values can make huge difference in what the AI pick what. Intuitively , they'll always pick the teams with the higher priority value first.
- Complimentary Teams are a new addition to ZH AI that basically gives their normal attack teams extra units depending on what the enemy has. They basically compliment other attack teams, as the name states.
- Normally, based on ZH scripts , Attacks are normally carried on via Attack Timer. What does this mean? Basically on a normal occasion, as soon as a team is built, the AI will order it to guard base parameter. However, the script that orders the AI to attack is defined in the generic behavior tab, that orders the AI to attack under the condition that _Launch_Attack ( or whatever) flag is True. Flag are values that can be either True or false. The second condition for the team to attack if it the team has 1 or more units, which means the team doesn't have to be fully build in order to issue an attack, HOWEVER, they will preform their On-create Guard Base order as soon as the team is fully created, even if part of it is attacking ( they will head back to base and guard to wait for the next time the flag is triggered).
- The Flag constantly switches based on a timer ( It's usually a non-subroutine Script that is always active and is evaluated per X second). X stands for the delay between attacks. According to ZH, the delay is usually 30 seconds, but that can be more. Note that the Attack Timers can be set in other ways if you know scripting well. I script the AI based on a special randomized timer , as well as other conditions such as if the AI meets specific conditions ect.. I won't be discussing it here however.

Attack Timer VS On-create Attacks

On-Create Attacks is very useful for rushes. Basically as soon as the team is created, the team will start attacking right away. This attack script is not defined in the generic Tab but in the behavioral Tab on the On-create script intuitively. However. since the AI has to fully build the team in order for the On-create script to issue, I would not advice to make those teams that use this function to be large teams as it can cause base clogs throughout the game ( depending on the total number of teams you have). You generally can use it on Rush teams early, or air units.

A minor disadvantage of this system is that if a good handful of attack teams are using this method of attacking, then the game will slow downs by a few frames depending on the number of teams/units per team since the game is calculating the pathfinding math over multiple frames. This can slow down the game over time.

An advantage the Attack Timer System has over the On-create attack is that all calculations are issued over 1 frame only. This caused the game to stutter in 1 frame for the calculations. Makes sense as the AI will only be ordered to search for units over this 1 frame.

Note that regardless of what you do, the game will always lag when there are many units. This is mostly due to faulty algorithms for which the unit calculates attack priorities and memory leaks, besides the optimized pathfinding or the models/particle effects.


Building Teams

- It's always better to divide your attack teams into smaller groups of 5 max units per team. Don't use the "Multiple Count" Function , as I found having to duplicate the teams themselves if you want more copies to be more efficient performance wise. Don't ask me why, don't really know. IF you're gonna use the multiple count units, reserve them for very small teams that do not use an attack timer to attack but rather preform their order on-create. If you want larger attacks then I recommend using an Attack Timer System.

- Set Attack Priorities, if you don't you're going to sacrifice performance. Blame SAGE. I tested attack teams using attack priorities and teams without. Main difference is that the latter will attack the units closest to them. It's probably related to the attack priority algorithm that calculates what the AI should attack ect... FPS can drop by 33% if there are alot of attack teams. and sometimes can reach over 50%.

Building Complimentary Teams

- As stated , CTs are teams that join other attack teams that have been fully built. This means that if a team is missing a member , and is triggered to attack prematurely via attack timer, then the Complimentary Teams will not join and remain in base, waiting for a team to be fully created.
- Of course you have to add a CT - Join My Team in the generic Tab of an attack team in order to make them possible for CT teams to merge into.
- The Script "CT - Buildable" is defined in the "On-destroyed" data field in the behavioral tab. You can adjust the % of how much destroyed the team is. This basically orders the AI to rebuild the CTs even if the team is not fully destroyed. It's rather very crucial otherwise they will never be rebuilt again.

- CTs are very useful to add specific counter units to your attack teams. Crucial if you want the AI to cover their attack groups with AA, or Anti-infantry units or even artillery ect..

- The mistake ZH did with those complimentary teams, is that overtime, when the game prologues , the AI is ordered to build very large attack teams ( relatively) , making it more likely for an attack order to be issued prematurely, leaving the CTs in base, being built over and over. This eventually cause lag , base clogs, and units just sitting in base doing nothing. A lot of mods do this mistake, due to them recycling ZH AI. Solutions to remedy this is to reduce the attack team sizes ./ and increasing the delay for which _Launch_Attack Flag is triggered ( former is better alternative than the latter depending on the number of teams you have).


Well this is the end of the guide. Stuff said above is probably known, but I just wanted to shed light on them again in case anyone is interested.

This post has been edited by Mizo: 14 Dec 2017, 2:03


--------------------


Not a Rusty Spoon........The_Hunter uses a goddamn wooden spoon on his AI Scripters....
Go to the top of the page
 
+Quote Post
Omeka88
post 28 Dec 2017, 21:44
Post #2



Group Icon

Group: Members
Posts: 48
Joined: 14 July 2017
From: Roma
Member No.: 15601



sorry if this question isn't reveleant
is any whay for force\use the "attack move" command ?

most of the time enemy ia unit just follow the waypoint and never stop a.k.a turn into dummy target if amushed during the "moving order"


--------------------
Go to the top of the page
 
+Quote Post
Mizo
post 1 Jan 2018, 2:03
Post #3


AI Coding Expert
Group Icon

Group: Dev. Team
Posts: 1846
Joined: 9 May 2014
From: Poland
Member No.: 10450



The only way to make them actively react is by not giving an attack priority to the team. They will attack the closest units to them but targetting would become dumb.


--------------------


Not a Rusty Spoon........The_Hunter uses a goddamn wooden spoon on his AI Scripters....
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 28 March 2024 - 13:12