Latest Posts

Topic: Rework Atlantean Crystal Mine

teppo

Joined: 2012-01-30, 08:42
Posts: 423
Ranking
Tribe Member
Posted at: 2018-02-27, 19:40

WorldSavior wrote:

While barbarian iron mines need 20 times more resources when depleted, atlantean iron mines need 50 or 100 times more. I don't think that this is how it was intended... And it's not fair.

Would it help if the first consume-animate-mine-produce -cycle of mine_quatz in the Atlantean crystal mine would produce at least one quartz, instead of granite only?


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2018-02-27, 19:52

Ok I had another look in the code

So if I get it right the minimum mines won't be upgraded at all (defaultai.cc line 4431 following) so for me it would be perfectly fine if every type of mine has just a minimum of 1 and every other instance will be build if the output is needed. Anyhow the code suggested by Tibor

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

would only be applicable for the empire marble mine. So I would like to test a branch where this has been set to 1 for all (line 4435 would look like : const uint16_t minimal_mines_count = 1)

Regarding the dismantling of mines if not fully occupied I can't see any logic in that. Instead every worker that might be in this mine should be expelled instead and this should be checked in the interval already given.

Last but not least I would not limit the number of mines as usually the AI builds not enough of them anyway. But if you think for example about the case the whole discussion started about it might be correct to build more of them and even keep depleted ones. Although this would be a corner case it is not covered by the current algorithm as all depleted mines except for the minimum amount would be dismantled.

So if I disregard the latter corner case, I would love 2 changes:
1. set minimum for every type of mine to 1
2. change dismantle unoccupied mines to expel workers from unoccupied mines every time interval given.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-02-27, 20:22

hessenfarmer wrote:

Ok I had another look in the code

So if I get it right the minimum mines won't be upgraded at all (defaultai.cc line 4431 following) so for me it would be perfectly fine if every type of mine has just a minimum of 1 and every other instance will be build if the output is needed.

Minimum mines means that they will not be dismantled even if there is lack of workers. But it does not keep them from upgrading. Note: this number is count of mines of all levels (so 3 iron mines (normal, deep, deeper) for barbarians and so on)

I strongly recommend you to start playing with the C++ code directly and test your ideas. Much better than theoretical discussions.

Anyhow the code suggested by Tibor

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

would only be applicable for the empire marble mine. So I would like to test a branch where this has been set to 1 for all (line 4435 would look like : const uint16_t minimal_mines_count = 1)

Regarding the dismantling of mines if not fully occupied I can't see any logic in that. Instead every worker that might be in this mine should be expelled instead and this should be checked in the interval already given.

The idea of dismantling is just to expel any miner that might be in it. I personally prefer get rid of such mine (keeping minimal count of course) then keep it for perhaps hours, but it is just matter of opinion and any change should be tested...

Last but not least I would not limit the number of mines as usually the AI builds not enough of them anyway. But if you think for example about the case the whole discussion started about it might be correct to build more of them and even keep depleted ones. Although this would be a corner case it is not covered by the current algorithm as all depleted mines except for the minimum amount would be dismantled.

So if I disregard the latter corner case, I would love 2 changes:
1. set minimum for every type of mine to 1
2. change dismantle unoccupied mines to expel workers from unoccupied mines every time interval given.

Just go on, and I can help you with needed changes in code if you will need help...


Top Quote
GunChleoc
Avatar
Topic Opener
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-02-28, 06:50

teppo wrote:

WorldSavior wrote:

While barbarian iron mines need 20 times more resources when depleted, atlantean iron mines need 50 or 100 times more. I don't think that this is how it was intended... And it's not fair.

Would it help if the first consume-animate-mine-produce -cycle of mine_quatz in the Atlantean crystal mine would produce at least one quartz, instead of granite only?

I think it would. We should do the same for diamonds.


Busy indexing nil values

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2018-02-28, 07:17

Tibor wrote:

I strongly recommend you to start playing with the C++ code directly and test your ideas. Much better than theoretical discussions.

here is the problem I neither did manage to compile on windows nor do I knoe how to code in c++. Reading the code is hard enough for me (obviously I don't get everything right)

The idea of dismantling is just to expel any miner that might be in it. I personally prefer get rid of such mine (keeping minimal count of course) then keep it for perhaps hours, but it is just matter of opinion and any change should be tested...

Problem is this leads to dismantling - building another mine of this type - dismantling cycles which are spoiling precious building materials. expel any miners from not fully occupied mines and wait if enough miners will be produced in the meantime makes more sense from an AI point of view) as a human would do so as well. an empty mine does not consume any ressources (cause AI sets input to zero if not occupied) so it is cheaper to keep the building and just expel the workers.

Just go on, and I can help you with needed changes in code if you will need help...

As I said this is to complicated for me. I'd rather spend my time watching the AI and reporting any behaviour that I don't understand.


Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-02-28, 08:40

Point 1 is trivial to implement.

But point 2 is part of bigger logic dealing with when a mine can be dismantled / upgraded and the change there is not that straightforward (like changing one line of code). Somebody should seriously sit over the entire check_mines() function and redesign it. So this is why I am afraid to touch it. My experience is that tweaking such complex code is multi step process, because there are always exemptions and corner cases for each rule...

EDIT: for example - if AI has 10 coal mines, 9 of them unoccupied, should it still keep all 9 "forever"?

Edited: 2018-02-28, 22:22

Top Quote
WorldSavior
Avatar
Joined: 2016-10-15, 03:10
Posts: 2094
OS: Linux
Version: Recent tournament version
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-03-01, 18:26

Tibor wrote:

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?

I thought about the AI-limit of crystal mines in the lua-files. I know that something like "weak_ai_limit" and "very_weak_ai_limit" exists... Does also an "ai_limit" exist? Every mine which is not the crystal mine shouldn't be limited to 1. face-wink.png

Hard-listing is bad approach...

Why, because of possible new tribes in the future?

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..

It would help if the crystal mine would get the highest number at "prohibited till", wouldn't it?

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.

Tool-economy is the part of the economy which creates tools.

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)?

They shouldn't dismantle them, check out hessenfarmers posts...

hessenfarmer wrote:

Regarding the dismantling of mines if not fully occupied I can't see any logic in that. Instead every worker that might be in this mine should be expelled instead and this should be checked in the interval already given.

+1

Last but not least I would not limit the number of mines as usually the AI builds not enough of them anyway.

Is that true for crystal mines?

But if you think for example about the case the whole discussion started about it might be correct to build more of them and even keep depleted ones.

The AI isn't able yet to use depleted mines (at least in build19). But if it learns it, the limit will be a problem, that's true.

GunChleoc wrote:

teppo wrote:

WorldSavior wrote:

While barbarian iron mines need 20 times more resources when depleted, atlantean iron mines need 50 or 100 times more. I don't think that this is how it was intended... And it's not fair.

Would it help if the first consume-animate-mine-produce -cycle of mine_quatz in the Atlantean crystal mine would produce at least one quartz, instead of granite only?

I think it would.

How?

We should do the same for diamonds.

Sure?

@teppo: Crystal mines don't influence iron mines directly. And the first program of the crystal mine already produces one quartz instead of granite only.

hessenfarmer wrote:

Tibor wrote:

The idea of dismantling is just to expel any miner that might be in it. I personally prefer get rid of such mine (keeping minimal count of course) then keep it for perhaps hours, but it is just matter of opinion and any change should be tested...

Problem is this leads to dismantling - building another mine of this type - dismantling cycles which are spoiling precious building materials. expel any miners from not fully occupied mines and wait if enough miners will be produced in the meantime makes more sense from an AI point of view) as a human would do so as well. an empty mine does not consume any ressources (cause AI sets input to zero if not occupied) so it is cheaper to keep the building and just expel the workers.

Well observed


Wanted to save the world, then I got widetracked

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-03-01, 19:45

WorldSavior wrote:

Tibor wrote:

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?

I thought about the AI-limit of crystal mines in the lua-files. I know that something like "weak_ai_limit" and "very_weak_ai_limit" exists... Does also an "ai_limit" exist?

No, but it is probably good approach, at least this is not first time it is asked for

Every mine which is not the crystal mine shouldn't be limited to 1. face-wink.png

Hard-listing is bad approach...

Why, because of possible new tribes in the future?

That.

+ changing atributes of current mines (like production programs)
+ renaming such mines

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..

It would help if the crystal mine would get the highest number at "prohibited till", wouldn't it?

Yes, it would "HELP", but would be no guarantee that all other mines are built before that time limit

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.

Tool-economy is the part of the economy which creates tools.

AI does not recognize anything like this. It might take ~20 hours to code the thing IMHO

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)?

They shouldn't dismantle them, check out hessenfarmers posts...

Even if the AI has 20 unoccupied mines?

hessenfarmer wrote:

Regarding the dismantling of mines if not fully occupied I can't see any logic in that. Instead every worker that might be in this mine should be expelled instead and this should be checked in the interval already given.

+1

You have 300 coal on stock and 10 unoccupied coal mines, and 1 unoccupied iron mine - and AI will forever expel miners from coal mines hoping that once he finally gets into the iron mine and will start working...

hessenfarmer wrote:

Tibor wrote:

The idea of dismantling is just to expel any miner that might be in it. I personally prefer get rid of such mine (keeping minimal count of course) then keep it for perhaps hours, but it is just matter of opinion and any change should be tested...

Problem is this leads to dismantling - building another mine of this type - dismantling cycles which are spoiling precious building materials. expel any miners from not fully occupied mines and wait if enough miners will be produced in the meantime makes more sense from an AI point of view) as a human would do so as well. an empty mine does not consume any ressources (cause AI sets input to zero if not occupied) so it is cheaper to keep the building and just expel the workers.

Well observed

Perhaps building new mines should be tweaked here. Or both, dismantling and building as well.


Top Quote
GunChleoc
Avatar
Topic Opener
Joined: 2013-10-07, 14:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-03-02, 07:05

Hard-listing is bad approach...

Why, because of possible new tribes in the future?

That.

+ changing atributes of current mines (like production programs)
+ renaming such mines

Exactly. It also means recompiling every time that we want to test a change.

GunChleoc wrote:

teppo wrote:

WorldSavior wrote:

While barbarian iron mines need 20 times more resources when depleted, atlantean iron mines need 50 or 100 times more. I don't think that this is how it was intended... And it's not fair.

Would it help if the first consume-animate-mine-produce -cycle of mine_quatz in the Atlantean crystal mine would produce at least one quartz, instead of granite only?

I think it would.

How?

Because a failed mining step might fail the whole program. See the discussion above how the whole program is aborted, never reaching the later stages where it actually produces a precious stone.

         actions = {
            "return=skipped unless economy needs granite or economy needs quartz",
            "sleep=45000",
            "consume=smoked_fish,smoked_meat:2 atlanteans_bread:2",
            "animate=working 20000",
            "mine=stones 4 100 5 2",  -- let's say this succeeds
            "produce=granite:2",      -- we get granite only here
            "animate=working 20000",
            "mine=stones 4 100 5 2",  -- let's say this fails, then the whole program potentially aborts (needs to be verified, but the code is complicated)
            "produce=granite:2",      -- never reached, so nothing produced
            "animate=working 20000",
            "mine=stones 4 100 5 2",
            "produce=granite",
            "animate=working 20000",
            "mine=stones 4 100 5 2",
            "produce=quartz"          -- never reached, so no quartz this time!
         }

We should do the same for diamonds.

Sure?

Well, mathematically the same "it's not really 5%" argument holds, doesn't it?

hessenfarmer wrote:

Regarding the dismantling of mines if not fully occupied I can't see any logic in that. Instead every worker that might be in this mine should be expelled instead and this should be checked in the interval already given.

+1

You have 300 coal on stock and 10 unoccupied coal mines, and 1 unoccupied iron mine - and AI will forever expel miners from coal mines hoping that once he finally gets into the iron mine and will start working...

Yes, but that's not bad per se - it's the same thing that a human would do. The worker will find his way to the iron mine eventually. Some scoring might help here - maybe devalue building or upgrading a mine if there are too many unoccupied ones.


Busy indexing nil values

Top Quote
Tibor

Joined: 2009-03-23, 22:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2018-03-02, 08:02

GunChleoc wrote:

You have 300 coal on stock and 10 unoccupied coal mines, and 1 unoccupied iron mine - and AI will forever expel miners from coal mines hoping that once he finally gets into the iron mine and will start working...

Yes, but that's not bad per se - it's the same thing that a human would do. The worker will find his way to the iron mine eventually. Some scoring might help here - maybe devalue building or upgrading a mine if there are too many unoccupied ones.

But this is what I am talking about - this is not one line change...


Top Quote