How about promotion check for AI?

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
roman_sharp
Posts: 22
Joined: July 11th, 2010, 8:01 am

How about promotion check for AI?

Post by roman_sharp »

Once I saw a foolish death of friendly unit close to promotion.

It has low HP, XP only one point below promotion, and was close to 3 enemy units. Instead of attacking one of them with lowest risk of death (range attack against weak with this type of attack unit) and getting promoted, it attacked strong unit and perished.

I think it wouldn't be hard to add 'promotion check' to code.
batoonike
Posts: 75
Joined: January 3rd, 2009, 8:14 pm

Re: How about promotion check for AI?

Post by batoonike »

How much AI values his own unit compared to dealing damage to enemy is different in different scenarios. Sometimes AI has 0 value of its own unit and always tries to maximize damage, which might be the case of attacking and dying over attacking and leveling up.
roman_sharp
Posts: 22
Joined: July 11th, 2010, 8:01 am

Re: How about promotion check for AI?

Post by roman_sharp »

I found this strange, because imho leveled up unit eventually would deal more damage to enemy.
batoonike
Posts: 75
Joined: January 3rd, 2009, 8:14 pm

Re: How about promotion check for AI?

Post by batoonike »

Guess the AI doesnt think very far ahead when it comes to planning damage. It would make sense since the possible options on a 20x20 map with 30 units are rather high in even 2 turn perspective.
User avatar
Crab
Inactive Developer
Posts: 200
Joined: March 18th, 2009, 9:42 pm

Re: How about promotion check for AI?

Post by Crab »

The AI already tries to consider promotions. see src/ai/default/attack.cpp , note how avg_losses is computed
Possible variants :
1) There are bugs in existing code which cause the situations like 'low hp unit which can advance' to be undervalued.
2) There are bugs in existing code which cause the AI to do attacks in suboptimal order (e.g. killing the enemy unit directly when there was a chance to farm it for XP before)
3) aggression was set too high, distorting the main attack evaluation formula

Code: Select all

 double value = chance_to_kill*target_value - avg_losses*(1.0-aggression);
(note, how, with increasing aggression>0 (btw, default is 0.4), AI cares less and less about its own losses and promotions, trying to maximize CtK. )
roman_sharp
Posts: 22
Joined: July 11th, 2010, 8:01 am

Re: How about promotion check for AI?

Post by roman_sharp »

Thanks for your time and the explanations. I found savegame for the case I'm talking about, but can't reproduce the unfortunate unit end now (hmmm... I could swear I reproduced it once before).

The units in question are the Elf Scout at 5,16, and two Goblin Knights and Orcish Assassin next to Scout. The Elf Scout can attack either of Goblin Knights by ranged attack and get promoted safely (they don't have ranged attack), but it attacks Assassin, what is risky - and he don't have any chance to kill the Assassin that way.
Attachments
logic.gz
Savegame to topic
(73.46 KiB) Downloaded 234 times
User avatar
Crab
Inactive Developer
Posts: 200
Joined: March 18th, 2009, 9:42 pm

Re: How about promotion check for AI?

Post by Crab »

thanks for the save, it would allow me to check this out.
Post Reply