Donation

Help us to pay our server!
(: Consider a donation :)



Social Media

  • Facebook
  • Google+

Latest Posts

Topic: Rework Atlantean Crystal Mine

WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 626
Ranking
One Elder of Players
Location: Saxony, GER
Posted at: 2018-02-23, 17:15

GunChleoc wrote:

WorldSavior wrote:

Are you sure? I thought that the lines with "mine" will cancel the program, not the whole cycle of programs. Canceling a program usually doesn't cancel the cycle, but the next program will run...

That's true.

Okay, that's surprising me.... And I still don't believe it:

I made a little experiment now; build a crystal mine in an area where it couldn't find stone resources and let it run, controlling that it has never a resource shortage and that all economy settings were always much higher than stock. (in build 19)

My observation: The crystal mines found many stones and diamonds, but not a single quartz. That's almost a prove for my thesis face-wink.png

Since the first program in the list doesn't produce any diamonds whatsoever, this actually disproves your thesis that only the first program is executed.

That's not my thesis, it's teppo's face-wink.png

WorldSavior wrote:

Otherwise, trainingsites would have a big problem...

Oops, I forgot trainingsites. You're right about them. But they are working different to productionssites, I guess...

They are productionsites with an extra soldiers tab. So, they work exactly the same face-wink.png

That's not what I observed face-wink.png

For example, if an atlantean weapon smithy gets full supply and no limits by economy settings, it will work according to the pattern 1 2 3 4 5 1 2 3 4 5 1 and so on.

But if a dungeon gets full supply and only three rookies go in there, it will work according to the pattern 1 1 1 2 2 2 3 3 3 4 and so on.

WorldSavior wrote:

I think I understand why. Let's take a look at a part of the quartz program:

"consume=smoked_fish,smoked_meat:2 atlanteans_bread:2",

        "animate=working 20000",

        "mine=stones 4 100 5 2",

        "produce=granite:2",

        "animate=working 20000",

        "mine=stones 4 100 5 2",

        "produce=granite quartz",

At the line with "mine", the probability that the next line will follow is 5%. But then it produces 2 granite, doesn't it? After this, there is another line with "mine", so the probability that the line with "produce quartz" will be reached is (5%)².

Then the solution would be to reorder the produce statements to have the precious stones on top.

This would probably achieve that more quartz would be find indeed.

And I thought about another solution which wouldn't contradict yours: What if the probabilities in the "mine"-lines get increased so much that they make sure that the efficiency of the mines will be 5% indeed?

WorldSavior wrote:

GunChleoc wrote:

I'd have to dig deeper into the code to try to understand when workers gain experience, but when mining and the mining fails, there is still a random chance that they will gain experience anyway.

Isn't it also another bug that a miner doesn't get experience if he finds nothing?

I don't really like how this is hard-coded.

Me neither...


*insert phrase about the necessity of saving the world here*

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 2432
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-02-24, 10:45

Found the program selection for the trainingsites:

/**
 * Find and start the next training program.
 *
 * Prioritize such that if UpgradeA.prio is twice UpgradeB.prio, then
 * start_upgrade will be called twice as often for UpgradeA.
 * If all priorities are zero, nothing will happen.
 */
void TrainingSite::find_and_start_next_program(Game& game) {

And the production site has:


void ProductionSite::find_and_start_next_program(Game& game) {
    program_start(game, "work");
}

So, you're right, it's indeed different. There's a lot more code to dig through though before I understand what's really happening, because it also depends on when this function is called and what happens then...

Edited: 2018-02-24, 10:45
Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 626
Ranking
One Elder of Players
Location: Saxony, GER
Posted at: 2018-02-26, 11:34

GunChleoc wrote:

Found the program selection for the trainingsites:

~~~~ / * Find and start the next training program. * Prioritize such that if UpgradeA.prio is twice UpgradeB.prio, then * start_upgrade will be called twice as often for UpgradeA. * If all priorities are zero, nothing will happen. / void TrainingSite::find_and_start_next_program(Game& game) { ~~~~

And the production site has: ~~~~

void ProductionSite::find_and_start_next_program(Game& game) { program_start(game, "work"); } ~~~~ So, you're right, it's indeed different. There's a lot more code to dig through though before I understand what's really happening, because it also depends on when this function is called and what happens then...

I don't understand exactly everything of trainingsites neither, but probably most things...


*insert phrase about the necessity of saving the world here*

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 299
Ranking
Tribe Member
Location: Bavaria
Posted at: 2018-02-26, 21:27

Just found another issue with the crystal mine. I have tried to improve AI performance for Atlanteans on Fullmoon Map which is very poor. The reason is with startin option HQ AI has 4 miners and 8 picks. As AI starts to build 2 crystal_mines as soon as they are allowed. there are only 6 picks left. As usually at least one pick is used for a stonecutter, and 3 are used for a coal mine there is no pick left for an iron mine which lead to a shortage of metal which leads to no pick can be produced and every iron_mine built is dismantled after 6 minutes of unoccupation. This is really kind of a deadlock. Currently I am trying to improve the situation but did not found any other solution than prohiniting the crystal_mine for a very long time, which is not optimal at all.

Any ideas?


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 299
Ranking
Tribe Member
Location: Bavaria
Posted at: 2018-02-26, 22:30

Ok I found out the reason for this behaviour:

Mines which produce Building materials have a minimum amount of 2 hardcoded in defaultai.cc. Currently these are empire_marble_mines and atlanteans_crystal_mines.
For the empire this is never a problem because a basic mine just needs one miner. In the contrary the empire need for marble is much higher than the atlantean need for diamond and quartz, so they really could live well with two marble_mines.
Different story for the Atlanteans they would happily live with only one crystal_mine for a long game time, but really miss the 3 miners in the second_crystal_mine.

So currently I see 3 solutions:
a) Increase number of miners in atlanteans starting conditions
b) decrease workers needed for atlanteans crystal_mine
c) handle these types of mines as any other mines i.e. all mines have a minimum of only one.

I would vote for option c) as it should have minimum impact on empire (they should build a second mine as soon as their marble supply drops) and gives the atlanteans AI a much better chance in the early game.


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1170
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-02-26, 23:37

hessenfarmer wrote:

c) handle these types of mines as any other mines i.e. all mines have a minimum of only one.

I think upgrading was involved in that logic - if we have two of the kind we can safely upgrade one of them. But of course, if mine is not upgradeable, 1 should be enough. But I must admit I dont remember clearly intentions behind the code..


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 2432
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-02-27, 09:14

I agree with c) - we shouldn't change game balance if it can be fixed in the AI. The enhancement is a valid point, you could check for

tribe_->get_building_descr(building_index)->enhancement() != INVALID_INDEX

instead and let the genetic algorithm take care of the rest.

Edited: 2018-02-27, 09:15
Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1170
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-02-27, 09:43

GunChleoc wrote:

I agree with c) - we shouldn't change game balance if it can be fixed in the AI. The enhancement is a valid point, you could check for ~~~~ tribe_->get_building_descr(building_index)->enhancement() != INVALID_INDEX ~~~~ instead and let the genetic algorithm take care of the rest.

This part of logic is not controlled by GA at all.. But we can change the logic like:

if has_enhancement && is_building_material_producer:
 minimal_mines_count = 2
else:
 minimal_mines_count = 1

But this must be tested because it can have unexpected consequences...:)


Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 04:10
Posts: 626
Ranking
One Elder of Players
Location: Saxony, GER
Posted at: 2018-02-27, 15:54

If your fix will not work for what reason ever, you could also think about giving the AI a limit for crystal mines of 1. I mean, for what does an AI need several crystal mines anyway? In most situations it's perfect to build less than 2.

By the way, the crystal mine should be build in almost every match after the three other types of mines...

Let me guess: It would be too complicated to code that the AI can kick out some miners if the tool-economy is not complete yet?

I've observed another idiotic behaviour of the AI. If a mine is not occupied yet, the AI will always dismantle it after a while.


*insert phrase about the necessity of saving the world here*

Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1170
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-02-27, 18:53

WorldSavior wrote:

If your fix will not work for what reason ever, you could also think about giving the AI a limit for crystal mines of 1. I mean, for what does an AI need several crystal mines anyway? In most situations it's perfect to build less than 2.

Good idea, can you create good and simple rule for AI to find out which mines should be limited to 1? Hard-listing is bad approach...

By the way, the crystal mine should be build in almost every match after the three other types of mines...

This is not easy, AI usually build mines as it conquers territories with various ores..

Let me guess: It would be too complicated to code that the AI can kick out some miners if the tool-economy is not complete yet?

There is nothing like "tool-economy" for AI, though I roughly understand what you mean. But when I recall amount of time spent on coding and follow up tweaks and discussion about basic economy, I am not much eager to create another "economy"...

I've observed another idiotic behaviour of the AI. If a mine is not occupied yet, the AI will always dismantle it after a while.

This can be easily tweaked, so what should be "timeout" for unoccupied mine (before AI will dismantle it)?


Top Quote