Hey community,
over the years of tinkering with the AI I've never really figured out how it calculates threat from a unit, or where to attack next. The AI seems to have some sort of threat perception that can break a game quite easily:
For instance, when I put a Pak 43 and a Machinegun Bunker at a chokepoint, even an Expert Bot will assault that only once or twice with a probing attack, and then avoid it for pretty much the rest of the match - even though enough artillery or some concentrated attack would surely bring the emplacement down.
This can lead to funneling the AI onto one side of the map, making it extremely easy to hold them off, and somewhat turning your Pak 43 into an expensive wall of hedgehogs. Behavior varies depending on the map, but there is certainly a pattern to this.
At the opposite end of things, the AI regularly launches suicidal attacks into your territory, ignoring everything in their way, just to get rid of a Walking Stuka or Panzerwerfer.
Now, is there a particular value to tweak, or set of rules to change that would convince the AI to launch more serious attacks against strongpoints, or to not throw an army away to kill some rocket artillery?
Any leads welcome.
Need help with AI threat perception
6 Feb 2022, 16:25 PM
#1
Posts: 84
6 Feb 2022, 18:25 PM
#2
Posts: 817 | Subs: 5
There is one settings that seems to heavily influence this. In ai_settings/pathing/pathing_detects_opponents_fog_of_war.
Description: "If true, the AI will take into account what areas the enemy can not see when path finding. Areas the enemy cannot see are considered safer."
I have set this to false for all difficulties and feel that it actually made the AI better. Instead of focusing on capturing territory, it now fights a lot more. I hope it helps. The AI behavior in general is still very mysterieus.
Description: "If true, the AI will take into account what areas the enemy can not see when path finding. Areas the enemy cannot see are considered safer."
I have set this to false for all difficulties and feel that it actually made the AI better. Instead of focusing on capturing territory, it now fights a lot more. I hope it helps. The AI behavior in general is still very mysterieus.
6 Feb 2022, 18:27 PM
#3
Posts: 100 | Subs: 1
I'm also interested in learning more about AI. I believe I've found some relevant files although it would require knowledge of scar to correctly decipher them. They are all located within data.sga.
data\ai\tactics.ai
data\attribxml\templates\types\ai\
data\scar\systems\aimanager\
data\scar\systems\aimanager\goals\
There's so many god damn variables that its difficult to test exactly what each function does. It also seems that some functions are just broken or at least don't do what their description says. One thing that I did find helpful was using the defense_building entity type which made the AI consistently send a couple of squads to attack it. But even this is highly conditional as it requires certain extensions to work properly.
data\ai\tactics.ai
data\attribxml\templates\types\ai\
data\scar\systems\aimanager\
data\scar\systems\aimanager\goals\
There's so many god damn variables that its difficult to test exactly what each function does. It also seems that some functions are just broken or at least don't do what their description says. One thing that I did find helpful was using the defense_building entity type which made the AI consistently send a couple of squads to attack it. But even this is highly conditional as it requires certain extensions to work properly.
6 Feb 2022, 18:56 PM
#4
Posts: 84
There is one settings that seems to heavily influence this. In ai_settings/pathing/pathing_detects_opponents_fog_of_war.
Description: "If true, the AI will take into account what areas the enemy can not see when path finding. Areas the enemy cannot see are considered safer."
I have set this to false for all difficulties and feel that it actually made the AI better. Instead of focusing on capturing territory, it now fights a lot more. I hope it helps. The AI behavior in general is still very mysterieus.
I actually use the same setting within my mods and have been for years. It does significantly improve AI behavior, but the issues that I describe do persist.
One thing that I did find helpful was using the defense_building entity type which made the AI consistently send a couple of squads to attack it. But even this is highly conditional as it requires certain extensions to work properly.
That is quite interesting, I will investigate that. Do you know which extensions need to be present for this to work properly?
One thing that I found intriguing is a weapon's priority_ext/threat
Description: "Multiplied by the chance of the target's primary weapon penetrating me. (ie 50% of the value is used if the target has a 50% chance of penetrating)"
I don't want to mess things up by playing around with this value, and my first thought was that it only applies in combat situations that are ongoing. But I wonder if it potentially factors into the AI's decision to attack or not attack a target? Say, if it calculates a very high threat (Pak43 has massive penetration chance on anything), the AI will refuse to attack?
6 Feb 2022, 19:31 PM
#5
Posts: 100 | Subs: 1
I am stacking 5 on my HQ buildings as the AI will not attack it otherwise. I haven't tested to see if this will work with moving squads. Ai_settings\skirmish_settings\attack_importance\defensive_structure is set to 50, or 3rd highest, although these values are relative.
Maybe not all of these extensions are required but most of them are.
- The weapon must do damage but you can set its aim time to some high number so it wont actually fire.
- Blueprint can be anything but is_visible_in_game must be true.
- Health can be invincible.
- Weapon_targeting can be no_targeting.
- Selection_type cannot be no_select.
7 Feb 2022, 17:26 PM
#6
Posts: 84
Thanks a lot, I will try duplicating that
8 Feb 2022, 23:31 PM
#7
Posts: 14
Try reducing the combat_eval_required_win_ratio_at_max_class_rating and min.
Also, set your max_num_attack_objectives to the maximum which is 100. The way the AI works from my own observation is they assign attack objectives on enemy units and evaluate the combat_eval for each one.
Also, set your max_num_attack_objectives to the maximum which is 100. The way the AI works from my own observation is they assign attack objectives on enemy units and evaluate the combat_eval for each one.
13 Feb 2022, 14:50 PM
#8
Posts: 84
Try reducing the combat_eval_required_win_ratio_at_max_class_rating and min.
Also, set your max_num_attack_objectives to the maximum which is 100. The way the AI works from my own observation is they assign attack objectives on enemy units and evaluate the combat_eval for each one.
Thanks Zycat, the max_num_attack_objectives definitely make the AI more challenging. I never knew setting it as high as 100 is a valid option.
I tried lowering the combat_eval_required_win_ratio_at_max_class_rating to 0.6 and ...min_class_rating to 0.9, but the AI behaviour now is odd. They start prioritizing bringing infantry over tanks, often saving heavy armor until the very end of a 1h match. They spam team weapons and dislike bringing mobile artillery pieces like Katyushas. Tank destroyers suddenly are produced early, turreted tanks much too late. This is not a utility issue as I have fine-tuned the utility of units for years, and this behavior is definitely new.
I would like to understand what actually happens when these values are tweaked. Do we have any intel on how the class_rating works?
20 Feb 2022, 09:23 AM
#9
Posts: 14
Sorry I'm not checking this forum very often.
AFAIK the combat_eval values govern how the AI chooses attack objectives as well. I even tried increasing the combat_eval_min_class_rating value and the AI starts behaving weirdly when it's over 10. I tried as low as 1 min_class_rating and the AI will chase retreating squads sometimes. My general observation is the lower the number, the more aggressive it is. Also I have my required_win_ratios backwards, i.e the at_max_class_rating is higher than at_min_class_rating, since my logic is that early engagements must be fought at about equal squad values (like Conscripts vs Grenadiers) while late engagements requires more units. Not sure if it works properly though.
Oh right, I also set attack_objectives_replan_time (and all other processing delays) to 1. I don't recommend doing this unless you free up CPU usage by optimizing the tactics.ai
I dunno about combat_eval affecting build orders. I'm even surprised that it does.
Pak43s, Bofors, 3inch Mortars and the likes are (most likely) not categorized as "entity" but as a "squad" with a "team weapon" for the purposes of AI. I know because if you set an ai_ability to only use the entity_filter it won't ever target those, but it will target bunkers.
Oh right, also for some reason some team weapons give cover to the soldiers and thus the combat value is multiplied by the value in cover_table. Try reducing that number.
Try turning off pathing_detect_min_firing_range. Since artillery pieces and mortars often have min range the AI will think the closer they get the safer they are.
BTW your suggestion for coaxing the AI to use mines with MG42 works, although if you do that somehow the mines doesn't explode at all even if I change the weapon. I solved by spawning another mine that explodes and not deleting the original MG42-laden mine so the AI doesn't try to constantly build mines.
AFAIK the combat_eval values govern how the AI chooses attack objectives as well. I even tried increasing the combat_eval_min_class_rating value and the AI starts behaving weirdly when it's over 10. I tried as low as 1 min_class_rating and the AI will chase retreating squads sometimes. My general observation is the lower the number, the more aggressive it is. Also I have my required_win_ratios backwards, i.e the at_max_class_rating is higher than at_min_class_rating, since my logic is that early engagements must be fought at about equal squad values (like Conscripts vs Grenadiers) while late engagements requires more units. Not sure if it works properly though.
Oh right, I also set attack_objectives_replan_time (and all other processing delays) to 1. I don't recommend doing this unless you free up CPU usage by optimizing the tactics.ai
I dunno about combat_eval affecting build orders. I'm even surprised that it does.
For instance, when I put a Pak 43 and a Machinegun Bunker at a chokepoint, even an Expert Bot will assault that only once or twice with a probing attack, and then avoid it for pretty much the rest of the match - even though enough artillery or some concentrated attack would surely bring the emplacement down.
Pak43s, Bofors, 3inch Mortars and the likes are (most likely) not categorized as "entity" but as a "squad" with a "team weapon" for the purposes of AI. I know because if you set an ai_ability to only use the entity_filter it won't ever target those, but it will target bunkers.
Oh right, also for some reason some team weapons give cover to the soldiers and thus the combat value is multiplied by the value in cover_table. Try reducing that number.
At the opposite end of things, the AI regularly launches suicidal attacks into your territory, ignoring everything in their way, just to get rid of a Walking Stuka or Panzerwerfer.
Try turning off pathing_detect_min_firing_range. Since artillery pieces and mortars often have min range the AI will think the closer they get the safer they are.
BTW your suggestion for coaxing the AI to use mines with MG42 works, although if you do that somehow the mines doesn't explode at all even if I change the weapon. I solved by spawning another mine that explodes and not deleting the original MG42-laden mine so the AI doesn't try to constantly build mines.
22 Feb 2022, 17:34 PM
#10
Posts: 84
Thanks for the amount of good information here. I will use this knowledge to further fine-tune AI behavior.
This is off-topic, but may be interesting to some:
Context: I got my AI to lay mines by tricking them into thinking that it's an MG bunker of sorts. This way, they will lay mines in somewhat strategic locations and around their emplacements. The AI loves MG buildings, so attaching a dummy MG to any building or object will result in them constructing that asap.
Good to hear that you got it to work. My AI mine actually works without spawning another set.
The mine starts out with 2 hardpoints:
1. hardpoint: dummy_mg
2. hardpoint: teller_mine_mp
I added a change_weapon action in the mine's on_construction_actions that changes hardpoint 1 to the teller_mine_mp weapon (or whatever mine "weapon" you want).
Then, with a delay action of 0,01, I remove_weapon the hardpoint 2 with fire_and_forget=true.
Happy to elaborate further, maybe even in a dedicated thread.
This is off-topic, but may be interesting to some:
Context: I got my AI to lay mines by tricking them into thinking that it's an MG bunker of sorts. This way, they will lay mines in somewhat strategic locations and around their emplacements. The AI loves MG buildings, so attaching a dummy MG to any building or object will result in them constructing that asap.
BTW your suggestion for coaxing the AI to use mines with MG42 works, although if you do that somehow the mines doesn't explode at all even if I change the weapon. I solved by spawning another mine that explodes and not deleting the original MG42-laden mine so the AI doesn't try to constantly build mines.
Good to hear that you got it to work. My AI mine actually works without spawning another set.
The mine starts out with 2 hardpoints:
1. hardpoint: dummy_mg
2. hardpoint: teller_mine_mp
I added a change_weapon action in the mine's on_construction_actions that changes hardpoint 1 to the teller_mine_mp weapon (or whatever mine "weapon" you want).
Then, with a delay action of 0,01, I remove_weapon the hardpoint 2 with fire_and_forget=true.
Happy to elaborate further, maybe even in a dedicated thread.
PAGES (1)
1 user is browsing this thread:
1 guest
Livestreams
118 | |||||
21 | |||||
1 | |||||
62 | |||||
57 | |||||
14 | |||||
11 | |||||
2 | |||||
1 | |||||
1 |
Ladders Top 10
-
#Steam AliasWL%Streak
- 1.829222.789+35
- 2.34857.859+13
- 3.587233.716+3
- 4.1095612.641+19
- 5.882398.689+4
- 6.280162.633+8
- 7.996645.607+4
- 8.379114.769+1
- 9.300113.726-1
- 10.717439.620+1
Replay highlight
VS
- cblanco ★
- 보드카 중대
- VonManteuffel
- Heartless Jäger
Einhoven Country
Honor it
9
Download
999
Board Info
764 users are online:
764 guests
3 posts in the last 24h
4 posts in the last week
23 posts in the last month
4 posts in the last week
23 posts in the last month
Registered members: 48722
Welcome our newest member, asherllc
Most online: 2043 users on 29 Oct 2023, 01:04 AM
Welcome our newest member, asherllc
Most online: 2043 users on 29 Oct 2023, 01:04 AM