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 ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 5 - Modders Workshop > Thread: New (unofficial) patch for ToE / AI mod
Thread: New (unofficial) patch for ToE / AI mod This thread is 42 pages long: 1 2 3 4 5 ... 10 20 30 ... 38 39 40 41 42 · «PREV
Quantomas
Quantomas


Responsible
Famous Hero
AI Wizard
posted May 18, 2020 01:52 PM
Edited by Quantomas at 14:22, 18 May 2020.

There seem to be quite a few misunderstandings what you can do with scripts for AI.

What New World Computing programmed for Heroes III and what is also in the vanilla H5, is a system that evaluates every tile a hero can visit. Beginning with the start position, it spirals out tile over tile, computing the possible ways a hero can reach to arrive at a tile. In Heroes III it was done for a three-turn-lookahead. H5 tried a fourth turn, but at that point the costs grow exponentially, making the process very slow.

This is not a sophisticated lookahead, but for H3 it worked marvellously, mostly because NWC did an outstanding job at balancing with mathematical tools. In principle it requires to keep in memory all the tiles of the map on all floors, plus all the information that needs tracking. There is basic information like the terrain type, the movement cost, what interactive objects are triggered, what resources are there. Plus more advanced information like what did the hero do to arrive at the tile, how much movement cost did it require, what other heroes can access the tile, what threats are there.

In C++ you can optimize this sufficiently to make it work on a regular PC, if you have the manpower. If you would like to do the same with scripts, just try to assemble all the information required for each tile on the map, it would take days for a single turn to process.

If you ask me what the modifiers in the .pak files do, they were most likely introduced to adjust the AI behaviour on specific maps shown in demos at expos. There is code that deals with features needed to do a Heroes V demo at E3 back in the day.

These modifiers were probably also used to test the raw balance of the game. In hindsight I'd say, Nival would have done better to remove these modifiers from the xdb, because then modders wouldn't have the impression that these are useful for tweaking the AI. They are not.

The new AI doesn't use these modifiers. They might still have an impact on functions that I hadn't the time to upgrade, like for example the code for hiring heroes.

To answer your question, naturally the hiring of heroes by the AI should be addressed properly by looking at the value that hiring a new hero has. This requires lookahead as well. The value of a secondary hero at the beginning for example is higher because the troops the hero carries can bolster your main. It also depends on how many resources there are in the vicinity, or whether they are needed at all. If there is an unguarded keymaster tent three turns travel distance away, but your main is busy clearing the area before the gate that is unlocked by it, then a secondary hero may have tons of value. The same goes for multiple heroes.

The new AI (3.2) will do this properly. Technically it converts the values of actions, like collecting a specific resource, into a lookahead value that reflects how much this action improves the power of your faction. Collecting recruits are an obvious example, collecting gold aids this, and a secondary hero can perform this. This is what lookahead is for.

Regarding 3.1k the last thing before the beta can hit the road and that I implement right now, is a partial implementation of these lookahead values. This should upgrade the AI behaviour a lot. How much I can already do to control the hiring of heroes needs to be seen. But for 3.2 that's definitely the plan, because otherwise you can't synchronize what all your heroes do. They should cooperate, shouldn't they?
____________
Will the TBS genre evolve? Yes!

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


Famous Hero
posted May 18, 2020 11:12 PM

Quantomas said:
There seem to be quite a few misunderstandings what you can do with scripts for AI.

What New World Computing programmed for Heroes III and what is also in the vanilla H5, is a system that evaluates every tile a hero can visit. Beginning with the start position, it spirals out tile over tile, computing the possible ways a hero can reach to arrive at a tile. In Heroes III it was done for a three-turn-lookahead. H5 tried a fourth turn, but at that point the costs grow exponentially, making the process very slow.

This is not a sophisticated lookahead, but for H3 it worked marvellously, mostly because NWC did an outstanding job at balancing with mathematical tools. In principle it requires to keep in memory all the tiles of the map on all floors, plus all the information that needs tracking. There is basic information like the terrain type, the movement cost, what interactive objects are triggered, what resources are there. Plus more advanced information like what did the hero do to arrive at the tile, how much movement cost did it require, what other heroes can access the tile, what threats are there.

In C++ you can optimize this sufficiently to make it work on a regular PC, if you have the manpower. If you would like to do the same with scripts, just try to assemble all the information required for each tile on the map, it would take days for a single turn to process.

If you ask me what the modifiers in the .pak files do, they were most likely introduced to adjust the AI behaviour on specific maps shown in demos at expos. There is code that deals with features needed to do a Heroes V demo at E3 back in the day.

These modifiers were probably also used to test the raw balance of the game. In hindsight I'd say, Nival would have done better to remove these modifiers from the xdb, because then modders wouldn't have the impression that these are useful for tweaking the AI. They are not.

The new AI doesn't use these modifiers. They might still have an impact on functions that I hadn't the time to upgrade, like for example the code for hiring heroes.

To answer your question, naturally the hiring of heroes by the AI should be addressed properly by looking at the value that hiring a new hero has. This requires lookahead as well. The value of a secondary hero at the beginning for example is higher because the troops the hero carries can bolster your main. It also depends on how many resources there are in the vicinity, or whether they are needed at all. If there is an unguarded keymaster tent three turns travel distance away, but your main is busy clearing the area before the gate that is unlocked by it, then a secondary hero may have tons of value. The same goes for multiple heroes.

The new AI (3.2) will do this properly. Technically it converts the values of actions, like collecting a specific resource, into a lookahead value that reflects how much this action improves the power of your faction. Collecting recruits are an obvious example, collecting gold aids this, and a secondary hero can perform this. This is what lookahead is for.

Regarding 3.1k the last thing before the beta can hit the road and that I implement right now, is a partial implementation of these lookahead values. This should upgrade the AI behaviour a lot. How much I can already do to control the hiring of heroes needs to be seen. But for 3.2 that's definitely the plan, because otherwise you can't synchronize what all your heroes do. They should cooperate, shouldn't they?



Thank you - this is an excellent answer to my question!  I AM looking forward to this new AI...the current one is beginning to irk me with its dumbness.  




Related but unrelated - you had mentioned maybe a couple pages ago that there's quite a difference between a Heroes game where caravans don't exist (H3) and a Heroes game where they do (H5).  In Heroes 3, I could easily have 8 Heroes running around doing various tasks, but the majority of them would be tagging dwellings (especially because the creatures would disappear if you didn't get them before week's end), getting water wheels, and so on, on rotation every week.  Obviously, in Heroes 5, the need for Heroes to tag dwellings is unnecessary short of occasionally stealing them back if an opponent takes them.  However - Windmills and Waterwheels still need tagging and would require "runners" as I would call them.  Heroes 5.5 solves this problem too by having the automatic system by paying 1000 gold to "flag" it by script - although you can steal from your ally and AI players steal from me regularly if I'm an ally.

My point is - Heroes 5 has considerably less demand for "runners" of this style - and I half wonder if an implementation of the Heroes 5.5 flagging for Windmills, Waterwheels, and Leprechauns would be worthwhile in the upcoming AI just to make things more smoothe.

For my part however, I just design my maps without Windmills, Leprechauns, or Waterwheels - Dwarven Warrens do the job just fine and it's less of a mess.

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


Responsible
Famous Hero
AI Wizard
posted May 19, 2020 01:45 PM

In principle once the secondary heroes "know" what they are doing, the issue becomes obsolete.

Regarding the micromanagement of visiting windmills, I guess that was what Magnomagus had in mind while designing this feature. Of course if you design such a feature without the AI in mind you create more issues than you solve, at least if you see HoMM as a strategy game.

In general I like to respect the original vision, if there are windmills in it, they are a part of the game, unless they are somehow diminishing the game. That doesn't mean that every map has to have them. There are possible solutions like tying the weekly income from windmills to the nearest town. Then the miller would have to respond accordingly if you visit a windmill not on your territory.

____________
Will the TBS genre evolve? Yes!

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


Famous Hero
posted May 23, 2020 02:52 PM

Quantomas said:
In principle once the secondary heroes "know" what they are doing, the issue becomes obsolete.

Regarding the micromanagement of visiting windmills, I guess that was what Magnomagus had in mind while designing this feature. Of course if you design such a feature without the AI in mind you create more issues than you solve, at least if you see HoMM as a strategy game.

In general I like to respect the original vision, if there are windmills in it, they are a part of the game, unless they are somehow diminishing the game. That doesn't mean that every map has to have them. There are possible solutions like tying the weekly income from windmills to the nearest town. Then the miller would have to respond accordingly if you visit a windmill not on your territory.



Personally I think the best solution would be a collaboration between mapmakers and the AI - that is, not including Windmills, Water Wheels, etc on the map - the AI has enough things to think about without visiting 1 Windmill and 1 Waterwheel per week, and it just seems like a drag on the human player as well for such a small thing to do.

That said, I do think that Magnomagus's instinct was the correct one - the transition to Caravans was "incomplete" without including Windmills etc as well.  But indeed - without having a mechanism for the AI to respond properly to the new scripts, it will be a mess, and I'm not sure how worth it it is to do more coding just to accomodate this.

Consequently in the end we would have maps without Windmills, ideally - in my opinion.  I respect the idea of respecting the original vision...but I think I can say with confidence that whatever the original vision was, it needs to be put in perspective of how the AI was incomplete, the game balance was incomplete, etc...so I don't feel bad "tweaking" the vision ever so slightly (ever so slightly) if it generally makes the game better at an extremely minimal loss.  I'm playing maps without Windmills right now, and I simply do not miss them - it's fine.

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


Promising
Known Hero
posted May 30, 2020 04:05 PM

I would like to make a suggestion, I do not know if it would be feasible. One is about the theme of town portal .... what if you include the characteristic of the water eddies and you lose a% of the army?

And the other feature that could boost the strategy quite a bit ... could caravans be added to mills and mines? The mines would produce their resources, but they would have to go through them to collect them, or send them to a city in caravans. With this, it opened that always keep the path clear, caravans could be attacked and resources stolen from another player and it would be a disadvantage to have mines away.

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


Famous Hero
posted May 30, 2020 08:30 PM

Hi Quantomas,

Hope you don't mind the constant intercessions, but a couple notes that have come to mind after playing some more games and making observations.

1.  Double towns.  While some maps have a single town per player and that's it, other maps will have an "expansion" town readily available to take for each player.  I myself am sometimes undecided about how I want to invest in the second town because there are so many different factors at play.  Sometimes every piece of wood, ore, and gold is necessary immediately.  At the very least, though - I try to get a Town Hall to upgrade the town to 1000 gold per day and make it profitable; I may wait a while and save my Wood and Ore (in particular) for my main town until I generate a surplus enough to get a City Hall.  Then - and only then - do I really start investing in all the other buildings in the town, if at all (perhaps I can't afford two towns' worth of recruits, so there's no point in bothering).  I might very well upgrade the Mage Guild, though, and basic spawns.

Something to note here is that if these are two towns of the same type that are relatively close to one another, I make a point of not upgrading to the upgraded creature tier buildings in the second town - because I can just use Caravans to ferry the creatures from Town 2 to Town 1 to be upgraded - just as if Town 2 was a massive external dwelling.  I'm not sure the AI presently appreciates the nitty-gritty of this strategy, and it sure sets it back, because it spends its money needlessly on things that don't need upgrading, or else recruits units in various places and loses movement for no reason.

Of course, if I'm worried about losing a town, I'll spare the caravans and defend it or whatever, or not even bother spending the money.  This is just a note in terms of a design I thought was worth mentioning.


2.  Lookahead depth.  Now that I think of it, I actually need to understand what you mean that the new AI will have a lookahead depth of 21 turns or whatever it was.  I say this because I don't have that kind of lookahead depth - and sure, an AI can calculate more possibilities than I can, but it's not like this game is Chess and all the possibilities are set in stone.  I might have a plan for a whole week - sometimes.  But honestly - most of the time I'm not even sure how far my hero can reach because there might be stuff in the way or things to knock off.  Or an enemy Hero suddenly appears from out of the dark and messes up all my plans.  Or something else happens.  So as I said, I might be able to plan for a week (I don't even have a concept of a 21-day lookahead or even what that means), yet realistically with the enemy's movements, things end up being more like 2 or 3-day plans.  With that said, I'm curious what you mean by a 21-day lookahead, because I'm unsure how an AI or anyone could ever plan such a thing unless it was a really HUGE map and it takes ages to get from anywhere to anywhere.

3.  A note on secondary heroes - that the AI should make some efforts to keep additional troops (that is, 7 or so) on secondary heroes so they don't die instantly because the hero has only 1 unit that is easily killed.  While 7 troops is still killable to be sure - it's much harder.  Finally - while I realize that the combat AI will come later - the AI doesn't retreat if the secondary hero it's about to lose isn't "important" (not levelled or no artifacts) - but it still gives lots of XP if killed, so I always retreat even if my secondary who is dying is meaningless - but I just might not bother re-hiring him...while I would definitely re-hire (and should immediately re-hire) a hero of any kind of importance.


Those are my thoughts for today - thanks!

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


Responsible
Famous Hero
AI Wizard
posted May 31, 2020 01:02 PM
Edited by Quantomas at 13:05, 31 May 2020.

Introducing a feature and then penalizing it, serves what purpose exactly? Unless there is proof that it makes the game better, it will only make the game more difficult to play.

A good strategy game thrives on simple rules that can be applied in a myriad of ways. But simplicity and streamlining are different things.

The caravan system is a good example how an attempt to streamline the game creates more complex issues. Things like the micromanagement that you need to do when a lot of caravans arrive at your castle and there are no creature slots free, or that caravans turn back if a point on its planned path is occupied, like your heroes blocking movement on a bridge, or that you would need to watch out for high value caravans to intercept.

It's more of a headache than a solution.

Something like causing losses for townportal may be worth a consideration for a shatter skill on a campaign map, though.

Gidoza said:

1.  Double towns.  While some maps have a single town per player and that's it, other maps will have an "expansion" town readily available to take for each player.  I myself am sometimes undecided about how I want to invest in the second town because there are so many different factors at play.  Sometimes every piece of wood, ore, and gold is necessary immediately.  At the very least, though - I try to get a Town Hall to upgrade the town to 1000 gold per day and make it profitable; I may wait a while and save my Wood and Ore (in particular) for my main town until I generate a surplus enough to get a City Hall.  Then - and only then - do I really start investing in all the other buildings in the town, if at all (perhaps I can't afford two towns' worth of recruits, so there's no point in bothering).  I might very well upgrade the Mage Guild, though, and basic spawns.

Something to note here is that if these are two towns of the same type that are relatively close to one another, I make a point of not upgrading to the upgraded creature tier buildings in the second town - because I can just use Caravans to ferry the creatures from Town 2 to Town 1 to be upgraded - just as if Town 2 was a massive external dwelling.  I'm not sure the AI presently appreciates the nitty-gritty of this strategy, and it sure sets it back, because it spends its money needlessly on things that don't need upgrading, or else recruits units in various places and loses movement for no reason.

Of course, if I'm worried about losing a town, I'll spare the caravans and defend it or whatever, or not even bother spending the money.  This is just a note in terms of a design I thought was worth mentioning.


2.  Lookahead depth.  Now that I think of it, I actually need to understand what you mean that the new AI will have a lookahead depth of 21 turns or whatever it was.  I say this because I don't have that kind of lookahead depth - and sure, an AI can calculate more possibilities than I can, but it's not like this game is Chess and all the possibilities are set in stone.  I might have a plan for a whole week - sometimes.  But honestly - most of the time I'm not even sure how far my hero can reach because there might be stuff in the way or things to knock off.  Or an enemy Hero suddenly appears from out of the dark and messes up all my plans.  Or something else happens.  So as I said, I might be able to plan for a week (I don't even have a concept of a 21-day lookahead or even what that means), yet realistically with the enemy's movements, things end up being more like 2 or 3-day plans.  With that said, I'm curious what you mean by a 21-day lookahead, because I'm unsure how an AI or anyone could ever plan such a thing unless it was a really HUGE map and it takes ages to get from anywhere to anywhere.

That is exactly what I am currently working on. In order to give mines and resources on the adventure map a proper value, you need to understand their use. And that leads to what you can build in your castles.

It's a tough nut to crack, and it took me a month, but I think this upgrade to the town management is well worth the effort. Like you guys, I rather would like to release 3.1k as soon as possible, but this will make the strategy game much more complete.

In the long run (3.2) the plan is to integrate the town management seemlessly with what your heroes can do on the adventure map.

That's what the lookahead is for. Don't think for a second you are just planning for three days ahead. If you observe an opponent's castle a week's travel away, you implicitly acknowledge the necessary travel turns and the time to prepare a potential attack. For example you will rationalize that your forces for a siege need to be stronger because your opponent has another week of reinforcements.

The same goes for adventure map resources. Surely, you will only survey your immediate vicinity again and again, but if you lack 20 crystals for your T7 building and see a nice stock of crystals five days of travel away, you will consider it in your plans.

And that is why the new resource buildings HotA introduced are great. They work because you see their value and you don't mind visiting them. Which also shines a different light on the previously mentioned issue with windmills. It's possibly not an issue with micromanagement, but rather the question that we are not sure whether it's worth it to visit them.
____________
Will the TBS genre evolve? Yes!

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: Next Thread » This thread is 42 pages long: 1 2 3 4 5 ... 10 20 30 ... 38 39 40 41 42 · «PREV
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0864 seconds