Chosen type of attack
Moderator: Forum Moderators
Chosen type of attack
Hi all, I was just wondering. How does the game pick the type of attack when there are more then one available? For example you can attack ranged or melee, or cold damage with three strikes while there is fire damage with two strikes. When the fire damage does a lot more damage per strike but not more then the three cold strikes combined it could mean a bigger chance to die. And the same goes for the ranged or melee choice. Does it go for more damage or higher chance to kill/lower chance to die?? I know for sure the game isnt always making the best choice!
Re: Chosen type of attack
AFAIK in campaigns, this is dependant on how people have told the AI to attack.
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
Re: Chosen type of attack
I think it works as follows: If your unit has a chance to die, the recommended attack is the one with the lowest chance to die. Otherwise, if your unit has a chance to kill, the recommended attack is the one with the highest chance to kill. Otherwise, the recommended attack is the one with the highest average expected damage, with retaliatory damage not taken into consideration.
Re: Chosen type of attack
That's pretty close, but not quite. The AI simulates attacks with all weapons of the attacker. It considers an attack better than another according to these criteria:Caphriel wrote:I think it works as follows: If your unit has a chance to die, the recommended attack is the one with the lowest chance to die. Otherwise, if your unit has a chance to kill, the recommended attack is the one with the highest chance to kill. Otherwise, the recommended attack is the one with the highest average expected damage, with retaliatory damage not taken into consideration.
- Calculate (chance of enemy unit to die) - (chance of own unit to die) * (1 - aggression). Choose the attack with the larger value. If equal, go on to B.
- Calculate difference between (average hitpoints after attack - loss due to chance of being poisoned) of own unit [ *(1 - aggression) ] and enemy unit. Again, choose the weapon which gives the better result. If equal, go on to C.
- Choose weapon which does the most damage to enemy.
aggression = 1
means that damage to the AI's own unit is ignored, and only damage to the enemy unit is taken into consideration.EDIT: I should add that this is only the algorithm for choosing the best weapon for a fixed attacker/defender pair. The method of choosing the best attack from all possible attackers and defenders is quite a bit more complex.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Chosen type of attack
I'm pretty sure he was asking about the attack that gets recommended by the game when the player attacks an enemy unit, not which attack the AI-controlled sides select when they make an attack. I may have misunderstood, though.
Re: Chosen type of attack
Ah, yes, I might have misinterpreted that. I checked out the source code for the attack dialog, and it uses that same function, but with a hard-coded value of 0.5 for aggression.Caphriel wrote:I'm pretty sure he was asking about the attack that gets recommended by the game when the player attacks an enemy unit, not which attack the AI-controlled sides select when they make an attack. I may have misunderstood, though.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: Chosen type of attack
Thanks That is good to know.
Re: Chosen type of attack
Thanks for the info all!!
Re: Chosen type of attack
I attempted to rewrite your statement in a bit simpler language:
First consider only the chance to kill and chance to die, with chance to kill given twice the weight of chance to die.
Next consider only the expected damage to enemy and expected damage to self, with damage to enemy given twice the weight of damage to self.
Finally, with all else being equal, just choose the weapon that grants the highest expected damage to enemy.
First consider only the chance to kill and chance to die, with chance to kill given twice the weight of chance to die.
Next consider only the expected damage to enemy and expected damage to self, with damage to enemy given twice the weight of damage to self.
Finally, with all else being equal, just choose the weapon that grants the highest expected damage to enemy.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Chosen type of attack
You forgot about caution and aggression in case of the ai being in control.Sapient wrote:I attempted to rewrite your statement in a bit simpler language:
First consider only the chance to kill and chance to die, with chance to kill given twice the weight of chance to die.
Next consider only the expected damage to enemy and expected damage to self, with damage to enemy given twice the weight of damage to self.
Finally, with all else being equal, just choose the weapon that grants the highest expected damage to enemy.