Post 0.41h AI feedback needed

It doesn't look like the Sheiam are building their planar gates nor the Illians their Temples of the White Hand.

The Sheaim build the planar gates if the AC goes above 30, since they aren't very worthwile in a low AC game.
I wrote some logic in my mod when the AI should build the temple of the hand( it checks for floodplains/tundra/rivertiles/deserts and jungle in the fat cross and calculates then whether building the temple would be an improvement), but that did not get ported into Sephi's AI_chooseproduction function.
 
I just played a game as the Bannor, and after doing a few crusades to wipe Kilmorph and Fellowship out, I bordered the Sheaim and Infernals (Both AV, Tebryn had summoned Hyborem). Since the power graph showed I was about twice as powerfuil as Tebryn, I sent my massive Stack of Doom, consisting of Valin McPhanuel, Donald Lugh, Sphener, Gilden Silveric (captured from the Ljosalfar after he lost an epic battle against Sphener), four Paladins, and about 100 Champion, Confessors, and some siege, into his lands. They first torched the AV holy city to the ground, and then came across Tebryn's Stack of Doom (much smaller then mine). Tebryn attacked, and using Rust, Fireballs, Spectres, and Pire Zombies, they completly wiped out my stack including the four heroes. Wow, I definatly didn't expect the AI to do something as smart as that.

I have noticed that turning the "AI ignores building requirments" option on means the AI will be much smarter in which units to build, and there will be no warrior stacks. Maybe it should be made to be on by default.
 
That's already been done. Feel free to try to improve the code in cvgameutily AI_chooseproduction if you think it is lacking something
 
I haven't seen a problem with the AI not building requisite buildings. Yes, the AI produces huge stacks of Warriors, but then it also upgrades them to Axemen (which means it built a Training Yard) or Archers (which means it built an Archery Range). Is the AI not upgrading units in your games, deanej?

The "ai ignores building requirements" setting helps the AI not because it allows it to bypass a systemic failure to build required training buildings, but because it allows the AI to directly build units that a human player can only get by upgrading an experienced unit. For example, instead of upgrading a level 6 unit to a Druid the AI will be able to just build a Druid directly. The only change that should be noticed when dealing with lower-tier units (which have no such upgrade requirements) is that the AI will upgrade its units sooner (because they don't have to pass by a city with a training building before the upgrade can take place) and the AI will have slightly more units (because it doesn't have to spend production on the training building itself).
 
I have been playing some games teamed with the AI and I think I found out why they keep stalling their cities when not a war. I constantly seeing it just leaving it's cities production queue empty.

This is what I am seeing before I made any modification. A few of these cities are my allies and some are not. You can see that 8 of the 14 cities have no production assigned. Most of them have one or two buildings and that is it.
before-change.jpg

I believe the AI is in a state of wanting to train workers on one hand and not being able to on the other. This continues every turn until it captures some workers or loses some cities. I modified the thrid statement to match the first's multiply which after one turn of my current game caused every city to start doing something productive.

CvGameUtils.pl: AI_chooseProduction
Code:
if 2 * pPlayer.getNumCities() > pPlayer.getUnitClassCountPlusMaking(gc.getInfoTypeForString('UNITCLASS_WORKER')):

So the AI here is basically deciding that it needs more workers. By the end of the fuction that leads to:

Code:
pCity.pushOrder(OrderTypes.ORDER_TRAIN,iUnit,-1, False, False, False, False)

Eventually this leads into the cannotTrain function in the same python file. However, there is lower threshold used here:

Code:
pPlayer.getNumCities() + 2 <= pPlayer.getUnitClassCountPlusMaking(gc.getInfoTypeForString('UNITCLASS_WORKER')):

This would also explain why in most of my games the AI starts off strong and then falls apart: 2*2 = 2+2 When the third city is built this no longer holds and then cities start to become dormant. It thinks it wants 3*2 workers but is only allowed to build 3+2.

Here is the same screen shot the turn after I change the addition to multiplication. You can see there are a couple of workers being built and every city has some production order. I am going to try another game from scratch and see if I have any other issues after this modification.
after-change.jpg
 
So I started up another game and ran into issues as it progressed.

The basis of the problem is that there are two things controlling the AI.
1) AI_chooseProduction
2) cannotConstruct/cannotTrain

The first one is choosing and the second is taking the input of the first and rejecting. The issue I found before and the one I am encountering are really the same thing. A civilization wants to build adepts but are over the limit defined in cannotTrain. The first function is not considering what the second one is going to return. So the AI becomes deadlocked because it cannot build what it is choosing to build.

I would suggest that the second set of functions should be deprecated and only choose those things to build that need to be build. However, I am not familiar with this code base so that might be a little heavy handed as a solution.
 
I have encounted the same problems, it's fixable by normalizing the critereas in cannotX and aiChooseproduction. In most cases you can just inactivate the conflicting cannotX by inserting a # at the start of the lines and they will go soly by aiChooseproduction just as well. I think this is where Sephi has put his focus and that canX/cannotX are most residues from similar mods that have bin used as inspiration.

If you go into Worldbuilder and finds a lot of AI-cities without any production, they have hit a confliction as you have descibed.
 
I have encounted the same problems, it's fixable by normalizing the critereas in cannotX and aiChooseproduction. In most cases you can just inactivate the conflicting cannotX by inserting a # at the start of the lines and they will go soly by aiChooseproduction just as well. I think this is where Sephi has put his focus and that canX/cannotX are most residues from similar mods that have bin used as inspiration.

If you go into Worldbuilder and finds a lot of AI-cities without any production, they have hit a confliction as you have descibed.
I think I have found the troublemaker. in Cvgameutils.py in cannottrain change.

Code:
if pPlayer.isHuman() == False and bContinue == False:
to

Code:
if pPlayer.isHuman() == False:

this means, that the cannottrain callback is also triggered for the cantrain call in the chooseproduction function. Some feedback would be nice if it works.
 
Seems to work for me. Lategame in a test game i just played 2 cities that wanted to build adepts stopped production. After do the change in code that you suggested and reloading the latest autosave they chose other production instead.
 
Top Bottom