Does the AI search for resources or does it instantly know where they all are?

Socratatus

Emperor
Joined
Jul 26, 2007
Messages
1,636
What I mean is, is the AI made `blind` to resources it should not know about until it actually comes across it from searching?
 
I think the AIs are all knowing. They know where every resource and unit is on the board regardless of fog of war, or current tech level, but I may be wrong.
 
I haven't seen code inside the dll that supports such claims. Thus, until somebody shows proof in the form of code, it's all a myth.
 
I haven't seen code inside the dll that supports such claims. Thus, until somebody shows proof in the form of code, it's all a myth.

I don't have code proof, but I did see a CS with a fishing boat camped out on a tile for an eternity. I was playing Austria, so I diplomatically married the CS. Upon researching Biology, I discovered that it was an offshore Oil deposit. This was a while ago, so such an event might have been coded out or something.
 
So the consensus is unsure. Interesting.
 
Ai for sure has Libe of sight, but I believe they see all future resources on tiled they can see.
 
You guys need to be more specific (i.e. provide and context/scenario). Do you mean that:

- The AI knows that there is a luxury resource that can be improved (i.e. "through the eyes of the worker/work-boat")?
- The AI knows that there is some sort of luxury resource (i.e. happiness from improvement-on-connection-to-trade-network) on a tile when evaluating the area for city placement?
- etc.

The AI has access to different levels of information depending on the specific context.
 
On the Spain DCL
Spoiler :
Boudicca always moves her second settler to the same spot. She does this every time, regardless the number of times you play that map.

Now tell me how the AI can calculate the fertility of a spot it technically hasn't seen yet, especially as it probably set of on turn 0? Unless it knows it's getting some kind of resource. You got to remember the dll is the part we are allowed to mod, there will be lots more code buried deep within the exe that we can't see. I have lots of anecdotal evidence that the AI knows where the strategic resources are, just no "scientific" evidence. In some courts of law circumstantial evidence is enough to convict......
 
Without a shadow of the doubt, the AI knows where resources are, without seeing them.

Not only is the Boudicca move on the Spain DCL proof in and of itself, but when I was the host of the DCL and experimenting with maps (both ones I used and didn't) I would do interesting stuff on IGE like put a mountain range between an AI and a great spot with NW and 2 luxes. It would beeline there every time. They know for sure.
 
You guys need to be more specific (i.e. provide and context/scenario). Do you mean that:

- The AI knows that there is a luxury resource that can be improved (i.e. "through the eyes of the worker/work-boat")?
- The AI knows that there is some sort of luxury resource (i.e. happiness from improvement-on-connection-to-trade-network) on a tile when evaluating the area for city placement?
- etc.
My first post was simple yet very clear.


Without a shadow of the doubt, the AI knows where resources are, without seeing them.

Not only is the Boudicca move on the Spain DCL proof in and of itself, but when I was the host of the DCL and experimenting with maps (both ones I used and didn't) I would do interesting stuff on IGE like put a mountain range between an AI and a great spot with NW and 2 luxes. It would beeline there every time. They know for sure.

Thanks for the info. A pity, but oh well. I guess it`s too hard to make an AI `blind` to what it shouldn`t see.:sad:
 
I don't have code proof, but I did see a CS with a fishing boat camped out on a tile for an eternity. I was playing Austria, so I diplomatically married the CS. Upon researching Biology, I discovered that it was an offshore Oil deposit. This was a while ago, so such an event might have been coded out or something.

You guys need to be more specific (i.e. provide and context/scenario). Do you mean that:

- The AI knows that there is a luxury resource that can be improved (i.e. "through the eyes of the worker/work-boat")?
- The AI knows that there is some sort of luxury resource (i.e. happiness from improvement-on-connection-to-trade-network) on a tile when evaluating the area for city placement?
- etc.

The AI has access to different levels of information depending on the specific context.

I was referring to the AI being aware of the location of a Strategic Resource long before it was revealed on the map. I'm not sure if it's the same as what the OP was talking about because the CS wasn't settling another city there, but I thought it might still be relevant.
 
I can confirm that no, the AI cannot see resources before it has researched the necessary tech, not even when it calculates plot fertility: the only thing it can see that it shouldn't when it comes to plots is that fertility calculations ignore fog of war, so an AI will know that a plot is a "good" place to settle before it has scouted the area around the plot.
Check the functions yourselves, the AI is located 100% in the DLL, it's just incredibly unwieldy: eg. the code to prioritize techs based on nearby resources is CvPlayerTechs::SetLocalePriorities(), the code to calculate fertility values (which resources feed into) is all in the CvCitySiteEvaluator class, and the code to determine where workers and work boats go is in CvHomelandAI.

Circumstantial evidence is just circumstantial: for example, plot fertility calculations are deterministic, so of course Boudicca in the DCL will always settle the same, high fertility plot each time, regardless of whether the plot would give her access to resources that she does not see on the map. Work boat idling logic is weird, but it does not factor in resources at all (it just follows the same logic as the idling logic for great people, albeit in the ocean).
 
Circumstantial evidence is just circumstantial: for example, plot fertility calculations are deterministic, so of course Boudicca in the DCL will always settle the same, high fertility plot each time, regardless of whether the plot would give her access to resources that she does not see on the map. Work boat idling logic is weird, but it does not factor in resources at all (it just follows the same logic as the idling logic for great people, albeit in the ocean).

Well, you looked into the actual game code so I certainly can't argue with that. The only thing I can think of for my Work Boat example is that IIRC it was my first game with Austria (which would put it in the G&K era) and there was a patch that came out that tweaked the AI - one tweak was to make the AI better at prioritize building UIs (In the patch notes, they specifically mentioned the Brazil Wood Camp which would place it in the BNW era). So maybe that patch altered the Work Boat behavior.

Either that or I'm having a prolonged hallucination. Or maybe this is all just a dream and I'm really lying in a stasis tube having my life-force sucked out of me.
 
What is a fertility calculation?

The spot that Boudicca heads for in the Spain DCL has resources but is quite a poor city location in terms of farmable tiles and especially in terms of hammers.
 
Well, you looked into the actual game code so I certainly can't argue with that. The only thing I can think of for my Work Boat example is that IIRC it was my first game with Austria (which would put it in the G&K era) and there was a patch that came out that tweaked the AI - one tweak was to make the AI better at prioritize building UIs (In the patch notes, they specifically mentioned the Brazil Wood Camp which would place it in the BNW era). So maybe that patch altered the Work Boat behavior.
I can see the bits of code in the worker automation logic that were added to increase AI prioritization of UIs, and none of it is related to work boats. Work boat automation is incredibly simple: the AI checks which resources it can build improvements on, then targets the closest resource with each work boat, after which all remaining work boats just act like idle civilian units. Legions, Samurais, and other non-worker units that can build improvements are never used by the AI to build improvements (except Great People improvements of course, but that's a separate issue).

What is a fertility calculation?

The spot that Boudicca heads for in the Spain DCL has resources but is quite a poor city location in terms of farmable tiles and especially in terms of hammers.
Plot fertility is the way the AI scores the value of settling any given plot; human players see this as yellow city icons. Its base value is determined by the sum of all yield values for the given plot as well as the Happiness, Resource, and Strategic value of the plot. In the case of yield values, the AI takes the total amount of each yield available in each ring around the plot and multiplies that value by a ring multiplier (6/3/2 for 1/2/3 tiles away), a yield-specific value multiplier (15/3/1/1/0/1 for Food/Hammers/Gold/Science/Culture/Faith), and a flavor multiplier (values based on the player's flavor values for Growth, Expansion, Production, Wonders, Gold, Tile Improvement, Science, Culture, and Religion). Happiness and Resource values are checked up to 5 tiles away with the ring multipliers of 6/3/2/1/1, a multiplier of 60 and 10, and a weird way of determining actual values that I cannot recall (only that it greatly undervalues happiness from unique luxuries). Strategic value is extremely dumb in the unmodded game: the only thing the AI checks for are hills in a radius of 1 and mountains in a radius of 2, increasing strategic value by a flat amount for each one. If a tile does not have any value besides strategic, ie. it's flat desert, snow, or mountain, it decreases the original plot's fertility value by 30 * (ring multiplier). Tiles owned by another player are not counted, and tiles owned by the current player have their fertility contribution halved. Natural wonders double their fertility contribution and also add an extra 500 fertility.
In the unmodded game, certain civs will get an exorbitant amount of extra flavor for plots in certain areas: Spain gets an extra 55000 fertility when the tile is in 3 radius of a natural wonder, Celts get an extra 1000 * (faith flavor) or 2000 * (faith flavor) fertility for settling next to 1 or 3+ forests, Morocco gets 1000 extra fertility for every desert within city working radius, Brazil gets 1000 extra fertility for every jungle within city working radius, Netherlands gets 2000 extra fertility for every floodplains or marshes within city working radius, Inca gets gets 1000 to 3000 extra fertility for every hills that is adjacent to a mountain depending on how many mountains there are adjacent to the hills, and Iroquois gets 10 extra fertility for every forest within 5 tiles. Indonesia multiplies the fertility value of all plots that would give it a civ-unique luxury by 3.

Once the base fertility of a tile has been determined, the AI then applies a boatload of multipliers based on the tile itself. Fertility is halved if the tile has a visible resource, is increased by 15% if the tile is on a river, is increased by 40% if the tile is coastal and another 40% if the player has 8 or more Naval flavor, and is doubled and increased by 25 if the tile is coastal and the player is flagged as a coastal civ (England, Carthage, Polynesia, etc.). After this come the distance modifiers: basically, the AI checks to see how close its closest city is to the plot and how close the closest enemy city is to the plot and applies modifiers based the results combined with its growth and expansion flavors as well as its boldness value.

After all of these have been calculated, the settler takes the overall fertility values of plots and then reduces their value if they are too far: what constitutes "too far" depends on the map and whether or not the settler is escorted, but everything roughly 12 or more tiles away is usually reduced by the same amount.
 
Ok but each AI knows this value on T0, right? So it actually doesn't matter if we perceive this as them going after resources or whatever... It's insane that they can see twenty hexes and think "hmm that's good, I'll settle there". And daft.


Sent from my iPad using Tapatalk
 
Do unrevealed barbarians/enemies in that area count for something? Sometimes I get a suggestion for a city placement, and when I start exploring the area and reveal some barbs/barb camps, the suggestion disappears.
 
Ok but each AI knows this value on T0, right? So it actually doesn't matter if we perceive this as them going after resources or whatever... It's insane that they can see twenty hexes and think "hmm that's good, I'll settle there". And daft.
They only know this value once they reveal the tile. The value is also only influenced by resources after they are revealed (eg. Horses, Iron). If a tile is revealed, the AI knows the fertility of that tile regardless of what other tiles are revealed; if there's an unrevealed natural wonder 3 tiles to the north of a tile, for example, the AI will still "know" that there's a natural wonder near the given tile and factor it into the given tile's fertility. Since these tiles also show up as yellow city icons for the human player, it's not really unfair (ie. if you see a newly uncovered tile have a yellow city icon, you'd suspect that the land around it might be quite good).

Do unrevealed barbarians/enemies in that area count for something? Sometimes I get a suggestion for a city placement, and when I start exploring the area and reveal some barbs/barb camps, the suggestion disappears.
If a visible enemy unit is on a tile, the AI will not target that tile for settling cities. Since the AI does not retarget settlers, this means that if the AI clears a barbarian encampment on a high fertility tile the turn after it sends its settler out to settle a plot, it will not redirect its settler to that high fertility tile.
 
Back
Top Bottom