Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the AI unit growth bonuses and tune the income bonuses for different difficulty levels #8402

Merged
merged 73 commits into from
Jun 1, 2024

Conversation

oleg-derevenetz
Copy link
Collaborator

@oleg-derevenetz oleg-derevenetz commented Feb 13, 2024

Related to #8321.

Also this PR tunes the AI surrender behavior.

@oleg-derevenetz oleg-derevenetz marked this pull request as draft February 13, 2024 18:18
@LeHerosInconnu
Copy link

LeHerosInconnu commented Feb 15, 2024

So, I finished my first test with this PR in game difficulty hard.

Here are screenshots of some of the cities I captured, where even without the creature growth bonus and gold income bonus, the AI was unable to recruit most of the creatures.

In fheroes2:

After yellow 01

After violet 01

After violet 03

Here are the save files:
Before after hard no ai bonus 01.zip

Then I watched a recent let's play of fheroes2 with these growth and income bonuses for AI in impossible difficulty mode.
And that's what I've been noticing in my tests too, it's the human player who ultimately benefits from these AI growth bonuses.
That's what makes it so easy for him to win the game, without any further challenge.

In fheroes2 (from the let's play):

Broken growth 01

@oleg-derevenetz
Copy link
Collaborator Author

And that's what I've been noticing in my tests too, it's the human player who ultimately benefits from these AI growth bonuses.
That's what makes it so easy for him to win the game, without any further challenge.

So what specific fixes are needed? In theory, we need some kind of formula M = F(G) that calculates an increase in money income depending on the increase in unit growth for AI (even if G is zero, because not all units are redeemed without bonuses either). By the way, the redemption of units in castles is not carried out every week "automatically", but only if necessary, that is, if the castle is visited by a hero or if the castle is under threat (that is, an enemy hero is seen nearby).

@LeHerosInconnu
Copy link

Hello @oleg-derevenetz,

And that's what I've been noticing in my tests too, it's the human player who ultimately benefits from these AI growth bonuses.
That's what makes it so easy for him to win the game, without any further challenge.

So what specific fixes are needed? In theory, we need some kind of formula M = F(G) that calculates an increase in money income depending on the increase in unit growth for AI (even if G is zero, because not all units are redeemed without bonuses either). By the way, the redemption of units in castles is not carried out every week "automatically", but only if necessary, that is, if the castle is visited by a hero or if the castle is under threat (that is, an enemy hero is seen nearby).

Giving more gold to the AI based on additional creature bonuses is not a solution for me, as it would destabilize the original game's "balance" between the different castles.
Castles with the strongest creatures would receive more gold to buy them and become even more powerful.

In Heroes 2, gold (and other resources) is the main factor to consider.
The game's standard income (the income from a castle compared to the cost of recruiting creatures from the same castle) doesn't allow for the purchase of all creatures, for both human and AI players.
That's why players have to do their best to acquire income from outside the castle.
By increasing the AI's gold income, it will be able to recruit more creatures and more quickly than the human player.
Higher difficulty levels should increase this recruitment capacity, and even more quickly too.

Increasing the AI's income with a simple percentage (without a convoluted formula) is simple for all players to understand and simple to put in place, and there's only one adjustment factor so it's easier to work out what's going wrong.
As I suggested in this post: #8321 (comment).

No creature growth bonus for AI.

I would do it this way:

  • Easy: -25% gold income
  • Normal: no bonus/malus
  • Hard: +50% gold income
  • Expert: +100% gold income, +1 of each resource per day
  • Impossible: +200% gold income, +1 of each resource per day

If impossible mode is not sufficiently different from expert mode, we can adjust to +2 of each resource per day, but I don't think this is necessary.

This would, I think, be a good basis for observing the effectiveness of AI, without giving an advantage that would ultimately be more beneficial to the human player.

In the original game, the AI buys everything it can and never gives gold to the opponent.
Granted, the creatures aren't used to their full potential, but at least the opponent can't recruit them (or at least much less than if the AI didn't recruit them).
Also, if I'm not mistaken, currently the AI is not immune to a long distance attack with the dimension door spell from the human player.

If I remember correctly, in Heroes 2, the bonuses for AI are as follows:

  • Hard: +10% gold income, +1 unit of ore, +1 unit of wood per day
  • Expert: +50% gold income, +1 of each resource per day
  • Impossible: +100% gold income, +2 of each resource per day

And it's not enough, in my experience, to give the AI the ability to recruit all the creatures available in Heroes 2 either.
But there is, thanks to this, a difference between the different difficulty levels.

@oleg-derevenetz
Copy link
Collaborator Author

I would do it this way:

  • Easy: -25% gold income
  • Normal: no bonus/malus
  • Hard: +50% gold income
  • Expert: +100% gold income, +1 of each resource per day
  • Impossible: +200% gold income, +1 of each resource per day

Well, let's try this way. I adjusted the income bonus in this PR according to this (well, almost - except the +1 of each resource, because this is not available now, it needs some additional code).

By increasing the AI's gold income, it will be able to recruit more creatures and more quickly than the human player.
Higher difficulty levels should increase this recruitment capacity, and even more quickly too.

This will only work up to a certain limit. Let's say if on the Expert difficulty (+100% income) AI will already be able to buy out all the troops, then additional +100% income on the Impossible difficulty won't matter because there just will be no additional troops to hire.

@LeHerosInconnu
Copy link

@oleg-derevenetz,

I would do it this way:

  • Easy: -25% gold income
  • Normal: no bonus/malus
  • Hard: +50% gold income
  • Expert: +100% gold income, +1 of each resource per day
  • Impossible: +200% gold income, +1 of each resource per day

Well, let's try this way. I adjusted the income bonus in this PR according to this (well, almost - except the +1 of each resource, because this is not available now, it needs some additional code).

Okay.

By increasing the AI's gold income, it will be able to recruit more creatures and more quickly than the human player.
Higher difficulty levels should increase this recruitment capacity, and even more quickly too.

This will only work up to a certain limit. Let's say if on the Expert difficulty (+100% income) AI will already be able to buy out all the troops, then additional +100% income on the Impossible difficulty won't matter because there just will be no additional troops to hire.

If the AI has more gold, it can be more aggressive (recruit its creatures and build its cities, as well as having more active heroes with strong armies on the adventure map), and it can also recruit creatures from captured castles that the human player was unable to recruit.
Let's see how the AI performs with the latest changes.
I'll start a test tomorrow (certainly in expert difficulty).

Another question I have is whether the AI knows how to use the secondary skill diplomacy.
Because there's also gold to be spent on this, although it requires a very solid economy.

@LeHerosInconnu
Copy link

@oleg-derevenetz,

So, I continued my tests.

In a first game, on expert difficulty, I played a bit relaxed, getting surprised by a more aggressive AI with better armies.

In the second game, still on expert difficulty, the AI was just as aggressive, still with better armies, and it took me a little longer to defeat it, and it was more difficult than usual with the standard version of fheroes2.
The cities conquered from the AI offered few or no creatures for recruitment, unlike the standard version of fheroes2.
It's worth noting, however, that the scenario played, Broken Alliance, has plenty of gold mines, which may have given the AI a very generous income.

For me, the current AI income bonus values in this PR are fine.
I'll test the same scenario in impossible difficulty, then another scenario where there are fewer gold resources on the adventure map later.

Here are the save files:
Expert no ai bonus 01.zip

@oleg-derevenetz
Copy link
Collaborator Author

oleg-derevenetz commented Feb 17, 2024

In a first game, on expert difficulty, I played a bit relaxed, getting surprised by a more aggressive AI with better armies.

More resources will certainly help AI develop its castles more intensively (even if there is only more gold, because AI is able to buy missing resources using marketplace if it has an excess of gold). The more interesting question is what will happen when it develops all the available castles, and it will be able to spend money only on hiring troops, and the number of troops now does not increase with increasing difficulty. I suspect that this should be more noticeable on L or XL maps, but with a relatively small number of towns/castles. Broken Alliance is a map of a medium size, AI finds and attacks the human player pretty quickly.

@LeHerosInconnu
Copy link

@oleg-derevenetz,

First game on impossible difficulty, still Broken Alliance, this time I played a little more seriously.

The AI heroes appear more quickly with armies of level six creatures.
AI cities are well developed, with a few unrecruited creatures left in conquered AI cities.
In this game, I forced the pace and finished the scenario more quickly (I built a level five mage guild in a conquered AI city and obtained the dimension door spell).

In fheroes2:

Some towns where level six creatures are available for a number corresponding to several weeks' growth;
Broken impossible 001
Broken impossible 002

A few unrecruited creatures from the week's growth, nothing too bad;
Broken impossible 003

AI's last castle:
Broken impossible 004

Here are the save files:
Broken impossible 01.zip

In a first game, on expert difficulty, I played a bit relaxed, getting surprised by a more aggressive AI with better armies.

More resources will certainly help AI develop its castles more intensively (even if there is only more gold, because AI is able to buy missing resources using marketplace if it has an excess of gold). The more interesting question is what will happen when it develops all the available castles, and it will be able to spend money only on hiring troops, and the number of troops now does not increase with increasing difficulty. I suspect that this should be more noticeable on L or XL maps, but with a relatively small number of towns/castles. Broken Alliance is a map of a medium size, AI finds and attacks the human player pretty quickly.

That's what I've observed.
I'm now going to do a test with the scenario Heroes (L size map).

@LeHerosInconnu
Copy link

@oleg-derevenetz,

First game on scenario Heroes on impossible difficulty, AI attacks me month 1, week 2, day 6, game over.

In fheroes2:

Heroes yellow bone end 01

Second game on scenario Heroes on impossible difficulty, I win against AI month 3, week 3, day 6.

In fheroes2:

Final combat:
Heroes win impossible 02

AI has nice armies, despite the fact that there is only one castle per player and only five gold mines to capture on the adventure map.

In fheroes2:

Month 2, week 1 , day 2;
AI armies impossible 02 001
AI armies impossible 02 002
AI armies impossible 02 003

Month 2, week 2, day 5;
AI armies impossible 02 004
AI armies impossible 02 005

Month 2, week 4 , day 1;
AI armies impossible 02 006
AI armies impossible 02 007

Here are the save files:
Heroes lose win impossible 01.zip

...The more interesting question is what will happen when it develops all the available castles, and it will be able to spend money only on hiring troops, and the number of troops now does not increase with increasing difficulty. I suspect that this should be more noticeable on L or XL maps, but with a relatively small number of towns/castles.

The aim is not to make the AI invincible, but to make the AI more harassing more quickly.
If the human player manages to get the better over the AI, I think it's perfectly normal for the AI to get weaker.
If the AI has a large amount of gold (which it might not be able to spend at all times), this is also beneficial for the AL, as the AI will be able to recruit creatures not recruited by the human player (the human player doesn't have the possibility of recruiting all the creatures at his disposal) when capturing or recapturing castles.

@oleg-derevenetz
Copy link
Collaborator Author

The aim is not to make the AI invincible, but to make the AI more harassing more quickly.

Nevertheless, it would be desirable to make the AI represent some challenge for experienced human players too (at least on Expert and Impossible difficulties). I just tried to increase the creature growth for Expert and Impossible difficulties by 25% and 33% respectively (while maintaining the gold income bonus by 200% and 300% respectively) and propose to try to test this when you have time - what will be your impressions? Will the game become more difficult or not?

@LeHerosInconnu
Copy link

Hello @oleg-derevenetz,

The aim is not to make the AI invincible, but to make the AI more harassing more quickly.

Nevertheless, it would be desirable to make the AI represent some challenge for experienced human players too (at least on Expert and Impossible difficulties). I just tried to increase the creature growth for Expert and Impossible difficulties by 25% and 33% respectively (while maintaining the gold income bonus by 200% and 300% respectively) and propose to try to test this when you have time - what will be your impressions? Will the game become more difficult or not?

So, I continued my tests, this time with the Dominion scenario (PoL), an XL sized map, on impossible difficulty.

In the first game, the orange AI player is superior in power month 3, week 2, day 3, no way to come back for my side.
In the second game, the green AI player made a decisive attack month 1, week 3, day 1, no way to come back for my side.

The AI is much more harassing than the last time I played this scenario.
The green AI player is attacking from the west.
The yellow AI player is attacking by sea from the east.
The orange AI player is attacking by sea from the south.

In the third game, I managed to stand my ground and get the edge over my opponents.
But not necessarily to win the game at that moment.

However, the additional growth of AI creatures benefits the human player.
The fact that it is delayed in time (not at the start of the first day, but only when the AI has the hand) does not detract from this fact.

Over time, it's this extra growth for the AI, which I ultimately benefited from, that ensures I get the upper hand over the other AI players.

The human player benefits from the additional creature growth of the AI: (click to expand)

First game:
I was able to get the extra AI creatures after recapturing one of my castles:
Bef recap yellow 01

Third game:
Some cyclops from the previous week are available in excess of standard growth:
Ai growth bonus human 003
Ai growth bonus human 007

AI has not recruited the extra cyclops (however in numbers less than or equal to standard growth):
Ai growth bonus human 004
Ai growth bonus human 005
Ai growth bonus human 009

AI has not recruited the extra cyclops (this time in excess of standard growth):
Ai growth bonus human 006

A few extra creatures from Knight Castle:
Ai growth bonus human 008

It also works for the Sorceress's castle:
Ai growth bonus human 010

And it's bouquet time in the Wizard's castle:
It's the end of the game for the AI.
From this point on, the game is won for the human player, and the rest is just a matter of completing the scenario.
Ai growth bonus human 011

More titans;
Ai growth bonus human 012

A few black dragons, for variety:
Ai growth bonus human 013

And more titans;
Ai growth bonus human 014

Even more titans:
Ai growth bonus human 015

Titans everywhere:
Ai growth bonus human 016

This just goes to show that additional creature growth for AI is more harmful in the end.
With the gold bonus, the AI comes out ahead, and is more aggressive more quickly.
But the extra creature growth for the AI just allows the human player to get around this.

In short, let's remove the extra growth completely for the AI and see how it performs with the current gold bonus.

Here are the save files:
Dominion impossible lose 01.zip
Ai growth bonus for human 01.zip

@oleg-derevenetz
Copy link
Collaborator Author

oleg-derevenetz commented Feb 21, 2024

Hi @LeHerosInconnu did I understand correctly that with increased unit growth the game becomes more challenging than just with increased money income, but AI just doesn't have enough money to hire all these units? Maybe then leave the increased unit growth, but increase the money income even more?

@LeHerosInconnu
Copy link

@oleg-derevenetz,

Hi @LeHerosInconnu did I understand correctly that with increased unit growth the game becomes more challenging than just with increased money income, but AI just doesn't have enough money to hire all these units? Maybe then leave the increased unit growth, but increase the money income even more?

The problem is that as creature growth increases, the most powerful castles, which are also supposed to be trickier to play on smaller maps, will become even more powerful, and on all map sizes.
Basically, the wizard with his titans and the warlock with his black dragons will reign supreme on all types of maps, with no competition possible for the other castles.
Take a look at the examples above, a few more cyclops will be fine, but dozens of titans and black dragons are unmanageable.

If we increase the gold income even further, AI heroes will roam the adventure map with invincible armies, and the human player will never be able to counteract this.

What's more, it will be hard to differentiate between expert and impossible difficulty levels.
The impossible level won't even be necessary, as AI will already be unbeatable at expert level.

As I wrote earlier, let's do a test with all creature growth bonuses removed, so with the gold bonus only, and see how it goes.

@oleg-derevenetz
Copy link
Collaborator Author

The problem is that as creature growth increases, the most powerful castles, which are also supposed to be trickier to play on smaller maps, will become even more powerful, and on all map sizes.

If necessary, we can easily make different growth bonuses for different castles (and even for different dwellings).

As I wrote earlier, let's do a test with all creature growth bonuses removed, so with the gold bonus only, and see how it goes.

OK, I removed the dwelling growth bonuses completely once again.

@LeHerosInconnu
Copy link

@oleg-derevenetz,

The problem is that as creature growth increases, the most powerful castles, which are also supposed to be trickier to play on smaller maps, will become even more powerful, and on all map sizes.

If necessary, we can easily make different growth bonuses for different castles (and even for different dwellings).

I think it would be very complicated to make something coherent.

As I wrote earlier, let's do a test with all creature growth bonuses removed, so with the gold bonus only, and see how it goes.

OK, I removed the dwelling growth bonuses completely once again.

I'll run a test for that.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

src/fheroes2/game/difficulty.cpp Show resolved Hide resolved
Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oleg-derevenetz , I left 2 questions here. Could you please take a look at them?

src/fheroes2/game/difficulty.cpp Show resolved Hide resolved
src/fheroes2/game/difficulty.cpp Show resolved Hide resolved
@Branikolog
Copy link
Collaborator

Hi, all!

I've made a couple of tests.
AI tends not to surrender outside towns now. If it's a deliberate decision - then OK (I'm still convinced, that sometimes saving troops could be a nice step, especially when AI faces a hero with much stronger army and cannot deal any damage because of drastic stat difference). In some cases, when AI has diplomacy or stateman quill it is definitely worth saving a few troops for a little money... Maybe it could be implemented as a separate PR if you wish...

I'm not against reducing unit growth bonuses.
Speaking about increasing income bonus - I'm not against a reasonable rising of gold income, but absolutely not sure about providing a ton of resources from nowhere. We can always set a resource giveaway for a particular map in the map editor. Maybe a few can be provided, but I still prefer rising the existing income, rather than giving all resources for free. What if a mapmaker would like to make a map, where AI cannot afford building a castle creating a map in such manner, that AI does not have any ore mines in his area? It would be hard to explain a player, how AI managed to find so many resources within his closed area...
I'm also unsure about providing resources based on a starting faction. There lots of maps, where a player starts with several multi-faction castles. Sometimes the map is designed in such a way, when a player does not have opportunity to develop his starting castle being forced to capture another. So resource bonus meant for the starting faction could be... Cannot say it is useless, but it looks like an overabundance in my opinion.
Anyway this game is designed in such way, when a player cannot afford to hire all troops on the start of every week. There's nothing wrong, when you capture a castle and find a bunch of troops for hire there. I think the root of the problem lies in AI leaving such castles without sufficient protection. Second thing that allows such issues to happen is AI spending too much money for developing other castles, rather than focusing on hiring new troops.

@oleg-derevenetz
Copy link
Collaborator Author

oleg-derevenetz commented May 27, 2024

We can always set a resource giveaway for a particular map in the map editor.

This giveaway will not depend on AI difficulty then.

I'm also unsure about providing resources based on a starting faction.

There is no such a thing as providing resources based on starting faction. Resources are provided on per-castle basis for each castle in the kingdom personally. For instance, if a kingdom has Barbarian castle (with Cyclopes), Sorceress castle (without the Phoenixes) and Warlock castle (with Dragons), there will be 1 additional Crystal + 1000 Gold per day for Barbarian castle, 1000 Gold per day for Sorceress castle (no Mercury) and 1 additional Sulfur + 2000 Gold per day for Warlock castle.

I think the root of the problem lies in AI leaving such castles without sufficient protection.

AI will hire troops in the castle if it sees any threat nearby (and will not develop such a castle). But:

  1. If AI has already spent money on the development of some other castles, it will not be able to hire enough troops, because the economy in the game is made in such a way that no castle can "feed itself" in terms of hiring troops - even if there is no need to develop other castles, and if you need to develop other castles, then even more so you will have to sacrifice the hiring of creatures;
  2. If AI will always hire troops before trying to develop castles, then the overall rate of castle development will be very slow (see point 1);
  3. Unlike the original game, AI does not start to see the entire map from a certain point, and cannot see threats hidden by the fog of war (and even more so those that can jump out of the fog of war through half a map using the Dimension Door-like spells).

@Branikolog
Copy link
Collaborator

@oleg-derevenetz

We can always set a resource giveaway for a particular map in the map editor.

This giveaway will not depend on AI difficulty then.

True. I was hoping that we are going to reduce all unfair AI perks with upgrading the code complexity, but the solution to boost AI with free resources each day feels like a step back for me. It would be harder to explain players, how many free resources AI gets each turn for each difficulty level, than they can see in map settings.
I totally agree with @idshibanov , no player (human or AI) should have 0 troops in his each castle by the end of the week. such situation is possible, but in most cases there would always be some left unhired.

There is no such a thing as providing resources based on starting faction. Resources are provided on per-castle basis for each castle in the kingdom personally. For instance, if a kingdom has Barbarian castle (with Cyclopes), Sorceress castle (without the Phoenixes) and Warlock castle (with Dragons), there will be 1 additional Crystal + 1000 Gold per day for Barbarian castle, 1000 Gold per day for Sorceress castle (no Mercury) and 1 additional Sulfur + 2000 Gold per day for Warlock castle.

Got it, thanks for clarification.

Unlike the original game, AI does not start to see the entire map from a certain point, and cannot see threats hidden by the fog of war (and even more so those that can jump out of the fog of war through half a map using the Dimension Door-like spells).

Yeah. Sometimes this could be easily abused by a human, that is hiding in the fog nearby: AI just forgets he watched enemy walking around and making just a single step into a fog,
I hope some day we teach AI to predict such situations and use "view heroes" spell to track such hiding heroes precisely.

If AI has already spent money on the development of some other castles, it will not be able to hire enough troops, because the economy in the game is made in such a way that no castle can "feed itself" in terms of hiring troops - even if there is no need to develop other castles, and if you need to develop other castles, then even more so you will have to sacrifice the hiring of creatures;
If AI will always hire troops before trying to develop castles, then the overall rate of castle development will be very slow (see point 1);

That how the things happen in H2: we do not always have enough gold to hire troops and develop castles. Human player has to make a choice and I suppose, AI has to behave similarly. Based on the overall kingdom efficiency and the presence of enemies nearby. I know this is not possible with the current level of AI, but we should be aimed to come to this some day.
I'm convinced, that it is possible to make AI do well even without any resource perks on higher difficulties: having a bunch or resources on the game start gives AI player a huge advantage, comparing to human, starting without any single resource.
By the way, if we slightly increase the priority for hunting resources for AI, he can do better in terms of castle development and army hiring.

It's just my personal opinion and I couldn't change the decision alone here. I just want AI to have as less such unfair perks as possible. Or make them feel more natural, by adding % to the existing income, so player can still use tactic of capturing enemy mines to prevent his development.

@oleg-derevenetz
Copy link
Collaborator Author

oleg-derevenetz commented May 29, 2024

having a bunch or resources on the game start gives AI player a huge advantage, comparing to human, starting without any single resource.

On Impossible difficulty, AI starts with 10K gold. This is literally nothing if your single castle wants 15K gold per week just to hire the weekly growth of Titans alone. This may help to speed up the development of the starting castle somewhat, but nothing more. Not such a huge advantage in the long term at all.

By the way, if we slightly increase the priority for hunting resources for AI, he can do better in terms of castle development and army hiring.

The resources on the map only help to develop the castles (to a certain extent). They don't re-appear every week and can't help with hiring new troops on weekly basis, especially in the long term.

In general, this PR implements the @LeHerosInconnu's idea, and as far as I understand, according to his tests, game complexity really increases on the Expert and Impossible difficulties, just as planned. If someone has specific ideas on how to achieve a similar result in other ways, they can offer a separate PR.

@Branikolog
Copy link
Collaborator

@oleg-derevenetz

The resources on the map only help to develop the castles (to a certain extent). They don't re-appear every week and can't help with hiring new troops on weekly basis, especially in the long term.

True! But the faster AI player develops his castle on the first days, the faster he can explore and conquer points of interest. The more resources he gets, the faster he hires new creatures/heroes and picks up more resources. So the less human player can pick up and the slower he develops then. Indeed, the income strictly depends on the number of towns and mines a player captured on the late game. But no one says, that all troops from all castles should be immediately hired. This is not how this game was planned to be played.

In general, this PR implements the @LeHerosInconnu's idea, and as far as I understand, according to his tests, game complexity really increases on the Expert and Impossible difficulties, just as planned. If someone has specific ideas on how to achieve a similar result in other ways, they can offer a separate PR.

Considering the idea of making the game maximum tough and annoying from the enemy invasion perspective, why can't AI receive 10k gold daily then? Or even 20k gold daily to be sure he hires everything and everywhere? I feel this is not the way we need to make game hard on higher difficulties.

@ihhub
Copy link
Owner

ihhub commented May 30, 2024

@Branikolog , please focus on the current improvement proposal. Before the changes AI had gold bonus and monster growth bonus. After the changes AI has gold and resource bonuses. The question is which way is "less" cheating?

@ihhub
Copy link
Owner

ihhub commented May 30, 2024

After thinking a bit I think we might consider only giving the AI gold rather than resources. For example, there could be castles where no marketplace exists but then dwellings are being. AI would buy monsters even when they have no mines.

We have logic to convert resources in castles when marketplaces are being built. In most cases this helps the AI to develop the castle and also buy many creatures. This could be a solution to satisfy @Branikolog as well.

@oleg-derevenetz what do you think?

@ihhub
Copy link
Owner

ihhub commented May 30, 2024

@oleg-derevenetz , could you please create a separate PR with the changes for surrender? I can see that this PR takes a lot of discussion and it is good to agree at least on one part rather than delaying both.

@oleg-derevenetz
Copy link
Collaborator Author

oleg-derevenetz commented May 30, 2024

Hi @ihhub

After thinking a bit I think we might consider only giving the AI gold rather than resources. For example, there could be castles where no marketplace exists but then dwellings are being. AI would buy monsters even when they have no mines.

We have logic to convert resources in castles when marketplaces are being built. In most cases this helps the AI to develop the castle and also buy many creatures.

You see, on Expert and Impossible AI will get starting resources which are more than enough to build the Marketplace in at least one castle even without mines. After that, the construction of new buildings in castles (as well as the upgrade towns into castles) becomes only a matter of time. Therefore, the argument "the mapmaker may want to remove particular mines from the map and AI will not be able to build some buildings" is untenable, at least on those difficulties where it has enough starting resources to build Marketplaces (AI builds them one of the first, immediately after the Statue). All that additional resources do at higher difficulty levels is accelerate this process, and not "allow" it in principle.

could you please create a separate PR with the changes for surrender? I can see that this PR takes a lot of discussion and it is good to agree at least on one part rather than delaying both.

IMHO there is still time, 1.1.1 milestone is scheduled for early July only. If the process with this PR drags on, I can do it.

@ihhub
Copy link
Owner

ihhub commented May 31, 2024

Hello @oleg-derevenetz , we are planning to allow map makers to disable any buildings in castle. Having this option and AI with extra resources would lead to broken gameplay on some future maps or players would obviously know that AI is cheating.

This isn't implemented yet so I would like to find a solution suitable for everyone.

@oleg-derevenetz
Copy link
Collaborator Author

@ihhub OK, what do you think about 0633eab? Please note that per-castle resource bonuses for level 6 units are still applied (BUT only if the corresponding buildings are built).

@ihhub
Copy link
Owner

ihhub commented Jun 1, 2024

Hi @oleg-derevenetz , the proposed change improves the logic. However, I am still concerned about the resources for creatures from dwellings of level 6. To make sure that for players it won't be obvious that the AI is cheating I am suggesting to add a check whether at least one marketplace is build in any town or the corresponding Mine was captured by the AI. What do you think?

@oleg-derevenetz oleg-derevenetz force-pushed the remove-ai-growth-income-bonuses branch from 0e85e39 to 10e41fa Compare June 1, 2024 13:32
@oleg-derevenetz
Copy link
Collaborator Author

Hi @ihhub

To make sure that for players it won't be obvious that the AI is cheating I am suggesting to add a check whether at least one marketplace is build in any town or the corresponding Mine was captured by the AI.

OK, so be it. Please take a look at the recent changes.

@ihhub
Copy link
Owner

ihhub commented Jun 1, 2024

@oleg-derevenetz , now I think this is the best solution we can have at the moment. Thank you very much for this update!

@ihhub ihhub merged commit 378c343 into ihhub:master Jun 1, 2024
20 checks passed
@oleg-derevenetz oleg-derevenetz deleted the remove-ai-growth-income-bonuses branch June 1, 2024 15:44
@LeHerosInconnu
Copy link

Hello @oleg-derevenetz,

What about the AI bonuses with the last changes made after my last test to date?
Looking at previous posts and code comments, it seems that the general bonus has been removed and now a bonus is given based on castle type and if the level six dwelling is already built.
If I've understood correctly (values are for understanding purposes):
Castle type A, bonus 10 000 gold and X rare resources.
Castle type B, bonus 5 000 gold no resources.
Etc.
And also the requirement of a resource type mine for the level six dwelling creature, and a marketplace?
I'm thinking of doing a few tests and I'd like to be sure of the AI bonuses for each difficulty level before I start.

@oleg-derevenetz
Copy link
Collaborator Author

oleg-derevenetz commented Jun 8, 2024

Hi @LeHerosInconnu

Castle type A, bonus 10 000 gold and X rare resources.
Castle type B, bonus 5 000 gold no resources.

Currently per-castle resource bonuses (on Expert and Impossible difficulties) are as follows:

  • +1 Crystal per day for each Barbarian castle;
  • +1 Mercury per day for each Sorceress castle;
  • +1 Sulfur & +1000 Gold per day for each Warlock castle;
  • +1 Gem & +1000 Gold per day for each Wizard castle;

The above bonuses are applied only if all the following conditions are met:

  • The corresponding castle has a level 6 dwelling;
  • The corresponding kingdom has a Marketplace in at least one of its castles or has at least one captured mine of the appropriate type.

In addition, 1000 gold is always awarded for each castle in the kingdom regardless of its type and dwellings (separately, in addition to "usual" (non-AI-specific) gold income from castle).

@LeHerosInconnu
Copy link

LeHerosInconnu commented Jun 8, 2024

@oleg-derevenetz,

Hi @LeHerosInconnu

Castle type A, bonus 10 000 gold and X rare resources.
Castle type B, bonus 5 000 gold no resources.

Currently per-castle resource bonuses (on Expert and Impossible difficulties) are as follows:

  • +1 Crystal per day for each Barbarian castle;
  • +1 Mercury per day for each Sorceress castle;
  • +1 Sulfur & +1000 Gold per day for each Warlock castle;
  • +1 Gem & +1000 Gold per day for each Wizard castle;

The above bonuses are applied only if all the following conditions are met:

  • The corresponding castle has a level 6 dwelling;
  • The corresponding kingdom has a Marketplace in at least one of its castles or has at least one captured mine of the appropriate type.

In addition, 1000 gold is always awarded for each castle in the kingdom regardless of its type and dwellings (separately, in addition to "usual" (non-AI-specific) gold income from castle).

Okay, thanks.

@LeHerosInconnu
Copy link

Hello @oleg-derevenetz,

I made my report here: #8840.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants