AI passive when surrounded

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
User avatar
doofus-01
Art Director
Posts: 4122
Joined: January 6th, 2008, 9:27 pm
Location: USA

AI passive when surrounded

Post by doofus-01 »

In BfW 1.11.7, the AI gets passive if it is surrounded, and won't attack when retaliation possible, no matter how feeble.

An example:

In first scenario of HttT (so, no UMC pollution), create a Yeti and give to side 2. Surround on six sides with some crappy unit with melee attack, like a bat. Leave the bats as side 1. End turn. Yeti does nothing. Next time, move one of the bats. Now the Yeti will move, then attack.

If you had used a fire dragon instead of a yeti, the AI would have used fireballs on the bats. If you had used something with ranged & melee attacks, instead of bats, the AI dragon wouldn't do anything when surrounded.

Reported in Gna: http://gna.org/bugs/index.php?21334
BfW 1.12 supported, but active development only for BfW 1.13/1.14: Bad Moon Rising | Trinity | Archaic Era |
| Abandoned: Tales of the Setting Sun
GitHub link for these projects
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: AI passive when surrounded

Post by mattsc »

Wow, this is a good one. Apparently, it has been around since the RCA AI was introduced in Wesnoth 1.7. Well, I don't actually know that for sure, but I tested it with Wesnoth 1.8.4 in an MP game where you can choose between the old default AI and the RCA AI (which is now the default). The bug occurs with the RCA AI, but not with the old default AI.

This should be fixed in commit e7f17412378bd81d2c89c0f391d97894c2cc80d2 and should work correctly in Wesnoth 1.11.8.

And for those interested in the underlying reason, the attack rating contains a multiplicative factor "support", which is (roughly speaking) the "power" other AI units can provide to help the attacking AI unit. For a surrounded unit, no other AI unit can get there, support is zero, and thus the attack rating is zero. This meant that the unit never attacked (attack rating >0 is required for that). I changed that by only multiplying by support if the unit is not surrounded (there are already some other exceptions when it's also not done).
Post Reply