Latest Posts

Topic: Improving the AI

Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-02-09, 17:26

OK,you tired me off face-sad.png

I am more-less convinced, but I have these comments:

  • I can review the code (and approve probably) but I would like if someone else confirmed overall positive changes to the game (I mean tested it)
  • Can we redefine trivial building materials as materials produced by sites with no inputs? Might simplify the logic further...

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

Tibor wrote:

OK,you tired me off face-sad.png

that wasn't my intention. Now I feel sorry.

I am more-less convinced, but I have these comments:

  • I can review the code (and approve probably) but I would like if someone else confirmed overall positive changes to the game (I mean tested it)

Fully acceptable.

  • Can we redefine trivial building materials as materials produced by sites with no inputs? Might simplify the logic further...

Interesting idea. Need to think and check our code. But if possible I'd love that.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-02-10, 14:42

Have thought about the identification of trivial material. could be done from my point by inventing a new bool to WareObserver named raw_build_material or something like this Property could be determined then in running over the building types for BuildingObserver properties as well.
However while looking through the code I did not find a single place where we use the properties consumers and producers from our WareObserver


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-02-10, 15:26

I think WareObserver is good place for this...

this Property could be determined then in running over the building types for BuildingObserver properties as well.

This I dont understand, probably you made some mistake here, the flow might be:

  • to collect all construction materials
  • to find out which ones are produced in sites without inputs

However while looking through the code I did not find a single place where we use the properties consumers and producers from our WareObserver

I cannot find neither


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-02-10, 15:42

Tibor wrote:

I think WareObserver is good place for this...

this Property could be determined then in running over the building types for BuildingObserver properties as well.

This I dont understand, probably you made some mistake here, the flow might be:

  • to collect all construction materials
  • to find out which ones are produced in sites without inputs

What I meant is initializing the bool with false. When we have a building that is producing constructionmaterial and has no inputs we change this to true. Could be done f.e. in the for loop of default.ai line 684 by adding
if (tribe_->is_construction_material(temp_output.first) && bo.inputs == empty) {
wares.at(temp_output).raw_building_material = true;
}

However while looking through the code I did not find a single place where we use the properties consumers and producers from our WareObserver

I cannot find neither

so shall we clean this up?


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-02-10, 15:47

I was not familiar with tribe_->is_construction_material - of course this is better approach

so shall we clean this up?

I think we can


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-02-10, 15:53

I'll try to include these changes in the branch under review and test it. maybe I'll finish this tonight. I will report back here


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2020-02-11, 10:35

Ok,
I implemented the check for raw_build_material and removed the definition of rawlog and granite. This worked ok in first tests.
1. First observation is: the imperial Marble mine is no longer a critical mine now as marble can be obtained (although in low quantities) from quarries. This is covered by having a marble mine in basic economy though and did not work that bad in the tests.
2. Second observation: For whatever reason AI now starts with 2 coal mines instead of 1 before the change. I have no explanation for this yet though. Furthermore it does not dismantle a coalmine if a critcal mine needs some workers, as it should be. This is bad for atlanteans as they get deadlocked on Full Moon without this feature currently I believe the problem is within the detection of critical_mine_unoccupied as the AI tends to always build 2 of them while the the check assumes there is only one.
3. Due to my research for 2. I beleive it is more efficient to evict workers instead of dismantling to achieve the workers released. So I'd like to change dismantle to evict workers for this special case after I have fixed the detection of unoccupied critical mines.
4. The definition of ironore() is only used once in the code where in every other instance the iron_resource_id is used to identify an iron mine, so I propose to get rid of this attribute as well as it might lead to inconsistency. Alternatively I'd change everything to use the ironore() definition and probably reintroduce the kIronMine property to achieve this. Anyhow this should be harmonized to prevent weird behaviour if the ironore() is defined alternatively (as in the Europeans for example).


Top Quote
Tibor

Joined: 2009-03-23, 23:24
Posts: 1377
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2020-02-11, 10:49

Aa for 2, the problem might be here:

// Identify iron mines based on output
if (bo.ware_outputs[0] == tribe_->ironore()) {
    bo.set_is(BuildingAttribute::kIronMine);  <- was replaced

So the coal mine might be considered as ironmine...

EDIT: now I am not sure....

Edited: 2020-02-11, 10:58

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

Tibor wrote:

Aa for 2, the problem might be here:

// Identify iron mines based on output
if (bo.ware_outputs[0] == tribe_->ironore()) {
    bo.set_is(BuildingAttribute::kIronMine);  <- was replaced

So the coal mine might be considered as ironmine...

No that is not the case. in the next 2 lines the Iron mine is set to be a critical mine and this can't happen for the coalmine in the code. I was suspecting that by some weird routine the coal mine might be considered as MatProducer but this isn't the case either. Basically it isn't to bad for the AI to have 2 coalmines. It is only a problem for atlanteans if there aren't enough miners left for the first ironmine. So if I can fix the issue of relieving workers to occupy the first ironmine everything should be fine.
Only thing that needs more intense testing is the change in empire marble production. But I will do that after I have made everything working as intended.

EDIT: now I am not sure....


Top Quote