Battle Brothers

Battle Brothers

View Stats:
turtle225 Sep 27, 2022 @ 8:40pm
2
Ranged AI behavior/tests - TLDR: It makes no sense (actually makes some sense)
Because I'm still a nerd, I had some inspiration to do some tests/studying of the ranged AI to try and see if there were any trends in their targeting behavior. Knowing such a thing could help us make informed decisions to the value of ranged defense with potential AI manipulation.

I think the current community understanding is that the AI tends to like shooting softer targets and targets with less ranged defense. This feels like it is generally true to me when I'm playing normally. My Nimbles get shot more than Forge, and they seem to like shooting lower hp, lower rdf bros.

I thought that I could try and test for this in as controlled an environment I could manage and see if the AI could be predicted, but my testing just left me more confused. The AI seemed pretty random or nonsensically broken, and not predictable at all from the expected levers we have (hp, perks, armor, rdf).

My original plan was to use the Bro Editor mod and the Combat Simulator mod to create a perfectly controlled environment where I could test two bros with one open space apart against a single Ambusher. This failed however because the AI was broken and would only shoot one of my bros no matter what I did. I even tried giving him 500 hp, 200 rdf, and famed heavy armor, and had the second bro as naked, 1 hp, and 0 rdf, and the AI was still not shooting the naked guy. It doesn't make any sense. I figured the mod environment somehow broke the AI.

So moving away from the mods, I tried to do some tests with my current game I'm running. I found a group of 6 Ambushers with one being a Champ. The first thing I tried was to put two bros on the field again and see who the AI would target. Once again the AI will only shoot one of the two bros fielded, but the bro they pick doesn't seem to make any consistent sense. They aren't going consistently for lowest hp, or lowest armor, or lowest ranged defense. I tried a bunch of different pairs.

I noticed that my Banner bro was always the preferred pick when he was one of the two in the pair, even though he had 40+ rdf and Anticipation (70hp). I even tried putting a naked guy opposite him and they still shot my Banner instead. My initial thought was that this was because Rally was increasing his target attraction, but I tried putting Rally on the naked bro and they still shot my Banner. I can't make sense of it, unless this specific two-bro setup just breaks the AI in general.

https://steamcommunity.com/sharedfiles/filedetails/?id=2868594941

To add to the confusion, my next set of tests was to put 7 bros on the frontline to see what happened. With these tests the AI almost never shot my Banner, despite him always being the preferred target in the pair tests (which is confusing). If I ran the same lineup multiple times the AI's preferred target seemed to be consistent, but if I just shuffled the position of two bros then the AI's preferred target would often change to someone entirely different despite the bros still being the same. I tried a bunch of different orders and almost everyone (not the Banner) was chosen as the primary AI target in at least one formation. To add more confusion, I even snuck a naked guy into the lineup and the AI ignored him.

https://steamcommunity.com/sharedfiles/filedetails/?id=2868601314

https://steamcommunity.com/sharedfiles/filedetails/?id=2868601399

https://steamcommunity.com/sharedfiles/filedetails/?id=2868596693

There's only two consistent observations I could make. One was that the AI seemed to largely want to focus one bro in every test, even if I could not get any reasonable prediction as to which bro that was going to be. I found that once a bro was picked, I could even Shieldwall with a Kite Shield and get him to 80 active ranged defense and they still kept trying to shoot him despite much easier targets nearby.

The other consistent thing I found was that the AI never focused the two edge bros. They would always pick one of the inner five to focus on. If I found one guy getting focused and I reloaded the test with him on the edge the AI would choose someone else. I'm not sure my sample size is big enough to make a real conclusion that AI shooters are unlikely to shoot your edge bros, but it was one of the only consistent things I found with my tests.

So can we make any real conclusions from these tests? It doesn't really feel like it to me, except maybe that the AI is more unpredictable and random than I thought before. They don't seem to behave in these tests the same way as they do in normal gameplay, I suppose because in normal gameplay your bros move around a lot and that changes how the AI evaluates.

As for what it means for ranged defense, idk. In my pair tests I had the AI only shooting my near unhittable Banner, but in the 7 man lineup they largely ignored him. So the rdf was amazing in one test and irrelevant in the other, with no clear understanding from me as to why the AI is reacting differently between the two tests. If we can find a way to consistently understand AI tendencies, that could lead to situations where rdf could be very good, but the AI seemed pretty random about shooting my bros with higher or lower rdf in the 7 man tests.

The AI was ignoring naked bros in both tests, so they don't seem to automatically zero in on bros they can easily kill. They weren't consistently shooting my lowest rdf bro, or my lowest hp bro.

I was hoping to share something more insightful with everyone, but this is what I've found through this limited testing. I would be interested to hear other's thoughts on either this or your own experiences. If you've found a way to consistently predict the AI then I would love to hear about it. Thanks for reading.

EDIT:
I did another round of testing, trying to test the AI's tendency to shoot interior bros rather than edge bros. It does appear that we have something here.

Recall from the pair tests that they always wanted to shoot my Banner, well I put him and two other bros side by side in 3's, and when the Banner was on the edge they nearly always shot the middle guy. When the Banner was in the middle they still often tried to shoot him despite him being their worst target.

https://steamcommunity.com/sharedfiles/filedetails/?id=2868772320

https://steamcommunity.com/sharedfiles/filedetails/?id=2868772296

Things got trickier when I introduced a backline. It's a bit harder to track now who the AI is targeting since there are so many misses/scatter shots. They were kind of spreading damage around the blob in general, but they were still trying to hit my Banner sometimes despite him being their worst target.

https://steamcommunity.com/sharedfiles/filedetails/?id=2868772269

When I moved more units to the lower side the AI shot at that group instead, with a preference toward the middle again.

https://steamcommunity.com/sharedfiles/filedetails/?id=2868772215

So maybe we do actual have a useful conclusion from these tests. The AI does seem inclined to want to shoot at bros that are surrounded by other bros. My guess is that they are trying to maximize potential for scatter value in the event that they miss.

With this in mind, maybe try positioning your highest rdf bros in the middle-front, and your lowest rdf bros on your edges and see if that helps when fighting ranged enemies. Or try putting the guys you don't want getting shot in a single file away from your main group.

They were shooting my 40 rdf Anticipation Banner in this test, so there may be some value in rdf stacking with this, though in a real battle your team is going to be moving a lot which will change what the AI is doing.

EDIT 2:
With some more testing, I think I've found a formation that can cheese the AI. You field a full frontline and then put 3 in the back center. This creates a situation where the AI wants to shoot 3 specific bros, the middle-back guy and the two immediately in front of him, even if these are not their best targets.

To demonstrate, I put my Banner, my second highest rdf guy (the Ancient Pike in the back), and my famed Forge super tank in those three positions, and the AI is shooting at my Forge tank despite him being literally their worst option on my team and everyone else being Nimble.

https://steamcommunity.com/sharedfiles/filedetails/?id=2868924904

With this formation you can get very high value out of having 3 bros with high rdf investment (or just put your tanks here). I tested this against a couple of camps in my normal game and it worked each time. I even tried putting very vulnerable bros nearby the trio and the trio was still the ones getting targeted. Once I started moving around the AI became a little less predictable as I couldn't keep the perfect formation, but they were still generally trying to shoot where I was blobbing.

If you are going to build a 40 rdf Anticipation bro, this is a way to get value from it.
Last edited by turtle225; Sep 28, 2022 @ 5:11pm
< >
Showing 1-15 of 27 comments
In conclusion: inconclusive!

Thanks for the effort Turtle (nerd!)
A5G_Reaper Sep 27, 2022 @ 9:06pm 
They do focus fire, but the who and why felt completely random. I often observe that they'll completely maul one bro, but once I move him a few steps back they just completely switch target. Even if the original dude is at 1HP, have no more armor, sports 4 different injuries, is standing in the open, and still well within shooting range.
Coldoge Sep 28, 2022 @ 5:16am 
The unpredictable makes me like the game more.
ecb2 Sep 28, 2022 @ 6:05am 
Nice read, thanks!
Edmund Greyfox Sep 28, 2022 @ 7:52am 
Interesting info. It tends to invalidate the thinking behind builds that try to minimize RDF on a bro (while maximizing HP) to turn him into an arrow magnet.

It does seem odd that they are ignoring "easy kills" like guys with no armor or only 1 hit point though. My experience in normal play has been that if a bro gets low on HP/armor and i move him to the back line that every AI archer on the field goes after him in the next round. Only thing i can think of is that the AI might be looking at the percentage of max hit points/armor, which would make someone with only 1 hit point look like they were at 100% health.
Oceon Sep 28, 2022 @ 8:42am 
One Tooltip says that rangers are bound to hit if they fire into a group of targets. Maybe thats a value they rely on?
Dixie Normus Sep 28, 2022 @ 9:11am 
The side-bro thing explains why my Fencer is no pincushion. I was seriously wondering why a bro that is consistently open (because on flank) and often ahead of the pack was never targeted.
turtle225 Sep 28, 2022 @ 9:31am 
I updated the original post with another round of testing. It does seem like the AI likes shooting interior bros.

Originally posted by Edmund Greyfox:
It does seem odd that they are ignoring "easy kills" like guys with no armor or only 1 hit point though. My experience in normal play has been that if a bro gets low on HP/armor and i move him to the back line that every AI archer on the field goes after him in the next round. Only thing i can think of is that the AI might be looking at the percentage of max hit points/armor, which would make someone with only 1 hit point look like they were at 100% health.

I've seen the same thing, they definitely like targeting near-death bros, and someone who checked the code even confirmed that it gives them a high weighting in their targeting behavior.

But I agree that you're probably right in that it is checking for % missing hp, rather than a raw number of low hp, so the game probably does think the 1/1 hp guy is "healthy" and not near-death.

Originally posted by Oceon:
One Tooltip says that rangers are bound to hit if they fire into a group of targets. Maybe thats a value they rely on?

Yes, upon the new round of testing this seems likely.

Originally posted by Dixie Normus:
The side-bro thing explains why my Fencer is no pincushion. I was seriously wondering why a bro that is consistently open (because on flank) and often ahead of the pack was never targeted.

It does seem like isolating a guy makes him less likely to be targeted.
Cat® Sep 28, 2022 @ 9:38am 
The same way it values scatter potential it might value other aoe abilities (such as banner) equivalently highly. There might also be a fairly straight-forward and understandable weighting system but it's obfuscated through seeded additional random weighting - to better simulate it picking targets intelligently.

What exactly that seeded weight is, or what the hitherto unknown dimension is; that's the million dollar question.
turtle225 Sep 28, 2022 @ 9:41am 
Originally posted by Cat®:
The same way it values scatter potential it might value other aoe abilities (such as banner) equivalently highly.

I had a thought as well that they might be targeting the Banner because of the passive aura ability, but I tried replacing his Banner with a regular Pike in a couple of tests and it didn't change how the AI reacted, so I don't think they are factoring that in.
Oceon Sep 28, 2022 @ 9:45am 
Originally posted by turtle225:
Originally posted by Cat®:
The same way it values scatter potential it might value other aoe abilities (such as banner) equivalently highly.

I had a thought as well that they might be targeting the Banner because of the passive aura ability, but I tried replacing his Banner with a regular Pike in a couple of tests and it didn't change how the AI reacted, so I don't think they are factoring that in.


The most notable thing In my runs that I realised (Lone Wolf, Ironman) Is that they often target the middle one of my early 3 guy group. So I BET its a group thing that ads up in their target value.

Another thing I realised is 2 handed vs 1handed. Maybe its bound to the damage output one bro can potentially deal to them, and thats why they target those guys?

What they usually never/very rarely aim at are dogs for example. But a bundle of peasants goes usually through their meatgrinder of arrows.
Cat® Sep 28, 2022 @ 11:28am 
Maybe reach-weapons are weighted more highly? Either because to the AI's evaluation the reach is a deciding factor, or it is simply set to weight reach weapons higher due to the high probability of them being priority targets.

I would imagine they do not target low ranged def on a scale because 1) it'd be really farking* unfun to play and 2) the developers wanted the archers to seem plausible from the character's perspesctive; it is plausible a bandit or arbalester would target, for example, pikemen first.

With how much time goes into doing the testing to figure this out, I suppose there's always sending Overhype an email. Any programmer I've ever known has been above average interested in explaining their thought process and solutions.

*Edited to swear thematically
Last edited by Cat®; Sep 28, 2022 @ 11:29am
Tlewnipla Sep 28, 2022 @ 1:33pm 
By my own observation in "normal" fights I can add that the AI definately does ignore rdef bonuses from shields. My lowest rdef bro gets a kite shield against ranged and (being not an edge bro) gets shot at 95% of the time even if the bro next to him has 15rdef less.
Estieukua Sep 28, 2022 @ 1:48pm 
I've certainly noticed in normal play that they all tend to mega-prioritize attacking anyone who's near-death, even if you surround him with easy-to-hit targets and put him in Shieldwall.

Possibly the AI ignores anyone who begins battle completely naked, because they assume that it's just bait to distract them from more valued targets?

If the AI considers the ratio of HPs versus total armour (as was suggested somewhere above), maybe re-try the test using someone with few HPs and no body armour but still some head armour (and/or try it using someone with highly damaged head+body armour and a few HPs) ...
Edmund Greyfox Sep 28, 2022 @ 3:54pm 
Originally posted by Estieukua:
I've certainly noticed in normal play that they all tend to mega-prioritize attacking anyone who's near-death, even if you surround him with easy-to-hit targets and put him in Shieldwall.

Possibly the AI ignores anyone who begins battle completely naked, because they assume that it's just bait to distract them from more valued targets?

If the AI considers the ratio of HPs versus total armour (as was suggested somewhere above), maybe re-try the test using someone with few HPs and no body armour but still some head armour (and/or try it using someone with highly damaged head+body armour and a few HPs) ...

What i was suggesting was that the AI may be looking at the percentages for both health and armor. If a guy has only 1 hit point and 0 armor the game may be looking at it as them being at 100% of their current max on both, while if someone has 10/100 hit points and 10/100 armor the game is going to look at them both being at only at 10% of their max and mark that bro as an "easy kill" priority target. I don't know if it's true, but it might explain why the AI wasn't favoring his naked bro with 1 hit point as a target over his normal bro.
< >
Showing 1-15 of 27 comments
Per page: 1530 50

Date Posted: Sep 27, 2022 @ 8:40pm
Posts: 27