Call to H-IV mapmakers - AI enchancing scripts

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.
User avatar
Dalai
Equilibris Team
Equilibris Team
Posts: 1073
Joined: 06 Jan 2006
Contact:

Call to H-IV mapmakers - AI enchancing scripts

Unread postby Dalai » 15 May 2015, 14:47

Basis for this call is this discussion. Short summary - it is possible to make an automated tool to add scripts to one or many maps of your choosing, that will enhance AI and make maps more challenging and interesting.

If you have made some AI enhancing scripts for your maps and you don't mind other people using and modifying them - please, share them here with description. You can share script text, a map with a single script or a whole map with instructions on how to find it. Or just a description, if you can't find it after your hard drive failed.

If your script does something else, but still makes gameplay interesting - share it too. For example, script that gives your opponent in multiplayer game control over neutral armies on battlefield will be in high demand for some players.

We plan to create a library of AI enhancing scripts and try to make them universal, so they can be added to any map. And create a tool to actually add those scripts to user selected maps.

If you want to warn others that your particular map should not be modified - it's also a good place to do it, we will add it to readme.

Any comments and suggestions are welcome. :)
"Not a shred of evidence exists in favour of the idea that life is serious." Brendan Gill

User avatar
Salamandre
Genie
Genie
Posts: 1032
Joined: 13 May 2006
Location: France
Contact:

Unread postby Salamandre » 15 May 2015, 15:56

I don't know if this can give you some ideas, but here is the "Better AI" mod I did for Heroes III. As you can see, all parameters are modulable to fit every player skill and AI income/growth can go up to +1000%.

A lot of redundant actions which slow a lot AI heroes are granted by default, as always mana at max, obelisks visited, conquered towns are converted to AI first town faction and many more. Therefore AI heroes now spend all their time to explore and fight.

Image

If you are interested I can give you a list of all changes and bonuses AI gets, there are dozens of them. I cannot make AI play "better" because I don"t have access to source code, but I can make him much more effective by eliminating the quirks he overuses and which slow him. At highest level, AI beats me always and I am not bad player.

I don't think AI in H4 is much different, I noticed a lot of passivity but probably is -as in H3- tied to lack of natural bonuses. Translate=effective cheats.

User avatar
Taro
Scout
Scout
Posts: 163
Joined: 11 Feb 2011
Location: Poland

Unread postby Taro » 15 May 2015, 17:12

Good to hear you are going to do such thing. I made a remake of "Conquer of Four Lakes". It's a vanilla map which I remade only in polish. You can download it from here:

http://mapy.heroes.net.pl/mapa/433

Effect is similar to some maps in h3 played on impossible. AI will try to destroy you, especially if you leave a castle. To create such experience you have to:

1. Show entire map for computer players.
In my scenario you can see a thieves placed on different parts of the map. They are prophets with four viewing crystals and Breeze the Falcon to have biggest possible view. In army options there is a triggtered event called "Map for AI". It is activated from time event from game options. It changes owners for other players but only if they are computers. After that thief is neutral once again, he loses artifacts and is defeated by black dragons.
With this AI see all the world and knows were to find other players. Read this article before saying anything:
https://www.celestialheavens.com/695

2. Every player is selected to vital which push AI to conquer.
You can do it with towns and starting heroes as well. I know there is no script about it, it's an option. But if you made Guardian Angel for high level heroes then I think you can also do this. From my testing, with high or vital importance AI hass less chance to get stuned and to do nothing.

3. Every town gives 1000 gold/ day for computer players.
It's for ability to buy more creatures.

4. On day one towns get a weakly growth in all dwellings if owner is computer.
It's important because AI gets too many loses in combats.

5. Every AI hero gets four tactic skills on expert and 10.000 experience.
It's made because AI somehow don't like those skills while they are important. Believe me, it's really hard to fight a large army with tactic hero. This is a placed event in front of towns and continous event in towns.

I advice you to play this map first and get cool experience. And place your comment after AI defeated you .

User avatar
GreatEmerald
CH Staff
CH Staff
Posts: 3330
Joined: 24 Jul 2009
Location: Netherlands

Unread postby GreatEmerald » 15 May 2015, 20:41

Sheesh, this is AI cheating 101. On the other hand, having it all centralised and configurable is much better than having it applied to maps permanently...

User avatar
wimfrits
Round Table Knight
Round Table Knight
Posts: 2047
Joined: 06 Jan 2006
Location: Utrecht, the Netherlands

Unread postby wimfrits » 17 May 2015, 08:44

Dalai wrote:For example, every AI army can triple upon contact with neutrals, and return back to normal after victory. That way AI will not engage in hopeless fights, but will suffer less casualties in fights it actually chooses to engage.
I think this would be excellent! It's not cheating, but merely compensating for AI stupidity. The AI greatly misjudges neutral threat and will easily lose 80% of it's army in encounters a novice player would avoid. Also, the AI does not consider threat areas of mobile guards.
Combined with an automatic POI this would greatly increase survivability.

A better AI interface like Salamandre did would be great. I'd want this internally (mapmaker's eyes only) and tweakable for each difficulty level.

Some other general non-cheating measures:
- give artifacts that can be bought in town to heroes (as AI heroes rarely do)
- increase experience of new AI heroes to compensate for the low priority to visit experience increasing objects
- give skills to new heroes to compensate for not buying skills. Partly randomised logical combinations (tactics + combat, magic + combat, ...) to increase AI hero variety.
All should be dependant on the player's chosen difficulty
Are you suggesting coconuts migrate?

User avatar
Salamandre
Genie
Genie
Posts: 1032
Joined: 13 May 2006
Location: France
Contact:

Unread postby Salamandre » 17 May 2015, 11:16

Be careful with tripling AI fight value before battle then return to normal: I already tried it and is headache to keep track of battle loses. I mean, you must have access to also internal battle rounds codes, so you can keep each round track of what died on AI side then consider it when recalculating the "normal size".

For me (and H3) it was more simple to ensure AI has the right skills, spells and creatures so he can't lose that battle. And even if he loses a lot, weekly growth is sufficient crazy to compensate.

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Unread postby Duzeom_ » 17 May 2015, 11:58

wimfrits wrote: It's not cheating, but merely compensating for AI stupidity.
I think it is cheating. Ideally is to change all neutral armies + 150% during AI turn so that it wouldn't engage in hopeless fights.

User avatar
wimfrits
Round Table Knight
Round Table Knight
Posts: 2047
Joined: 06 Jan 2006
Location: Utrecht, the Netherlands

Unread postby wimfrits » 17 May 2015, 18:24

Salamandre wrote:I mean, you must have access to also internal battle rounds codes, so you can keep each round track of what died on AI side then consider it when recalculating the "normal size".
IF(!) Dalai is able to triple the hero's army, then it should not be a problem to take away that same number of creatures after the fights.

If hero has 40 elves, give 80 elves at start of combat, take 80 elves when combat is over. Any losses would still directly affect the army, but the survivability rate would be more comparable to a human player.
Duzeom_ wrote:I think it is cheating. Ideally is to change all neutral armies + 150% during AI turn so that it wouldn't engage in hopeless fights.
Without help, the AI currently expands at a rate of say 30% of that of an average human player. +150% neutral armies would bring that down to 15%.
Are you suggesting coconuts migrate?

User avatar
Taro
Scout
Scout
Posts: 163
Joined: 11 Feb 2011
Location: Poland

Unread postby Taro » 17 May 2015, 20:08

I don't get why you say "this is cheating! omg!". Yes, this is cheating, but you forgot about the purpose. And what is that purpose? EASILY SWITCHABLE CHALLENGE. We will not get better AI, so that's why we are talk about other reachable solution.

Salamandre made interesting mod indeed. Something like this would be great. Wimfrits also gave us some good options, maybe except giving items. Potions - fine. But not items like plate armor etc. It's because AI doesn't change artifacts for better. You will give a hero chainmail and if he find Dragon Scale Armor he will not change for it.

I think giving exp points everyday to heroes can be good. Tougher heroes will provide more interesting battles. Depending on option/difficulty it can be 200, 400 and 800. Or something like this.

User avatar
Salamandre
Genie
Genie
Posts: 1032
Joined: 13 May 2006
Location: France
Contact:

Unread postby Salamandre » 17 May 2015, 20:58

Here is exactly what my mod does for H3, in order to make AI more challenging (ofc is cheating but the result is similar to what a better player will show you in MP)

AI players will be given each one 3 super heroes and can't recruit more. (I had to limit heroes as they take up to 1 min each when have big armies)

When one dies, he is revived next day, unless that AI player has no town left.

They have all natural combat skills, and each has a randomly selected specialty between offense, armorer and resistance (kick ass). They can move up to 110 tiles every turn (depending on the movement settings you selected) and will enjoy town portal at 15th level + fly at 40.

general settings:

* Gives 30k gold on first day to every AI.
* Set all obelisks to "visited" for every AI.
* AI movement will increase daily by half tile, but no more than 40-60 tiles (4000-6000 mvm points), depending on the difficulty selected. Late recruited AI heroes will start with the bonus, to help leveling faster
* AI heroes are marked, human can't hire them if dead.
* Every day 1 of the week, it places extra creatures in all built dwellings, builds guild up to 2nd level and first three upgraded dwellings in all AI towns (if not build yet). Extra resources too.
* Every AI hero gains a random +1 stat every day and a bonus to his overall experience of 10%-40% (depending on difficulty selected), until level 50. He is given Air, Earth, Archery, Intelligence and Resistance at expert level, all his mana is refueled daily too. He also receives slow, haste and shield.
* At level 15/25 an AI hero is automatically granted with town portal. At 50-60 with Fly.
* All junk AI creatures (joiners etc) are removed from AI garrisons on every day 1.
* Every town AI conquers will be changed to its faction type.
* Expansion: every day 1 of the week, every AI player having at least one level 15 hero is given a chance* (depends on the number of AI players in the game) to expand by receiving a free town, randomly picked from available neutral towns. Human player will receive a warning message and a view over the new town acquired:

One AI player: 100% chance
Two AI players: 50% chance
Three AI players: 33% chance
Four AI players: 25% chance

Hope can give you some ideas, good luck.

User avatar
wimfrits
Round Table Knight
Round Table Knight
Posts: 2047
Joined: 06 Jan 2006
Location: Utrecht, the Netherlands

Unread postby wimfrits » 18 May 2015, 08:17

Taro wrote:Wimfrits also gave us some good options, maybe except giving items. Potions - fine. But not items like plate armor etc. It's because AI doesn't change artifacts for better. You will give a hero chainmail and if he find Dragon Scale Armor he will not change for it.
Well.. the AI doesn't use potions. And chances of finding a wand (unable to use) are higher than finding the Dragon Flame Tongue. So I'd rather take my chances with a longsword ;)

But I think you bring up a great idea.
Would it be possible to have a generic ranked artifact table. And then clear each AI heroes' inventory periodically and return each item ordered by the ranked table? So that highest ranked artifacts are returned and equipped first?
Are you suggesting coconuts migrate?

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Unread postby Duzeom_ » 18 May 2015, 10:16

wimfrits wrote:Would it be possible to have a generic ranked artifact table. And then clear each AI heroes' inventory periodically and return each item ordered by the ranked table? So that highest ranked artifacts are returned and equipped first?
I thought about the same thing ;)

And it isn't cheating B-) :devil:

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Unread postby Duzeom_ » 18 May 2015, 10:36

wimfrits wrote: Without help, the AI currently expands at a rate of say 30% of that of an average human player. +150% neutral armies would bring that down to 15%.
I think not. AI would not attack stacks which will destroy him completely or jeopardize his army. Therefor AI would have more army when attacking stack and have less casualties. Of course the number +150% is a guess. This number can be variable depending of creature type. For example AI vs sprites is quite good and never loses many armies so number of added creatures should be 0 ( X = 100%), but for example AI underestimates cyclops which makes from his army cannon fodder, so let X be equal to 150%. so on, so on. Of course these added creatures are immediately taken when fight begins - so the number of creatures + added that way only influence the AI behavior on the map.

User avatar
Dalai
Equilibris Team
Equilibris Team
Posts: 1073
Joined: 06 Jan 2006
Contact:

Unread postby Dalai » 18 May 2015, 11:44

Salamandre wrote:I don't know if this can give you some ideas, but here is the "Better AI" mod I did for Heroes III. As you can see, all parameters are modulable to fit every player skill and AI income/growth can go up to +1000%.
...
If you are interested I can give you a list of all changes and bonuses AI gets, there are dozens of them.
I have never heard about your mod, but it looks very much like I imagined our idea :) I see that you already posted all bonuses. Thanks!
Taro wrote:Good to hear you are going to do such thing. I made a remake of "Conquer of Four Lakes".
This is great, thank you!
wimfrits wrote:
Dalai wrote:For example, every AI army can triple upon contact with neutrals, and return back to normal after victory. That way AI will not engage in hopeless fights, but will suffer less casualties in fights it actually chooses to engage.
I think this would be excellent! It's not cheating, but merely compensating for AI stupidity. The AI greatly misjudges neutral threat and will easily lose 80% of it's army in encounters a novice player would avoid.
I am glad that you and other people find this idea worthy. To be clear - it's not mine, I read it somewhere here, in forum. I like it too. I raised it again in hope, that if there are some hidden problems - someone would warn us about them.
wimfrits wrote:Also, the AI does not consider threat areas of mobile guards.
This is still a problem, even with bigger AI armies. We want AI to attack neutrals that it can actually win. If big armies will help AI win fights it's not supposed to fight at all - it's hardly a better AI. Or even an imitation of one. :(
wimfrits wrote:A better AI interface like Salamandre did would be great. I'd want this internally (mapmaker's eyes only) and tweakable for each difficulty level.
Could you elaborate on this some more?
wimfrits wrote:Some other general non-cheating measures:
- give artifacts that can be bought in town to heroes (as AI heroes rarely do)
- increase experience of new AI heroes to compensate for the low priority to visit experience increasing objects
- give skills to new heroes to compensate for not buying skills. Partly randomised logical combinations (tactics + combat, magic + combat, ...) to increase AI hero variety.
All should be dependant on the player's chosen difficulty
That are all good ideas. Let's try to make a next step.

Here is a problem for all mapmakers who have time and desire to solve it:

Suppose we are trying to "increase experience of new AI heroes to compensate for the low priority to visit experience increasing objects". We can surround every existing Learning Stone (+1000 xp) by placed events giving AI heroes additional 2000 xp. But we want it to work exactly once for each AI hero per Learning Stone.

Essentially, we want each Learning Stone to give each AI hero 2000xp if hero chooses to ignore it and pass by, and 3000xp if he chooses to visit it.

All will be done automatically, so we don't know how many Learning Stones are there on a map.

How would you solve this problem?
wimfrits wrote:But I think you bring up a great idea.
Would it be possible to have a generic ranked artifact table. And then clear each AI heroes' inventory periodically and return each item ordered by the ranked table? So that highest ranked artifacts are returned and equipped first?
If it needs modifying the game code - no promises, sorry. But if it can be solved with scripting - good, another problem to train scripting skills. Fame and undying gratitude of generations of H-IV players are waiting for someone who solves it :)
Salamandre wrote:Be careful with tripling AI fight value before battle then return to normal: I already tried it and is headache to keep track of battle loses. I mean, you must have access to also internal battle rounds codes, so you can keep each round track of what died on AI side then consider it when recalculating the "normal size".

For me (and H3) it was more simple to ensure AI has the right skills, spells and creatures so he can't lose that battle. And even if he loses a lot, weekly growth is sufficient crazy to compensate.
I imagined it simple. Let's assume we have an AI army with hero, 2 BDs, 10 efreeti and 50 medusas. When it engages in fight, we triple the army: 6 BDs, 30 efreeti and 150 medusas. AI suffers some losses, for example, he finishes the battle with 4 BDs, 19 efreeti and 122 medusas. We then divide it by 3 and round up: 2 BDs, 7 efreeti and 41 medusas.

In this algorithm losses are smaller than in one proposed by wimfrits. And it is impossible to win a fight and lose all heroes and creatures in the end.
"Not a shred of evidence exists in favour of the idea that life is serious." Brendan Gill

User avatar
Salamandre
Genie
Genie
Posts: 1032
Joined: 13 May 2006
Location: France
Contact:

Unread postby Salamandre » 18 May 2015, 12:24

Dalai wrote:I have never heard about your mod
This is because we don't update anymore at CH the wog section, there is no demand/visits to that forum to worth the effort. but maybe I'll update a bit when holidays come, in july :ill:

But all 150+ mods for Heroes III are detailed and available at HC community

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1126
Joined: 12 Nov 2011

Unread postby Karmakeld » 18 May 2015, 13:19

Dalai wrote:
I imagined it simple. Let's assume we have an AI army with hero, 2 BDs, 10 efreeti and 50 medusas. When it engages in fight, we triple the army: 6 BDs, 30 efreeti and 150 medusas. AI suffers some losses, for example, he finishes the battle with 4 BDs, 19 efreeti and 122 medusas. We then divide it by 3 and round up: 2 BDs, 7 efreeti and 41 medusas.

In this algorithm losses are smaller than in one proposed by wimfrits. And it is impossible to win a fight and lose all heroes and creatures in the end.
This sound rather fair to me. Atleast still ensuring there are losses.
Now I use some of the same ideas that has already been mentioned, increased income, xp bonus/level up's to newly hired heroes, increased dwell. population.
I also found that increasing AI heroes att./def. by +10 pr. difficulty above intermediate usefull. (adv. +10/+10, expert +20/+20, champion +30/+30).
This could also be used with spellspoints.
Maciek and I also found that AI heroes getting a fake att/def. boost also increases their aggresiveness. You can increase it by +99/+99 and then decrease that bonus upon encounter with human players.
I also use the victorious script/timed events to give add. xp/level bonus depending on difficulty.
Another interesting idea Maciek came up with for one of my maps was to decrease your main heroes stats after each victory. This was related to the story so it made sense, but essentially on champion you would decrease att, def or spellpoints by 2 after each won battle. Expert -1 in of the those 3, and advanced would get a decrease after each 2nd battle. Novice players would get an increase instead, making it easier as they get along. (Now this one might be dangerous to implement, but it is however a fun idea, that forces you to decide which battles are worth fighting - also note that hero can never get below 5 point, but the game do registers if your attack should be -10, in case of a later increase).

Making an artifacts table shouldn't be hard to script, although it might take some time. You could simply check for relic>major>minor and treasures.
If AI has a certain relic, you'd take away any major, minor, treasure or items of the same weapon type (head, armour, feet etc.) In case of more than one artifact in the same category level, you could make it random or simply list wheter you think Horned Bow is better than Bow of the Elf King or opposite etc.
Biggest issue is most likely with armours (ward armours). But how often do AI carry around several ward armours? Getting more complex, you could then check for opponent alignments and chose bassed on that.
Here is a problem for all mapmakers who have time and desire to solve it..:
I ask that Maciek is brought forth to this disccusion, as he's is good at these scripting issues.
In order to prevent the same AI hero from getting several boosts from the same Learning Stone, you'd need to give each AI hero a different variable. In theory I guess you could check for names, but only given that no AI heroes has been renamed in the map. Then you could simply set a 'Mudgeon_visited_learning_stone_1' variable to true. Variable names would need to automatically increase with each number of Learning Stone on the map. So 5 Learning Stones would require 5 variables.. For EACH hero (available in the map)..
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1126
Joined: 12 Nov 2011

Unread postby Karmakeld » 18 May 2015, 13:33

regarding the Learning Stone script, I was just reading this other tread:
Minimalistic map - most important objects, and funny coinsident, Maciek writes:
10.Skill buildings - some can't be replaced with quest huts because there's no way to check with scripts if a specific hero hired from tavern already got a skill from there or not
Now Dalai, can you dig into the Learning Stone's script? For it already remembers if a hero has already visited it (even if original name is changed), if you can do this, then you should be able to use the same script infront of the learning stone to give additional 2000 xp pr. Leaning Stone. :creative: (brilliant - I know)

Now what's the next issue to solve ;)
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
wimfrits
Round Table Knight
Round Table Knight
Posts: 2047
Joined: 06 Jan 2006
Location: Utrecht, the Netherlands

Unread postby wimfrits » 18 May 2015, 13:58

Duzeom_ wrote:I think not. AI would not attack stacks which will destroy him completely or jeopardize his army. Therefor AI would have more army when attacking stack and have less casualties.
Only when the current neutral stack size is exactly balanced around the AI's decision point to attack or not attack the stack. Which is near impossible.
But this is beside the problem. The problem is not that the AI should not attack stack X. On the contrary, it needs to attack stack X in order to maintain it's exploration rate of a 2 year old.
The problem is that the AI takes unnecessary losses when attacking stack X.
Dalai wrote:
wimfrits wrote:A better AI interface like Salamandre did would be great. I'd want this internally (mapmaker's eyes only) and tweakable for each difficulty level.
Could you elaborate on this some more?
E.g. One of the things I did in A Wind of Thorns was adjust the size of every neutral stack based on the player's chosen difficulty. A menu inside the editor to modify general neutral stack size and input boxes or sliders per difficulty would have been a dream come true.

The same for AI gold and resources per day, bonus weekly creature growth, bonus starting creatures, starting town level, AI hero bonus stats, AI hero bonus level, etc.
Dalai wrote:Suppose we are trying to "increase experience of new AI heroes to compensate for the low priority to visit experience increasing objects". We can surround every existing Learning Stone (+1000 xp) by placed events giving AI heroes additional 2000 xp. But we want it to work exactly once for each AI hero per Learning Stone.

Essentially, we want each Learning Stone to give each AI hero 2000xp if hero chooses to ignore it and pass by, and 3000xp if he chooses to visit it.

All will be done automatically, so we don't know how many Learning Stones are there on a map.

How would you solve this problem?
I'd let go of the location constraint. If you want a baby to drink his milk, you don't use placed events around the milk bottle. Just put it at his mouth.
I think the tiles in front of a town are the best bet to catch a passing hero, so I'd suggest one general placed event for all AI hero modification scripts and place it before each town.
One of the modules in the script could be an experience increase that can only be triggered x times (1? 2?) per day by an AI hero and gives y experience to the weakest hero in the army, where y would be a value based on the mapmaker's input in that nifty user-interface in the editor :) Possibly a value that increases each week.
Are you suggesting coconuts migrate?

User avatar
Duzeom_
Conscript
Conscript
Posts: 235
Joined: 07 Mar 2011

Unread postby Duzeom_ » 18 May 2015, 14:16

wimfrits wrote:
Duzeom_ wrote:I think not. AI would not attack stacks which will destroy him completely or jeopardize his army. Therefor AI would have more army when attacking stack and have less casualties.
Only when the current neutral stack size is exactly balanced around the AI's decision point to attack or not attack the stack. Which is near impossible.
But this is beside the problem. The problem is not that the AI should not attack stack X. On the contrary, it needs to attack stack X in order to maintain it's exploration rate of a 2 year old.
The problem is that the AI takes unnecessary losses when attacking stack X.
So maybe taking army from neutral stacks is a better option? The same as adding but taking for example 20% of the neutral armies. Of course only in AI turn,

User avatar
wimfrits
Round Table Knight
Round Table Knight
Posts: 2047
Joined: 06 Jan 2006
Location: Utrecht, the Netherlands

Unread postby wimfrits » 18 May 2015, 14:23

Duzeom_ wrote:So maybe taking army from neutral stacks is a better option? The same as adding but taking for example 20% of the neutral armies. Of course only in AI turn,
Yes! There's an idea!!
1. Temporary decrease neutral stack size by 20% during the AI's turn
2. In addition, take away 40% of a neutral stack size if it is attacked by an AI player. Return it in the event the AI player loses.

That way, you don't need scripting on AI armies. You boost exploration AND decrease losses by the AI player.
Are you suggesting coconuts migrate?


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 12 guests