Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
New Server | HOMM1: info forum | HOMM2: info forum | HOMM3: info forum | HOMM4: info forum | HOMM5: info forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Library of Enlightenment > Thread: AI's skill priorities
Thread: AI's skill priorities This thread is 2 pages long: 1 2 · NEXT»
phoenix4ever
phoenix4ever


Supreme Hero
Heroes is love, Heroes is life
posted October 09, 2018 09:07 AM

AI's skill priorities

A human player which has played the game a couple of times knows that skills like Logistics, Offense and Earth Magic are always great skills to have, but what about AI? Does it also prioritize those skills or is it all random? It seems to me like AI always has Ballistics, (makes sense since most classes have high chance to learn the skill) but never Eagle Eye for example. What about the magic schools, does it for example like Earth better than Fire or is it all random?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
zmudziak22
zmudziak22


Famous Hero
posted October 09, 2018 11:44 AM
Edited by zmudziak22 at 11:44, 09 Oct 2018.

i think ai pick random skills when they level up.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
bloodsucker
bloodsucker


Legendary Hero
posted October 09, 2018 12:20 PM

I agree, for all I've seen AI picks skills randomly. I've found many heroes without Wisdom and some magic heroes without any magic school. If exceptions apply to AI as I believe so, this wouldn't happen if it had any kind of priorities.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 12:33 PM
Edited by AlexSpl at 12:34, 09 Oct 2018.

AI doesn't pick secondary skills randomly, but based on skill values, which are not just constants. I may describe the AI secondary skill choice algorithm later in this thread.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
phoenix4ever
phoenix4ever


Supreme Hero
Heroes is love, Heroes is life
posted October 09, 2018 12:40 PM

@Alex Sounds interesting, would be happy to learn about it.
What about Conflux' Magic University and other Universities?, I suspect AI don't choose skills randomly here, but I don't know exactly how it works.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 01:39 PM
Edited by AlexSpl at 13:43, 09 Oct 2018.

In short, AI evaluates all 28 secondary skills first. Then picks the right offered secondary skill if it's among (8 minus number_of_already_occupied_secondary_skill_slots) of most valued skills. Otherwise AI picks the left offered secondary skill.

What may be interesting indeed is how those values are calculated, and how AI, thus, prioritize secondary skills.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
bloodsucker
bloodsucker


Legendary Hero
posted October 09, 2018 01:44 PM
Edited by bloodsucker at 13:45, 09 Oct 2018.

Thanks, I knew this could become interesting... Please, don't forget to get in detail.

Too late.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
bloodsucker
bloodsucker


Legendary Hero
posted October 09, 2018 01:49 PM

There is already a list of those values?
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
NimoStar
NimoStar


Promising
Supreme Hero
Modding the Unmoddable
posted October 09, 2018 02:38 PM

I always assumed it was random too. Pretty interesting info.
____________
Discover H4 Greatest Mod!
https://www.moddb.com/mods/greatest-mod/downloads
(Also biggest of only two 2 mods for HOMM IV)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
bloodsucker
bloodsucker


Legendary Hero
posted October 09, 2018 02:45 PM
Edited by bloodsucker at 14:46, 09 Oct 2018.

AlexSpl said:
AI doesn't pick secondary skills randomly, but based on skill values, which are not just constants.


Sorry, I see you already stated values are not constants.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 02:57 PM
Edited by AlexSpl at 15:07, 09 Oct 2018.

Quote:
There is already a list of those values?

No, they are not constants. Many secondary skill values depend on hero's army power (modified sum of AI_Values; is proportional to 1000 + Army_Power). The stronger army hero has, the higher value of secondary skill is. And some skill values depend on other factors. For example, the value of such a skill as Archery only depends on how many ranged units are in hero's army (is proportional to 500 + Ranged_Units_Power). I'll write all the formulas later.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 03:55 PM bonus applied by Maurice on 12 Oct 2018.
Edited by AlexSpl at 16:32, 19 Oct 2018.

0. Pathfinding
Value = [(1000 + Army_Power) * k / 4], where
k = number_of_passable_penalty_terrain_tiles / number_of_all_passable_tiles, for Basic Pathfinding;
k = number_of_passable_tiles_with_penalty_greater_than_125 / number_of_all_passable_tiles, for Advanced Pathfinding;
k = number_of_passable_tiles_with_penalty_greater_than_150 / number_of_all_passable_tiles, for Expert Pathfinding.

1. Archery
Value = [(500 + Ranged_Units_Power) * k], where
k = 16, for Basic Archery;
k = 7, for Advanced Archery;
k = 11, for Expert Archery.

2. Logistics
Value = [(1000 + Army_Power) * 1/10]

3. Scouting, 12. Necromancy, 21. Learning
Value = [(1000 + Army_Power) * 1/20]

4. Diplomacy
Value = [(1000 + Army_Power) * 1/100]

5. Navigation
Value = [(1000 + Army_Power) * k / 2], where
k = number_of_passable_water_tiles / number_of_all_passable_tiles.

6. Leadership, 9. Luck, 19. Tactics
Value = [(1000 + Army_Power) *  1/50]

7. Wisdom
Value = [the_strongest_spell_efficiency_delta(1, 1, 0, 0, 0, 0, 0) * SpellPower * 1/2]
Note: here the first 1, as an argument, means +1 to raw Spell Power, and the second 1 means +1 to raw Spell Power, modified by artifacts. See remarks in the end of this post.

8. Mysticism
Value = [the_strongest_spell_efficiency_delta(0, 0, 30, 0, 0, 0, 0) * 1/10]
Note: 30, as an argument, means +30 to Mana Points here. See remarks in the end of this post.

10. Ballistics
Value = [(1000 + Army_Power) * 1/8]

11. Eagle Eye
Value = [the_strongest_spell_efficiency_delta(1, 1, 0, 0, 0, 0, 0) * 1/5],
if a hero has Wisdom, otherwise 0.

14. Fire Magic
Value = the_strongest_spell_efficiency_delta(0, 0, 0, 1, 0, 0, 0)

15. Air Magic
Value = the_strongest_spell_efficiency_delta(0, 0, 0, 0, 1, 0, 0)

16. Water Magic
Value = the_strongest_spell_efficiency_delta(0, 0, 0, 0, 0, 1, 0)

17. Earth Magic
Value = the_strongest_spell_efficiency_delta(0, 0, 0, 0, 0, 0, 1)

18. Scholar
Value = [the_strongest_spell_efficiency_delta(1, 1, 0, 0, 0, 0, 0) * SpellPower * 1/5],
if a hero has Wisdom, otherwise 0;

20. Artillery
Value = 10 * Attack,
if a Ballista is equipped, otherwise 0.

22. Offense, 23. Armorer
Value = [(1000 + Army_Power) * 7/100]

24. Intelligence
Value = [the_strongest_spell_efficiency_delta(0, 0, 30, 0, 0, 0, 0) * Knowledge * 1/4]

25. Sorcery
Value = [the_strongest_spell_efficiency_delta(1, 1, 0, 0, 0, 0, 0) * SpellPower * 1/20]

26. Resistance
Value = [(1000 + Army_Power) * 1/40]

27. First Aid
Value = 250,
if a First Aid Tent is equipped, otherwise 0.

Note: use max(1, min(SpellPower, 99)), max(1, min(Knowledge, 99)), max(0, min(Attack, 99)) for computations.

* * *
the_strongest_spell_efficiency_delta() is quite a complex function* which operates with the AI_Values of spells. In short, it calculates the difference between:

a) the efficiency ("power") of the strongest spell, currently known to a hero,

and

b) the potential efficiency of the strongest spell with an offered secondary skill.

In general, it may be two different spells, and also the difference cannot be less than 10.

------------
* The simplest formula for a spell efficiency is

spell_efficiency = [Army_Power * Spell_AI_Value * k],
if a hero can cast a spell at least once, otherwise 0; where

k = 0.009 + 0.001 * sqrt([Max_Mana_Points / Spell_Mana_Cost])

It works for some adventure spells such as Summon Boat, Fly, Water Walk, Dimension Door, Town Portal, and also for Earthquake.

Other fomulas might be quite cumbersome. For example, for such spells as Resurrection, Animate Dead, Hypnotize, Fire/Earth/Water/Air Elemental the following formula is used:

spell_efficiency = [Army_Power * Spell_AI_Value * k],
if a hero can cast a spell at least once, otherwise 0; where

k = max(3.9, ScaleFactor(max(13, [Max_Mana_Points / Spell_Mana_Cost])) * max(0.9, 10 * (Raw_Spell_Power + Effective_Magic_School_Level) / Army_Power))

ScaleFactor(N) =
N = 0: 0.00, N = 1: 0.83, N = 2: 1.53, N = 3: 2.11, N = 4: 2.59,
N = 5: 2.99, N = 6: 3.33, N = 7: 3.60, N = 8: 3.84, N = 9: 4.03,
N = 10: 4.19, N = 11: 4.33, N = 12: 4.44, N = 13: 4.53


Some more info:

AI doesn't use the following spells: Scuttle Boat, Visions, View Earth, Disguise, View Air, Quicksand, Land Mine, Force Field, Fire Wall, Sacrifice, Forgetfulness, Remove Obstacle. Their efficiencies are always 0.

The efficiencies of level 3-5 spells are 0 if Recanter's Cloak is equipped.

The efficiency of Titan's Lightning Bolt is always 1 (probably a bug).

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
NimoStar
NimoStar


Promising
Supreme Hero
Modding the Unmoddable
posted October 09, 2018 04:43 PM

Interesting than diplomacy has lower value than Learning (and less army size dependent), I guess the AI is actually dumber than random
____________
Discover H4 Greatest Mod!
https://www.moddb.com/mods/greatest-mod/downloads
(Also biggest of only two 2 mods for HOMM IV)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 06:05 PM

Quote:
I guess the AI is actually dumber than random

This is how it's intended to be. Players should be satisfied No one would play the game where you cannot beat the AI. Look at chess. To beat a modern professional chess AI is quite an achivement, I'd say.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
phoenix4ever
phoenix4ever


Supreme Hero
Heroes is love, Heroes is life
posted October 09, 2018 06:40 PM

@Alex Not that I don't believe you, but where do you have those formulas from? (source?)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 06:44 PM

Yes. You can check it yourself, for example, with LMOracle.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
phoenix4ever
phoenix4ever


Supreme Hero
Heroes is love, Heroes is life
posted October 09, 2018 06:57 PM

Okay, thanks.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
AlexSpl
AlexSpl


Responsible
Supreme Hero
posted October 09, 2018 07:28 PM
Edited by AlexSpl at 20:30, 09 Oct 2018.

How to check? For example, you can play with Basic Pathfinding. The formula for Basic Pathfinding is

Value = [(1000 + Army_Power) * k / 4],
where k = number_of_passable_penalty_terrain_tiles / number_of_all_passable_tiles*

* For example, for a simple 36x36 map with two castles and with no underground level, k = number_of_passable_penalty_terrain_tiles / (36 * 36 - 2 * 12).

Draw a map with no penalty terrain. Find a hero/tree where you offered Basic Pathfinding as a new skill (in the right slot) at level-up with LMOracle. See which skill AI picks when there are no penalty terrain tiles on a map (it will never pick Basic Pathfinding). Then gradually increase the number of penalty terrain tiles, and you will eventually see that AI prefers Basic Pathfinding secondary skill over the left one.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
bloodsucker
bloodsucker


Legendary Hero
posted October 10, 2018 01:44 PM

Thx.
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
NimoStar
NimoStar


Promising
Supreme Hero
Modding the Unmoddable
posted October 10, 2018 09:34 PM

Quote:
This is how it's intended to be. Players should be satisfied No one would play the game where you cannot beat the AI. Look at chess. To beat a modern professional chess AI is quite an achivement, I'd say.


Not to nitpick or anything, but that is NOT intended. Plus millions of dollars and decades of work went into having a good chess AI. Whereas with Heroes AI probably a single guy with little playtesting did it in a couple months being paid a mediocre wage :V
____________
Discover H4 Greatest Mod!
https://www.moddb.com/mods/greatest-mod/downloads
(Also biggest of only two 2 mods for HOMM IV)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 2 pages long: 1 2 · NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0650 seconds