Currently Online

Latest Posts

Topic: Some small Ideas, improving a lot

hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1557
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-11, 13:08

blind3rdeye wrote:

I would appreciate ways to boost AI players would boost AI players - but I don't think stronger starting soldiers is the way to do it. There are already ways to give the AI a starting advantage - you can make them start with a town while you only have a HQ; or you can even give yourself "basic outpost" starting conditions to make it harder. Strong starting soldier would be different to that, but similar in the sense that it is only the early game that is harder. Or do you mean that all newly trained soldiers would have the free bonus?

For me, I'd prefer a way to make the AI stronger in the mid-game rather than the early game. Here are two ideas that I've been throwing around in my mind to give AI players an (optional) 'unfair' advantage:

  • Shorter building cooldown and construction times; so that they can mine and manufacture a bit faster.

this is not possible unfortunately, as the AI has no own values or functions for this. These things are controlled as for every other player by the relevant productionsite code.

  • Each soldier lost gives a free random military item in the AI headquarters. (ie. when the AI loses a battle, it will get a free random item in its HQ which will either help it recruit or train a soldier.

this would be more the less similar to letting them start with trading outpost.

My thinking is that when I play a game vs the AI, the outcome essentially comes down to what happens at first contact; because the AI basically just attacks until they run out of soldiers. So if I'm strong enough to defend my core infrastructure, I win; otherwise I lose. When the AI has a starting advantage, it means I have to try to avoid a fight to survive the early game; but once I'm set up, the early game advantage doesn't matter anymore. I'd prefer if the AI's advantage was a bit more persistent. This way, in a FFA with AI players, the later players might still offer some resistance.

Agreed the AI is much to triggerhappy in the moment. I did not have the time to search for the reason and if we use genetic algorithm there. But this is definitly on my list.

Ultimately though I think what the AI really needs is better decision making. They seem able to run only a basic economy, and rather than scaling up, they seem to fill most their land with sentries (which they don't even have enough soldiers to fill). Maybe one day I'll have a shot at trying to improve it.

I beleive we have done a lot in this area in the last times. On which version do you account this experience?
However the basic mechanism in AI is:
1. We try to build a basic economy Which is defined in the lua files of each tribe. This is to avoid a deadlock in any circumstance (given at least HQ, village, fortified village or trading outpost Startconditions.
2. if the beasic economy is established we take 50 fields. evaluate the possible buildings and score them due to their neededness by economy. the highest score of each of the 50 combinations of field and score wins and we built the winning building. The needeness is evaluated against various decision questions which are weighted by factor numbers that have been gained by training runs (genetic algorithm is implemented in this topic)
3. Furthermore the militay presence is controlled by evaluating the military power per area with the military power of the opponent in the area. However I beleive this evaluation leads to suboptimal decisions currently as the AI should stop attacking as soon as it is not powerful enough anymore which not seems to happen.

That reminds me, I did glance at the building selection code. I didn't read through it enough to get an understanding of how it works, but I did notice something that seems like it is a probably a mistake. Just from context alone, I'd guess that this line should read inputs[50] = (bakeries_count_ > 1); (Although I don't expect it would make much difference.)

No I don't believe so because below the Inputs block there is a block where 2 factors are calculated to determine whether we need more economy more space or both. for this decision summary we need this to be true if economy needs boost meaning we have only 1 bakery at the max. the doubling of the line is due to the fact this is an important condition and due to the bits in the used neuron only part of the input values are evaluated.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1665
Ranking
One Elder of Players
Posted at: 2020-04-11, 16:28

the-x wrote:

The Altanter need something like experience in the smithy, so that not so bleak times arise that after 16 minutes you have a full hero or in the game after 19 minutes. This is way too early, not only because they have a significant advantage over the others (it doesn't help that they have fewer units to start with), there is nothing better than one full hero ... except two full heroes

I agree that it is a problem if atlanteans can make a hero much sooner than everyone else. i disagree that it is such a large problem; in practical games heroes are not made so early anyway because of practical considerations. getting one hero soldier is much less important than getting more of them on a regular basis.

anyway, I also disagree on the proposed solution.

First of all, I would wait the end of the tournament before taking any action, and see how the other tribes fare. maybe they also will have some shortcuts to be found. If they don't, it's generally because of a lack of fundamental resources. So I would prefer to reduce atlantean starting stock, because they really have a lot of resources. they have very little logs, but they have a ton of everything else. probably to compensate for their slow starts due to the lack of logs. in that case i would add some logs and remove some other wares. you can skip making a sawmill, you can skip making farms, you can skip making iron mines... definitely too much.

EDIT:

hessenfarmer wrote:

blind3rdeye wrote:

I would appreciate ways to boost AI players would boost AI players - but I don't think stronger starting soldiers is the way to do it. There are already ways to give the AI a starting advantage - you can make them start with a town while you only have a HQ; or you can even give yourself "basic outpost" starting conditions to make it harder. Strong starting soldier would be different to that, but similar in the sense that it is only the early game that is harder. Or do you mean that all newly trained soldiers would have the free bonus?

For me, I'd prefer a way to make the AI stronger in the mid-game rather than the early game. Here are two ideas that I've been throwing around in my mind to give AI players an (optional) 'unfair' advantage:

  • Shorter building cooldown and construction times; so that they can mine and manufacture a bit faster.

this is not possible unfortunately, as the AI has no own values or functions for this. These things are controlled as for every other player by the relevant productionsite code.

On the other hand, would it be so difficult to change the working cycle times as "[normal time] * X", where X is a function of the difficulty level? Normal difficulty, X=1. harder difficulties have X<1, so the AI produces everything faster.

Edited: 2020-04-11, 16:41

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1557
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-11, 16:55

king_of_nowhere wrote:

First of all, I would wait the end of the tournament before taking any action, and see how the other tribes fare. maybe they also will have some shortcuts to be found. If they don't, it's generally because of a lack of fundamental resources. So I would prefer to reduce atlantean starting stock, because they really have a lot of resources. they have very little logs, but they have a ton of everything else. probably to compensate for their slow starts due to the lack of logs. in that case i would add some logs and remove some other wares. you can skip making a sawmill, you can skip making farms, you can skip making iron mines... definitely too much.

This is exactly what was in my mind the last days, as if you had read my mind.

EDIT:

hessenfarmer wrote:

this is not possible unfortunately, as the AI has no own values or functions for this. These things are controlled as for every other player by the relevant productionsite code.

On the other hand, would it be so difficult to change the working cycle times as "[normal time] * X", where X is a function of the difficulty level? Normal difficulty, X=1. harder difficulties have X<1, so the AI produces everything faster.

It is difficult as we would need to communicate the AI difficzulty level and the information that a player is AI to all the involved economy functions. The economy currently doesn't know whether a player is human or AI it is just doing its job in every building.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1665
Ranking
One Elder of Players
Posted at: 2020-04-11, 17:07

EDIT:

hessenfarmer wrote:

this is not possible unfortunately, as the AI has no own values or functions for this. These things are controlled as for every other player by the relevant productionsite code.

On the other hand, would it be so difficult to change the working cycle times as "[normal time] * X", where X is a function of the difficulty level? Normal difficulty, X=1. harder difficulties have X<1, so the AI produces everything faster.

It is difficult as we would need to communicate the AI difficzulty level and the information that a player is AI to all the involved economy functions. The economy currently doesn't know whether a player is human or AI it is just doing its job in every building.

the AI would not need to know anything. the AI would keep working as usual, having all production faster would just let it make more of everything. but it woudl not change radically how the economy work (on the more powerful settings perhaps all the extra wares would clog the roads more easily?).

the economy needing to know the difficulty setting would be an addition, yes. on the other hand, all it would need to know would be th X value, which is set at the beginning of the game and never changed.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 1557
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-04-11, 17:12

king_of_nowhere wrote:

EDIT:

hessenfarmer wrote:

this is not possible unfortunately, as the AI has no own values or functions for this. These things are controlled as for every other player by the relevant productionsite code.

On the other hand, would it be so difficult to change the working cycle times as "[normal time] * X", where X is a function of the difficulty level? Normal difficulty, X=1. harder difficulties have X<1, so the AI produces everything faster.

It is difficult as we would need to communicate the AI difficzulty level and the information that a player is AI to all the involved economy functions. The economy currently doesn't know whether a player is human or AI it is just doing its job in every building.

the AI would not need to know anything. the AI would keep working as usual, having all production faster would just let it make more of everything. but it woudl not change radically how the economy work (on the more powerful settings perhaps all the extra wares would clog the roads more easily?).

maybe I was not clear in my communcation. Production in buildings is not handled by AI code. It is handled by a lot of economy and productioncode. These packages of the economy, the productionsites, the workers and so on do not know anything about the player (whether AI or human) changes there would pretty much affect the whole codebase of the game.

the economy needing to know the difficulty setting would be an addition, yes. on the other hand, all it would need to know would be th X value, which is set at the beginning of the game and never changed.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1665
Ranking
One Elder of Players
Posted at: 2020-04-11, 17:59

Back on OT, I'm thinking perhaps to remove all food and metal resources from the starting stock of all tribes, in exchange for some basic construction material.

the reason is that on small maps (which is most maps, actually, as you can cover a lot of ground if you know where your opponent is) it is often convenient to start by making the training sites and train a few soldiers for fast combat before you even have all the buildings ready. then you gradually make the food production buildings to replace your stock as you run out of food. I call this approach "top-down", because if you look at the economy like a pyramid with every layer using the wares made from the one below it, with the primary producers at the base and the training sites on top, then in this approach you start building from the top and then move down gradually.

whereas the opposite approach, which I dubbed "bottom-up", produces first the primary producers, then it makes the buildings that transform their products, and then those transforming those products some more, all the way to the training sites. it grants a more steady and powerful production, but it starts slower.

and if we want to de-emphatise the military side of the game, we should favor the bottom-up approach over the top-down. And the top-down approach is only possible insofar as one has a starting stock of highly transformed wares. removing those wares would force the bottom-up approach. meaning that to win, one has to at least have a full economy.

hessenfarmer wrote:

maybe I was not clear in my communcation. Production in buildings is not handled by AI code. It is handled by a lot of economy and productioncode. These packages of the economy, the productionsites, the workers and so on do not know anything about the player (whether AI or human) changes there would pretty much affect the whole codebase of the game.

All it would need to know would be an X value that is set at the beginning of the game. it would not need to know the player.

then again, the exhistance of this X value would need to be assigned at the beginning of the game, and it would need to be included in saves... yes, I can see it would not be as trivial as run a search and modify on all the lua files. Still, anything else would likely be much harder.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1054
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-04-11, 18:19

king_of_nowhere wrote:

Back on OT, I'm thinking perhaps to remove all food and metal resources from the starting stock of all tribes, in exchange for some basic construction material.

the reason is that on small maps (which is most maps, actually, as you can cover a lot of ground if you know where your opponent is) it is often convenient to start by making the training sites and train a few soldiers for fast combat before you even have all the buildings ready. then you gradually make the food production buildings to replace your stock as you run out of food. I call this approach "top-down", because if you look at the economy like a pyramid with every layer using the wares made from the one below it, with the primary producers at the base and the training sites on top, then in this approach you start building from the top and then move down gradually.

whereas the opposite approach, which I dubbed "bottom-up", produces first the primary producers, then it makes the buildings that transform their products, and then those transforming those products some more, all the way to the training sites. it grants a more steady and powerful production, but it starts slower.

and if we want to de-emphatise the military side of the game, we should favor the bottom-up approach over the top-down. And the top-down approach is only possible insofar as one has a starting stock of highly transformed wares. removing those wares would force the bottom-up approach. meaning that to win, one has to at least have a full economy.

I fully agree! face-smile.png

hessenfarmer wrote:

maybe I was not clear in my communcation. Production in buildings is not handled by AI code. It is handled by a lot of economy and productioncode. These packages of the economy, the productionsites, the workers and so on do not know anything about the player (whether AI or human) changes there would pretty much affect the whole codebase of the game.

All it would need to know would be an X value that is set at the beginning of the game. it would not need to know the player.

then again, the exhistance of this X value would need to be assigned at the beginning of the game, and it would need to be included in saves... yes, I can see it would not be as trivial as run a search and modify on all the lua files. Still, anything else would likely be much harder.

It would break multiplayer games and replays. Because the information which kind of AI controls a player is not available and could not be made available without reworking literally an estimated three quarters of the entire codebase. More general: Any game-logic-related code must not be allowed to take into account (directly or indirectly) whether a player is controlled by an AI.


Top Quote
king_of_nowhere
Avatar
Joined: 2014-09-15, 18:35
Posts: 1665
Ranking
One Elder of Players
Posted at: 2020-04-11, 18:26

All it would need to know would be an X value that is set at the beginning of the game. it would not need to know the player.

then again, the exhistance of this X value would need to be assigned at the beginning of the game, and it would need to be included in saves... yes, I can see it would not be as trivial as run a search and modify on all the lua files. Still, anything else would likely be much harder.

It would break multiplayer games and replays. Because the information which kind of AI controls a player is not available and could not be made available without reworking literally an estimated three quarters of the entire codebase. More general: Any game-logic-related code must not be allowed to take into account (directly or indirectly) whether a player is controlled by an AI.

But it wouldn't break anything because It would not need to know who is controlling which player. All it would need to know is the X value. So for multiplayer the X value is 1 for all players, and that is encoded in the save, period. In the replay, all it would need to know is the X value, and again that one is encoded in the file, and it's just a single number. nothing to break there.

I guess one could start a multiplayer game with an AI at hard value, then save it and reload the game with him in place of that AI, but the likelyhood of this happening by accident is exceedingly small.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1054
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2020-04-11, 18:43

Ähm… could you please define how exactly this X value is to be determined? It first sounded like a per-player factor that can reduce production times for hard AIs, now it's suddenly a single number…?

and it's just a single number. nothing to break there

I'm not going to accept arguments like this face-wink.png I recently fixed a desync that was also caused by one wrong 8-bit number. One-number-changes have broken savegames and replays and introduced desyncs and logic bugs countless times already.


Top Quote
niektory
Avatar
Joined: 2019-06-03, 20:06
Posts: 181
Ranking
Widelands-Forum-Junkie
Location: Poland
Posted at: 2020-04-11, 19:05

king_of_nowhere wrote:

Back on OT, I'm thinking perhaps to remove all food and metal resources from the starting stock of all tribes, in exchange for some basic construction material.

the reason is that on small maps (which is most maps, actually, as you can cover a lot of ground if you know where your opponent is) it is often convenient to start by making the training sites and train a few soldiers for fast combat before you even have all the buildings ready. then you gradually make the food production buildings to replace your stock as you run out of food. I call this approach "top-down", because if you look at the economy like a pyramid with every layer using the wares made from the one below it, with the primary producers at the base and the training sites on top, then in this approach you start building from the top and then move down gradually.

whereas the opposite approach, which I dubbed "bottom-up", produces first the primary producers, then it makes the buildings that transform their products, and then those transforming those products some more, all the way to the training sites. it grants a more steady and powerful production, but it starts slower.

and if we want to de-emphatise the military side of the game, we should favor the bottom-up approach over the top-down. And the top-down approach is only possible insofar as one has a starting stock of highly transformed wares. removing those wares would force the bottom-up approach. meaning that to win, one has to at least have a full economy.

One thing to keep in mind for it to work is ensuring that rushing with the starting force is not effective. In other words, making sure that with equal forces the defender has an advantage.


Top Quote