Workers

Wodan

Deity
Joined
Jun 3, 2005
Messages
4,867
Location
In transit
Has there been any discussion regarding improvement of the moronic workers? Currently you can see things such as:
-- workshopping over cottages while unimproved tiles are present
-- changing an improvement from X to Y while in the very next tile another worker is changing Y to X
-- two workers buiding different improvements in the same tile

The cottage thing especially is pretty critical. It means that all AI teching is lobotomized and, if the human can survive the early game, the AI's ability to tech will fall more and more behind. This is clearly obvious if you play with No Tech Trading.
 
It's been brought up a couple times, and is definitely on my list ...

For those interested in looking through the code, the relevant functions are:

- CvCityAI::AI_updateBestBuild - looks at city's and player's needs and special properties and determines general weightings for production/commerce/food for the plots worked by the city.

- CvCityAI::AI_bestPlotBuild - based on city needs/modifiers, picks best improvement for a plot.

AI_bestPlotBuild has a built in cottage upgrade protection clause:

Code:
	// cottage/villages (don't want to chop them up if turns have been invested)
	ImprovementTypes eImprovementDowngrade = (ImprovementTypes)GC.getImprovementInfo(pPlot->getImprovementType()).getImprovementPillage();
	while (eImprovementDowngrade != NO_IMPROVEMENT)
	{
		CvImprovementInfo& kImprovementDowngrade = GC.getImprovementInfo(eImprovementDowngrade);
		iValue -= kImprovementDowngrade.getUpgradeTime() * 8;
		eImprovementDowngrade = (ImprovementTypes)kImprovementDowngrade.getImprovementPillage();
	}

	if (GC.getImprovementInfo(pPlot->getImprovementType()).getImprovementUpgrade() != NO_IMPROVEMENT)
	{
		iValue -= (GC.getImprovementInfo(pPlot->getImprovementType()).getUpgradeTime() * 8 * (pPlot->getUpgradeProgress())) / std::max(1, GC.getGameINLINE().getImprovementUpgradeTime(pPlot->getImprovementType()));
	}

The naive thing to do would be to simply up these protection multipliers to 10 from 8.

My guess is that food is the source of the instability in switching between cottages and workshops ... a workshopped grassland tile (often) yields only 1F, and so would change the food modifiers to make anything producing 2F more appealing. Once replaced by a cottage, the food modifier drops, making production look more appealing. Rinse and repeat.

Also, wasn't there a bunch of discussion on this in Bhruic's unofficial path thread?
 
Also, wasn't there a bunch of discussion on this in Bhruic's unofficial path thread?

A lengthy discussion which starts in post 1822 (by guess who: Wodan) and goes on for about 100 posts....:p

I do remember some discussion about:
-the AI reimproving tiles in one city while another is still using bare unimproved tiles
-the AI reimproving two tiles at the same time in a city, cottage -> farm + farm -> cottage (what a way to keep people busy ;) )
-the AI changes local city tile improvements caused by empirewide changes which changes the relative valuation of resources (:hammers::commerce::food:): so for instance a war breaks out and the AI starts valuing hammers more and changes some towns into workshops, a resource is lost which makes cities more unhealthy and the AI focusses more on food, a tile improvement gets a civic based bonus and thus replaces some other improvements. Temporary changes which cause reimprovement of tiles. (Reimprovement is bad for cottage development. Reimprovement is sometimes required for irrigation chains.)

There was also considerable discussion between Bhruic and me about whether the city emphasis buttons were maybe hurting the AI. Some repeating changes in these emphasis buttons from production to commerce back to production back to commerce could cause massive reimprovements around such cities.
 
In addition to what Roland says, IIRC, one suggestion was to have a "threshold". i.e., if the AI determines it wants more hammers in the city, the formula for determining how many hammers should add some value, say 15% to the number, before comparing to the actual number of hammers the city has. This would, while not resolve, certainly help with the situation.

Secondly, I would recommend telling the AIs to improve unimproved tiles before it switches an already-improved tile. (Keeping in mind the slight desire to leave a couple of forests until lumbermills become available.)
 
Thanks for the quick summary and the link Roland!

You'll be glad to know that the AI almost never uses emphasis now, so that at least is less of a concern.

You're welcome.

Since which version of BetterAI does the AI use the emphasis buttons less often?

In addition to what Roland says, IIRC, one suggestion was to have a "threshold". i.e., if the AI determines it wants more hammers in the city, the formula for determining how many hammers should add some value, say 15% to the number, before comparing to the actual number of hammers the city has. This would, while not resolve, certainly help with the situation.

Oh, yes, I remember that suggestion. It's a very natural way to resist small changes. I do remember that Bhruic even mentioned that something like that was already being used for cottages (Cottages are the only improvement that should actually somewhat strongly resist change. Changing other tile improvements should just be lower priority than creating new tile improvements). But it must be balanced precisely so that the AI can still change something. You do want the AI to be able to create irrigation paths after the discovery of civil service. And you do want the AI to be able to change some farms after the discovery of biology (when you need less farms to feed your people).
 
All that makes sense, Roland. The biggest issue, as I see it, is conversion of Hamlets, Villages, or Towns. Second biggest is the cycling problem, where the AI constantly changes one to the other, and back again.
 
You're welcome.

Since which version of BetterAI does the AI use the emphasis buttons less often?

Straight BTS actually. From CvCityAI::AI_doEmphasize

Code:
	//Note from Blake:
	//Emphasis proved to be too clumsy to manage AI economies,
	//as such it's been nearly completely phased out by 
	//the AI_specialYieldMultiplier system which allows arbitary
	//value-boosts and works very well.
	//Ideally the AI should never use emphasis.

The AI only emphasizes commerce/research when going after a "first" tech, ie one which gives a bonus for being the first to get it. It will also emphasize great people in a wider range of circumstances. That's it.
 
Will the AI workers still prefer different terrain improvements based on the emphasize buttons? I ask, because if the above is the only and temporary reason for the AI to go into emphasize commerce mode, then it shouldn't start changing terrain improvements around cities. The effect on the short term commerce gain is insignificant and it will cause lost worker turns.

Will the emphasis of great people cause a worker preference for farm tiles? If so, this could cause farming over advanced cottage and other tiles. If the great person emphasis is temporary, then that is a bad thing.
 
Solid points Roland!

Yes, the AI still responds to the emphasize buttons, though the degree is much smaller if it's replacing versus improving a virgin plot. For commerce it's a 1.4x overweighting on commerce for replacing, (1.4 * 1.8)x for new plots. Either way, that should definitely be turned off.

Emphasizing great people does not appear to have any affect on improvement selection.

So, what about response to emphasize buttons for the human player? I certainly have never intended for my workers to replace improvements when selecting emphasize something, though I usually play with leave old improvements on anyway.

Thoughts?
 
Solid points Roland!

Yes, the AI still responds to the emphasize buttons, though the degree is much smaller if it's replacing versus improving a virgin plot. For commerce it's a 1.4x overweighting on commerce for replacing, (1.4 * 1.8)x for new plots. Either way, that should definitely be turned off.

Good to hear that at least one of the causes of the AI reimproving terrain has been identified. :)

Emphasizing great people does not appear to have any affect on improvement selection.

So, what about response to emphasize buttons for the human player? I certainly have never intended for my workers to replace improvements when selecting emphasize something, though I usually play with leave old improvements on anyway.

Thoughts?

I never ever use the worker automation and I never use the emphasis buttons, so I'm probably a bad judge of that. I guess it depends on what the player would expect the workers to do. Maybe there are some players out there who are used to the fact that the workers change terrain improvements based on the emphasis buttons. Maybe there are players out there who prefer a system where workers don't change terrain improvements based on the emphasis buttons and they hated it when this was implemented.
 
Given that there's an in-game option to leave old improvements alone, the worker response to emphasize buttons for the human player is an extremely minor point.
 
....but it would prevent the AI of taking a cottage down to make a irrigation chain, or of changing mines to windmills ( or even of using oil if it is discovered it below a farm ). That is not the best way, I guess.
 
....but it would prevent the AI of taking a cottage down to make a irrigation chain, or of changing mines to windmills ( or even of using oil if it is discovered it below a farm ). That is not the best way, I guess.

Excepting the discovery of new resources beneath existing improvements, I think those might actually be risks worth taking.
 
Solid points Roland!

Yes, the AI still responds to the emphasize buttons, though the degree is much smaller if it's replacing versus improving a virgin plot. For commerce it's a 1.4x overweighting on commerce for replacing, (1.4 * 1.8)x for new plots. Either way, that should definitely be turned off.

Emphasizing great people does not appear to have any affect on improvement selection.

So, what about response to emphasize buttons for the human player? I certainly have never intended for my workers to replace improvements when selecting emphasize something, though I usually play with leave old improvements on anyway.

Thoughts?

Does the AI maybe emphasize food when the city has room to grow and does this cause reimprovement of terrain towards farms? I sometimes see the AI creating lots of extra farms while destroying cottages and those moments seem to be coincide to the moments that the AI acquires new health and happiness resources.

If this happens, it is not necessarily all bad. It can sometimes be a bit better to change some cottages to farms when there is a lot of room to grow and the city is extremely slow growing. However, the worker AI sometimes picks improved tiles over unimproved ones and changes multiple tiles into farms at once. I think these kinds of changes should be a bit more subtle to limit the destruction of advanced cottages.
 
A simple algorithm will be better for the AI than anything complex:

1. Always improve special resources
2. Always mine hills (and chop away the forest from hills)
3. Always cottage grasslands
4. Always irrigate plains

There, that alone should make the AI equal to one extra difficulty level.

Advanced things like irrigation chains or judging if a city has enough food or not (irrigate grasslands) would be nice once the basic groundwork has been lain.
 
No, actually with the way the AI destroys it's cottages, and wastes hammers on unneeded workers, the algorithm as provided above would work better. Not being able to have villages or towns in the industrial and later eras kills the AI, and also the fact the AI cycles through windmills/mines and cottages/farms/workshops means it currently always has an unstable and hectic production supply. To be honest I can compete at emperor, and I pretty much use the above formula... It's affective and will beat the snot out of what the AI currently does, by leaps and bounds. Well actually I do farm alot of grassland, so It'd be best to have the AI flip a coin and decide weather to farm or cottage grassland.
 
The idea would be to start with a simple base algorithm and then expand on that. I don't see anything good coming from trying to mess with the current worker AI, as it is a complete mess. phungus420 explains it well above.
 
Back
Top Bottom