Question about Workers

BumpNsubz

Warlord
Joined
Jan 5, 2007
Messages
123
Some of you have mentioned that you've seen the AI do some pretty stupid build/re-builds of improvements by their workers. A few things popped into my head almost immediately...

I don't even pretend to act like I know how to read the XML code so this question is directed to those of you who do. Is there a certain check the AI does each turn that tells it what improvement is needed? And if so could this explain why a worker would build a workshop over a farm, few turns later the check says not enough food, so the worker builds a farm back over it? If one worker is remedying the fix and another becomes free, does the AI know this, or will it also try to remedy the fix only to find it wasn't needed in the first place therefore turning right back around and improving it back to what it was?

My other question is....

Could it just be that in the beginning of the game certain things were needed for the city to grow and not needed in the latter part of the game? For instance: A grassland tile early in the game with a farm produces +3 :food:. You build 4 farms on grasslands so your food output from those 4 tiles becomes +12 :food:. Now it's later in the game and you've teched Biology which causes farms to produce an extra +1 :food:. Assuming that this particular city is NOT your GP Farm, wouldn't it be more beneficial to take one of those farms and cottage it? Or even better when you can build a Supermarket for the +1 :food:, change 1 farm to a workshop.

4 farms pre-biology on grasslands = +12 :food: / post biology = +16 :food:
3 farms post-biology with supermarket and 1 workshop on grasslands = +14 :food: +4 :hammers:
3 farms post-biology and 1 town = +14 :food: +1 :hammers: (civic needed) +5-8 :commerce: (civic + leader trait specific)

assuming my math is right and there are no bonuses to specialists, the extra :hammers: or :commerce: far outweigh the benefits of the extra +2 :food: from leaving the farm improvement.

Agree or disagree?
 
I can't comment on the AI behaviour but I agree that changing a tile improvement can be very beneficial. I don't think that anyone would disagree with that.

It isn't necessary in the early game very often. Instead of transforming a farm into a cottage it is much better to simply build a cottage on an unimproved tile. That way you can switch from food to commerce whenever you want.

Rince
 
It's not simply changing improvements over time that we're talking about here.

The automated or AI workers will build a farm, then immediately build a cottage, then immediately a farm again, over and over. It will do this all over the place. On hills, it'll flip constantly between windmills and cottages. This is pretty much all they did in Warlords (they work fine in vanilla), but it seems they also throw workshops into the mix in BtS, changing improvements continuously.

There are two plausible sources for this error that I can think of. Initially, you start with the fact that the code governing AI/automated workers has to calculate what improvement should be on a given tile.

Factors that go into this calculation must include what other improvements there are in the neighborhood. The AI is pretty good at spreading farms when tech allows, so it's not even just other improvements in the city's workable tiles, but basically all improvements in a contiguous cultural area. So one possible explanation is that the code which checks what to build doesn't account for what's currently being built, so when workers complete an improvement, that throws off the determination for other tiles in the same area, which causes those improvements to be changed, which in turn changes the determination for the original tile, and so on. I don't favor this theory, because it kind of requires that the code in question be much more complex than a competent programmer would make it. The proper way to calculate is to determine what all tiles should be in a contiguous area, period, then set the workers loose to make that a reality. Only new technologies or a change in the geometry of the area would (possibly) change the tile determinations.

Another possibility (one that I favor due to the ease with which such a mistake can be made) is that sometimes the determination of what to build comes up a tie between two (or more) improvements. The AI has to decide to build *something*, so it flips a virtual coin. But the next time improvement calculations are made, the randomized result might make it different, so when the worker is done, it suddenly has new orders to change the same tile to something else. If that's the nature of the problem, then the solution is pretty simple - instead of randomizing the choice, use the existing improvement to weight the choice. If the choice is even between farm, workshop, and cottage, and the tile already has one of those improvements on it, then the choice is that improvement. Only if there is no improvement at all should the choice be randomized.

The actual nature of the root problem might be neither, of course. I only know that workers functioned properly in vanilla, and were broken in Warlords, then at least not entirely fixed in BtS (there seem to be less workers constantly flipping between farm and cottage, for example).

I suppose it might be possible to create an add-on that fixes the worker behavior, but I'm currently too lazy to consider even finding out if that's the case.
 
So one possible explanation is that the code which checks what to build doesn't account for what's currently being built, so when workers complete an improvement, that throws off the determination for other tiles in the same area, which causes those improvements to be changed, which in turn changes the determination for the original tile, and so on.

This is exactly what I was thinking too, but I agree that the code would have to be outlandish.

I don't favor this theory, because it kind of requires that the code in question be much more complex than a competent programmer would make it. The proper way to calculate is to determine what all tiles should be in a contiguous area, period, then set the workers loose to make that a reality. Only new technologies or a change in the geometry of the area would (possibly) change the tile determinations.

The only problem I see with that is, when a city is first founded for the AI and an assessment is given for what improvements need to be built, the factor of future Tech's need to be accounted for. So something in the meantime needs to be built in the tile that say, for example, will EVENTUALLY have a workshop but can't be built at the moment.

When the city is built, it should run through a series of possibilities (checks) to see what the best possible combinations are IF all improvements WERE to be possible. This would also have to take into account city specialization and such so that not all cities are :gp: Farms or all :hammers: Cities etc,...

Another possibility (one that I favor due to the ease with which such a mistake can be made) is that sometimes the determination of what to build comes up a tie between two (or more) improvements. The AI has to decide to build *something*, so it flips a virtual coin. But the next time improvement calculations are made, the randomized result might make it different, so when the worker is done, it suddenly has new orders to change the same tile to something else. If that's the nature of the problem, then the solution is pretty simple - instead of randomizing the choice, use the existing improvement to weight the choice. If the choice is even between farm, workshop, and cottage, and the tile already has one of those improvements on it, then the choice is that improvement. Only if there is no improvement at all should the choice be randomized.

I agree with this also. It may be a little of both idea's and probably a few others not thought of/mentioned.

I used the automated workers A LOT in Civ 3 when I was learning how to play and feel that it made me a better planner/player quicker by watching what and why my workers built what they did and when. With it being broke like this, and others thought/think like I did when I was first learning, I feel without some sort of fix it will start turning new players away and frustrate those who are still in the learning curve to play on higher levels (I'm still stuck on Noble with BTS).
 
I think the biggest problem with AI Worker logic is the AI seems to value "balanced" cities too highly.

So when the AI evaluates terrain, it might have food and hammers at a 1.1:1.0 ratio, so it decides to replace a Farm with a Workshop. Afterwards, however, the city is left at 1.0:1.1, so the re-evaluation determines the Workshop should be replaced by a Farm.

And round-n-round it goes -- continuing this "balancing act" all over with every improvement.

This might also explain why the AI sometimes levels fully developed Towns only to replace them with a Cottage and walk away.

Meanwhile, human players value highly specialized cities, so instead of balancing the ratio, we try to unbalance it to the extreme. Thus, it's easy for us to make permanent improvement decisions.

I think if the AI's city specialization skills were polished, the odd Worker behaviour would cease (IIRC, Bh is currently tweaking AI city placement and plot valuation, so perhaps his changes might result in better Worker logic).


-- my 2 :commerce:
 
AI-controlled workers can indeed do strange things. In one AI's fat cross I have seen unimproved tiles whilst one worker was building a farm over a cottage and another building a cottage over a farm. The only way to prevent such idiocies happening in your human-controlled territory is NEVER to automate your workers (with the possible exception of "build trade network" combined with "leave exisiting improvements"). Furthermore, do not place total trust in the city governor, who frequently puts citizens to work in curious places, ignoring newly-built cottages and piling up priests and spies.
 
I think if the AI's city specialization skills were polished, the odd Worker behaviour would cease (IIRC, Bh is currently tweaking AI city placement and plot valuation, so perhaps his changes might result in better Worker logic).


Glad to hear someone is tweaking it. If I knew how, I surely would be trying also.

On another note, I don't understand why the AI doesn't tailor to its own traits. For instance Financial Leaders cottage spamming. Maybe this is also due to the oversimplification of "balanced" cities.

Does the AI keep this balancing act going on more difficult levels? And if so, should we be following suit? I guess I'm saying, have your :gp: Farm, :science: City, :gold: City, and balance the rest. I don't generally do this myself. I try to specialize every city to its fullest potential, not balance it out.
 
Back
Top Bottom