Login

russian armor

Need help with AI threat perception

Dar
6 Feb 2022, 16:25 PM
#1
avatar of Dar

Posts: 84

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.
6 Feb 2022, 18:25 PM
#2
avatar of SneakEye
Senior Modmaker Badge

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.
6 Feb 2022, 18:27 PM
#3
avatar of Sie_Sayoka
Modmaker Badge

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.
Dar
6 Feb 2022, 18:56 PM
#4
avatar of Dar

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
avatar of Sie_Sayoka
Modmaker Badge

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.

Dar
7 Feb 2022, 17:26 PM
#6
avatar of Dar

Posts: 84

Thanks a lot, I will try duplicating that
8 Feb 2022, 23:31 PM
#7
avatar of Zycat

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.
Dar
13 Feb 2022, 14:50 PM
#8
avatar of Dar

Posts: 84

jump backJump back to quoted post8 Feb 2022, 23:31 PMZycat
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
avatar of Zycat

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.

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.

jump backJump back to quoted post6 Feb 2022, 16:25 PMDar
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.
Dar
22 Feb 2022, 17:34 PM
#10
avatar of Dar

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.

jump backJump back to quoted post20 Feb 2022, 09:23 AMZycat

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.
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

681 users are online: 681 guests
1 post in the last 24h
7 posts in the last week
39 posts in the last month
Registered members: 49062
Welcome our newest member, Mclatc16
Most online: 2043 users on 29 Oct 2023, 01:04 AM