My personal thread: Clarification of certain game mechanics

Flavor is used to impact research decisions. In the CvPlayerAI::AI_bestTech function (which is used to pick path of research), there's a huge list of factors that can increase or decrease the perceived value of any given choice - it values techs that enable units more, techs that enable map trading, etc. etc.... about 80 such factors.* Typically, values range between 0 (useless junk) and ~2000 (an incredibly, absurdly great tech for the AI's current situation, in it's often-unwise opinion). It adds the leader flavor * tech flavor * 20 (that'll range from 0 to 2000 or so), and adds a 0-2000 point random factor. So roughly speaking... 1/3 of tech choice is random, 1/3 is personality and tech flavors, and the remaining 1/3 is its judgment of what the game calls for.

*AFAIK, the AI doesn't check this function when considering a tech trade though... they'd pay equally for two different 500-beaker techs, even if they'd never research one and would highly prioritize the other. So flavor shouldn't impact tech trade values.

Thanks for clearing that up. Still some personality in tech choice then, it appears, but not as much as I thought/hoped. The coders have put a lot of emphasis on random factors everywhere, possibly too much, to the detriment of the game.

In tech trades, do the AI value the techs equally with the same ratio towards the human no matter diplomacy (assuming they are willing to tech trade) and difficulty level?

During a monarch game I did the math as there was a trade where the AI demanded gold. Think it worked out to about 0.90. So assuming it was a 1000 tech, the AI was willing to give me a 900 tech - on the assumption that 1 :science: = 1 :gold:

Actually, I assume this will scale on difficulty; seem to recall possibly Seraiel saying it was 0.7 at Deity. But will it scale on level of relationship (pleased etc) with the AI in question? Or will it be the same as long as they are willing to trade with you?
 
Diplomacy doesn't affect the ratio of tech-trades, an AI is either willing to trade, or not, but the conversion factor mostly depends on the difficulty. I've read that things like the tech being a monopoly or many civs knowing it already also influences the ratio, and I think I can approve that, but the amount at which the conversion factor changes because of that must be almost insignificant, maybe 5%.
 
Bump for new questions in the opening post. If you know something or has a lead, feel free to post.
 
*There is a small trick with building culture. If the city will border pop next turn (thanks or not to building culture) and queue something else than wealth or science (because they are considered same category as beakers), then you get the built culture and same value after multpliers for the unit or the building. Bug created by beakers first, then hammers compiled.
I've never heard this before. Can you explain it further? If I understand you correctly, you're saying that if a city is building a culture, has an item in the queue and it's about to get a borderpop, you get hammers into the item in the queue. Did I understand that right? What if you have multiple items in the queue? Can you do that with wonders, too?

[*] Gold trade are by increments of 10 golds since CIV. Later in the game, it is reduced to increments of 5 gold. And sometimes even to increments of 3 gold. What does trigger this?

[/LIST]

Err, you can choose to trade any amount of gold. I've also seen the AI offer to trade XX4 gold (because they're allowed to trade all of their gold away for a really good deal) so I don't know what you mean here.
 
I've never heard this before. Can you explain it further? If I understand you correctly, you're saying that if a city is building a culture, has an item in the queue and it's about to get a borderpop, you get hammers into the item in the queue. Did I understand that right? What if you have multiple items in the queue? Can you do that with wonders, too?

Yes, you understood correctly. You get the culture built and border pop cancels build culture (I think that appears along BTS), so the next build in queue is taken and a bug caused by beakers, wealth or culture come first and then hammers.
Quite a useful trick I found myself (and was supposedly known by WastinTime long time ago...) once the conquered city revolt is finished. You get the border pop, hammers in a building and then you whip without handicap. 1 pop lost max.

Gamespeed has strong influence on this trick strength. Each turn on quick speed worths big chunk of everything and border pop takes only 5 hammers.
Marathon has many contributions from many turns for each build. So that trick can be ignored.
Normal speed is fine.
Multiple items in queue won't all get their part. Only the very next in queue.
Wonders take it theoritically.

Err, you can choose to trade any amount of gold. I've also seen the AI offer to trade XX4 gold (because they're allowed to trade all of their gold away for a really good deal) so I don't know what you mean here.


Yes, I know it is increment of 10 or all the gold. Possibly that was implemented to avoid the huge micro from CivIII.
But as eras pass, I noticed the incrementation proposed by the AI decreased. Of course, I can't propose 5 gold, but I was curious why the AI decreased its incrementation.

I suppose it is partially explained by: 10/2 = 5 ===> 5/2 = 2.5 ~3 gold.
But the why, I don't know.
It happens often in map trades.

Comments in blue.
 
Any chance of a diff?

Any chance of a ....Urban Dic let me down this time...

Well, true only one question was added in the OP (opening post or whatever that acronym means). Every question is added at the beginning of the thread.
True, I do some "fresh" necro because CivFanatics population changes over time and maybe...maybe one has the answer to one of these questions.

Anyways, I hope this thread is going to increase in importance over time as a small bible of under-known mechanics of the game. Sometimes, knowing how it works...as little the aspect of the game is...changes dramatically the game outcome.

For instance, I just recalled (unless it was patched) spies in boat accumulate stationary discount while the boat advances and is completely invisible by the AI (no detection by evil RNG) until we unload the spy. Indeed, it dramatically changes the game outcome if the stars are perfectly aligned like a nice coastal city with our religion by under a different religion state and close by our city that pumps boats.
 
Am I mistaken or do techs that unlock wonders become less valuable to the AI in trades after the wonder is built? I try to make those trades only when I have the wonder for sure (edit: but before it's finished of course), but I realize I acually have no idea if this makes any difference.
 
Am I mistaken or do techs that unlock wonders become less valuable to the AI in trades after the wonder is built? I try to make those trades only when I have the wonder for sure (edit: but before it's finished of course), but I realize I acually have no idea if this makes any difference.

The AI does try not to trade you a tech it would like to build the wonder for, yes.
 
The AI does try not to trade you a tech it would like to build the wonder for, yes.

I know they will not trade a tech if they are building an associated wonder, I was wondering if they give you a higher return on a tech if the wonder isn't built yet.
 
An indication, in each bump, of what the new questions are.

If I ran the zoo -- new questions would be added to the end of the thread, and then copied to the first post when a satisfactory answer is found.

I also wouldn't use that shade of green, because (a) it has very poor contrast with the default background and (b) I wouldn't expect it to be particularly friendly to color blind readers.

But it's not my personal thread, and so....
 
If I ran the zoo -- new questions would be added to the end of the thread, and then copied to the first post when a satisfactory answer is found.

I also wouldn't use that shade of green, because (a) it has very poor contrast with the default background and (b) I wouldn't expect it to be particularly friendly to color blind readers.

But it's not my personal thread, and so....

I concur on all points made, especially the one about the green font. I can see that the font is green, but due to the poor contrast I can't discern a single character. I'm forced to highlight the green text which changes the foreground and background of the green text to high contrast colors.

Sun Tzu Wu
 
AI leaders bragging about their strongest unit:
Synopsis and use:
AI that is CAUTIOUS or less towards the human and has less power (in terms of soldier values in demographics) will start bragging at a random instances about their strongest unit available.

A tactical use that stems from this AI weakness is the knowledge without condition (like exploration) of what the AI best abilities in war. For instance, if an AI still insists on his/her chariots being so great after a great span of the early game, then the lack of metal units sure is a military edge to stomp them or take them as the softest target.
Their unit bragging does not equal they have gotten out a unit; it is based on the availability of unit as a build in the AI unit, which comes from the usual fact of a connected strategic resource.
Or a tech that enables the unit.


Hereunder is the code ruling the conditions needed for bragging (and commanding what string texts will be sent in diplo tables):
Spoiler :
Code:
DiploCommentTypes CvPlayerAI::AI_getGreeting(PlayerTypes ePlayer) const
{
	
[...]
		else if ((GET_PLAYER(ePlayer).getPower() < getPower()) && AI_getAttitude(ePlayer) < ATTITUDE_PLEASED && (GC.getASyncRand().get(4) == 0))
		{
			return (DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_UNIT_BRAG");
		}
	}

	return (DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_GREETINGS");

(A great thanks to Refar for the big big pointer)
Hereunder is a brief explanation on how the AI decides what is the best unit to brag.

In CvPlayer.cpp
Spoiler :
Code:
const wchar* CvPlayer::getBestAttackUnitKey() const
{
	CvCity* pCapitalCity;
	CvCity* pLoopCity;
	UnitTypes eBestUnit;
	int iLoop;

	eBestUnit = NO_UNIT;

	pCapitalCity = getCapitalCity();

	if (pCapitalCity != NULL)
	{
		eBestUnit = pCapitalCity->AI_bestUnitAI(UNITAI_ATTACK, true);
	}

	if (eBestUnit == NO_UNIT)
	{
		for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
		{
			eBestUnit = pLoopCity->AI_bestUnitAI(UNITAI_ATTACK, true);

			if (eBestUnit != NO_UNIT)
			{
				break;
			}
		}
	}

	if (eBestUnit != NO_UNIT)
	{
		return GC.getUnitInfo(eBestUnit).getTextKeyWide();
	}

	return L"TXT_KEY_MISC_NO_UNIT";

Basically reporting AI_bestUnitAI(UNITAI_ATTACK, true), that is units with possible <UnitAI>UNITAI_ATTACK</UnitAI>, otherwise report TXT_KEY_MISC_NO_UNIT, which is the commonly known "Fear our --!".


After cutting most parts that not related: In CvCityAI.cpp
Spoiler :
Code:
UnitTypes CvCityAI::AI_bestUnitAI(UnitAITypes eUnitAI, bool bAsync, AdvisorTypes eIgnoreAdvisor)
{
iBestOriginalValue = 0;

	for (iI = 0; iI < GC.getNumUnitClassInfos(); iI++)
	{
		eLoopUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(iI)));

		if (eLoopUnit != NO_UNIT)
		{
			if ((eIgnoreAdvisor == NO_ADVISOR) || (GC.getUnitInfo(eLoopUnit).getAdvisorType() != eIgnoreAdvisor))
			{
				if (!isHuman() || (GC.getUnitInfo(eLoopUnit).getDefaultUnitAIType() == eUnitAI))
				{
				    
					if (!(bGrowMore && isFoodProduction(eLoopUnit)))
					{
						if (canTrain(eLoopUnit))
						{
							iOriginalValue = GET_PLAYER(getOwnerINLINE()).AI_unitValue(eLoopUnit, eUnitAI, area());

							if (iOriginalValue > iBestOriginalValue)
							{
								iBestOriginalValue = iOriginalValue;
							}
						}
					}
				}
			}
		}
	}
}

Notice the canTran() functions; that is the very condition for showing off some units without even having one yet. "UnitAITypes eUnitAI" is set to UNITAI_ATTACK btw.
It compares between units with possible UNITAI_ATTACK and via "AI_unitValue()"
function, it calculates what is the best unit to brag about.

Let takes a look into that mess: In CvPlayerAI.cpp

Spoiler :
Code:
int CvPlayerAI::AI_unitValue(UnitTypes eUnit, UnitAITypes eUnitAI, CvArea* pArea) const
{ 

[...]
[...]
[...]
[...]

case UNITAI_ATTACK:
		iFastMoverMultiplier = AI_isDoStrategy(AI_STRATEGY_FASTMOVERS) ? 2 : 1;
		
		iValue += iCombatValue;
		iValue += ((iCombatValue * GC.getUnitInfo(eUnit).getMoves() * iFastMoverMultiplier) / 2);
		iValue += ((iCombatValue * GC.getUnitInfo(eUnit).getWithdrawalProbability()) / 100);
		if (GC.getUnitInfo(eUnit).getCombatLimit() < 100)
		{
			iValue -= (iCombatValue * (125 - GC.getUnitInfo(eUnit).getCombatLimit())) / 100;
		}
		
		break;
[...]
[...]
[...]
[...]

return std::max(0, iValue);
}

Here is the exact formula for evaluating UNITAI_ATTACK units.
Let put it more friendly:

iValue = (CombatValue) + (CombatValue*Move*FastMoverMultiplier/2)+
(CombatValue*WithdrawalValue/100)

FastMoverMultiplier is a multiplier equalling to 2 if the AI is pursuing a war planning about 2 moves units. I suppose this has to do with WHEOON mode with an AI having in mind that war planning.

The condition "GC.getUnitInfo(eUnit).getCombatLimit() < 100" is not important because it is tied to units with <iCombatLimit>0</iCombatLimit>, which are units that can't attack, like workers, settlers, missionaries, naval units, air units, spies, etc.
Those units have penalties, but they doesn't interest us in bragging function, especially where that function is best used early game where exploration is not done yet.

Conclusions from that formula:
2 movers are more prioritized than slow units and this is even more increased with 2 move units having an innate withdrawal odd like horse archers.
 
Great work tachywaxon!

Thanks for using a shade of green with good contrast with the background. Unfortunately, the contrast is not so good with spoiler background which it occurs to me may have been my original complaint about green fonts.

Sun Tzu Wu
 
The "trick" with the culture works with money/beakers put in to hammers too, but I consider it too strong and tempting to be used non stop while it is in fact bug/cheating. To save you the temptation and inner fights and not put you all in sin, I wont tell how it works.
 
^
I know how it works, but I don't exactly know how it happens. I have a hunch it has to do with culture output are stocked before hammers stocks...

This trick/cheat/whatever you call it is best on quick speed and negligible on marathon.
 
Top Bottom