My personal thread: Clarification of certain game mechanics

Manco Capac

Friday,13 June,I Collapse
Joined
Mar 1, 2010
Messages
8,051
Updated on 19/12/2013 (date/month/year)

This thread intention is to gather the most complete set of articles about how the game works. The Civilization® Serie is known for a long time to be abstruse in revealing how the game actually works.
The great particularity of CivIV over CivIII for instance is the release by the developers of the uncompiled code, allowing everyone to judge by their own eyes how the game works and adjust it to their own way (modding). Through the code only as piece of justification, I will lay out the very building pieces of CivIV for the common player. Somehow, an attempt to How Civ4 works for dummies.


Game Mechanics

Spoiler :


City Mechanics


Unit Mechanics
Spoiler :

  • How many war success points worth a sunken ship along its load?
    Spoiler :
    EDITED: I haven't been able to find the SDK dealing with exact mechanics of war success definitions, but a quick testing showed the cargo of a ship drowning is NOT counted towards war success. I think that is good implementation if that was intended as it avoids possible AI abuses.



Miscellaneous
Spoiler :

  • Does one beakers equate to one gold in tech trade? I'll test perhaps later. Answered. It is not 1 beaker for 1 gold at all!
  • I think I've seen cases of peacevassaling when the master DoW you and the master makes automatic peace with you. Does the later case exist? Or the master needs to DoW you to get rights to have a vassal.
    Spoiler :
    Master always DoW to have the right to get a peacevassal.

  • What I discovered with experience is many aspect of the game is ordered. Just like the AI's and the player themselves IBT in a SP game. Some type of orders are understood (still I will list them for people's information), but some are still unknown to me. Sometimes, it can be gamebreaker or just annoying.
    Spoiler :

    • Beakers versus hammers. Beakers are always compiled before hammers from cities. That means monasteries in construction cannot be finished while getting SM IBT. Same for outdated units.
      That means settling on marbe and chopping a bunch of trees 1 turn before getting Masonry leads to more hammers than expected for a marble wonder or National wonder.
    • Golden Age from TaJ Mahal. How is it compile? Before all cities compile their hammers IBT (in between [two successive] turns) or something else? I lost my chance to milk more fail gold from Sistine Chapel because of a Taj golden Age (the wonder went two turns left to one turn).
    • Forests outside cities BFCrosses. If distant equally, the oldest city (according to the list of cities) gets the hammers. For instance, between the capital or another secondary city, the capital gets the chop unless it got captured by barbs and then retaken, which screwed the "founding dates".
    • 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.
    • GPeople are spawning in the order the cities are founded/captured. For instance, if you have London, Oxford and Paris, although Paris is older in world foundation, you captured it, so comes third in your city list. So, if London and Oxford has the same GPeople bar filled and same GPeople rate, then London comes first. To get two GPeople within a turn, Oxford should have humongous GPeople to catch up the margin created by each additional GPeople. Early in the game, it is usually 100 :GP: points per additional GPeople.
  • 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? NOW EXPLAINED.




======================================================================

AI Mechanics

Spoiler :


CvCityAI.cpp - AI City Mechanics
Spoiler :




CvPlayerAI.cpp - AI Leader Mechanics


CvTeamAI.cpp - AI Team Mechanics
Spoiler :

  • Vassals (either peacevassal or a capitulee) get free technologies from their master. How does it work?

    Spoiler :
    Peacevassalings to a master and the master gives you free techs. Well, what does rule the AI in leaking his technological secrets? And given the master is not always a FRIENDLY dude, he doesn't necesserily gives all his techs.
    On FRIENDLY, I think the master gives all but perhaps wonder techs if (s)he starts a wonder the turn he gets the tech.
    I think the tech leakage comes with "We don't want to trade it away just yet!".

  • What does mean "We'd rather win this game..." when I want to bribe the AI off a war? Directed Victory condition? AI stomping another AI badly?

    Spoiler :

    There are two reasons, but the most common is when the human player has few land tiles compared to the AI. If the AI you want to put a stop in his war has more than 2.5 your land value, then (s)he returns an excuse: "We'd rather win this game...". Can be found in CvTeamAI.cpp.



    [*] AI gifting free techs inner working. Checked.


CvUnitAI.cpp - AI Unit Mechanics
Spoiler :









  • For the future...

    [*] How war tribute works in detail?
  • When vassals revolt? NEW
  • Strike and Automatic Unit Disband Process




NOT longer intended to ask questions to the community. Even those knowing deeply the code refuses to help. Only archives under dust here.


BUT you can ask questions to me.
 
Well, my personal thread was a misused term as I wish some people help me to understand those mechanics.

As usual, my question threads are typically unpopular. lol
 
Peacevassal (PAssal) will result in DoW with anyone the vassal is currently fighting, with no exceptions AFAIK. Peace is only forced from capitulation when there is mutual war against the same target. If master to be can't (peace treaty) or otherwise wouldn't (diplo disposition) declare then it won't PAssal your target. I used to mistakenly think the PAssal was selling itself as part of a war bribe; but actually the mechanics for it are different and more based on standard vassal state rules.

Of course, war is not necessary for a PAssal deal to happen and if it happens at peace then the master won't declare on you (unless, of course, it simply chooses to do so anyway).

I'm not a code expert and you'd probably need one to understand what the AI "logic" is for gifting vassals techs (IE occasionally throwing the game by powering up a culture civ and protecting it).

"don't want to trade tech just yet" is something the AI refuses based on #known civs with the tech. Some AI need quite a few other civs to know the tech while mansa musa will trade monopoly techs outright. I have no idea if those rules apply to the bent over AIs, although friendly status *does* ignore this check so you might be right about that.
 
In vanilla "We'd rather win..." was only a reason for late space-race-related techs.

I am not sure whether I understand the Beaker/Gold equivalence. The AI usually only trades in its favor, i.e. usually they will not trade techs with the same # of beakers, but how much more than equal value they want sometimes seems to depend on particular techs. So it is probably similar with gold for tech or gold + tech for tech.
 
Thanks for lightspeed response. I didn't expect that. Possibly I'll make some tests for gold-beaker equivalency on noble, which, IIRC' , represents the level where human and AI are on the same foot level. I somehow want to know more about it to make my trades a bit more organized in a sense I can't take as many turns as I wish lest I lose my chance to tech trade. Sometimes, it can be a ridiculously low 20 gold making difference despite lacking it and means to get it within a same turn. Of course, we need to take consideration human beaker value is inflated on higher levels, AI may research such tradable tech meanwhile, AI's get discounts thing per era IIRC, number of AI's who knows the tech, etc.

And knowing gold/beaker correlation makes war capitulation along tribute or simply war tributes more deterministic. Something like getting a high cost tech, but you are missing few beakers. This happened in the Charlie game recently. I waited some turns of personal teching of constitution before agreeing to my neighbour's capitulation along the said tech. And at the same time, I was in fear of some sort of peaceful Pvassaling, but that doesn't happen at all. I surely mistakened with someone who took advantage (another offline game) after DoW.

Why did I think about "We don't to trade it just yet" ? It is based on IMM Shaka by soundjata where SB got feudalism and two of my victims under his wing. Interestingly, because of the insufficient diplo stance, he never leaked his secrets of feudal regime. Of course, he's not prone to leak techs if no less than 80% of the world knows that tech too.
So, I was teching feudalism, but at first I resisted to the idea in fear to see him giving it outright to his protégés. After getting the said tech, he still kept his secrets. That was an interesting assumptions as knowing how the AI decides when to give it or not. Let's take an example where most has feudalism and we need me to get 80%. So if I got feudalism before attacking one of those vassals, then that would have been a huge strategical mistake.

@Kallitrates
Yes, in Warlords too I think. But now, twice, I encountered those weird excuses as if the AI is geared towards domination. Since when the AI in inclined to domination in CIV?
 
Bucket list: Green: answered.

  • Does one beakers equate to one gold in tech trade? I'll test perhaps later.

In my experience (mainly noble/epic), the "base" value is around 1:1 (if I'm trading a tech and the AI has the money, they'll offer or ask about 1:1 to make up the difference in beakers). However, the AI will sometimes value a tech significantly more than its beaker value. Late-game, they'll charge significantly more than beaker value for state property or fascism, to pick two.
 
[*]What does mean "We'd rather win this game..." when I want to bribe the AI off a war? Directed Victory condition? AI stomping another AI badly?
In my experience, it seems to mean that the AI is closing on domination limit (perhaps if conquering the target would put it over it?).
 
Would you mind if I put in a mechanic here that surprised me, and feels rather counterintuitive and illogic?

Struggling with happiness and recovering after a war, with poor tech, I noticed that the now dead civilization had calendar and built a plantation on an incense resource. When the border popped I fully exepcted +1 :) However, that did not happen. So now there is planation on an Incense in the cultural (and workable) borders, but no +1 :) So even if you have the resource and it is improved, if you don't have the pre-requisite tech, you actually don't get the benefits.

So this isn't like wonders, where we get their benefits after conquer even if we don't have the pre-requisite tech(s) to build them ourselves.
 
Would you mind if I put in a mechanic here that surprised me, and feels rather counterintuitive and illogic?

Struggling with happiness and recovering after a war, with poor tech, I noticed that the now dead civilization had calendar and built a plantation on an incense resource. When the border popped I fully exepcted +1 :) However, that did not happen. So now there is planation on an Incense in the cultural (and workable) borders, but no +1 :) So even if you have the resource and it is improved, if you don't have the pre-requisite tech, you actually don't get the benefits.

So this isn't like wonders, where we get their benefits after conquer even if we don't have the pre-requisite tech(s) to build them ourselves.

you certainly can't expect your citizens to understand the beauty of incense without calendar.
otoh they surely can enjoy their stonehenge or pyramids without knowing the ways how to build them...

naaaaah just kidding :), it works how you wrote, dunno the design decision behind this.
 
@pangaea:
It is always a pleasure if people uses this thread for more questioning. Vranasm already gave the right answer.
 
1 :science: = 1 :gold: when trading with AI, at least on Deity, tested and confirmed in Replay #3. Multiply your tech with 0.7 if you want to know what it's worth for the AI.
 
Thanks vranasm for the confirmation. It was a bit weird to me, but that's how it is sometimes. Not everything makes sense.

1 :science: = 1 :gold: when trading with AI, at least on Deity, tested and confirmed in Replay #3. Multiply your tech with 0.7 if you want to know what it's worth for the AI.

Is this why it's so difficult to get 1:1 tech trades with the AI? If they value, say, 1000 :science: as 700 :science: then it's no wonder it's difficult to trade 'fairly' with them.
 
Thanks vranasm for the confirmation. It was a bit weird to me, but that's how it is sometimes. Not everything makes sense.



Is this why it's so difficult to get 1:1 tech trades with the AI? If they value, say, 1000 :science: as 700 :science: then it's no wonder it's difficult to trade 'fairly' with them.

an AI will never do "fair trade" meaning exchanging beakers in 1:1 ratio.

what can happen though that the value of techs they give you is lower then the beakers it costs and thus you can sometimes get "fair trade"

famous alpha x aesth trade comes to mind, both tech cost the same, but if you invest X amount of beakers into alpha you can trade aest for alpha since AI knows how many beakers you invested into a tech

another thing cheapening techs is how much spread they are between players (known or all?) thus if you broker monopoly tech you start trading for highest beakers first and brokering cheapest techs last.
 
1 :science: = 1 :gold: when trading with AI, at least on Deity, tested and confirmed in Replay #3. Multiply your tech with 0.7 if you want to know what it's worth for the AI.

I remembered this and checked the post, because going by the code it looks like there is some calculation and the :science: : :gold: exchange rate should be nothing like 1:1. It seems like it should be maybe more like 1 : 1.5 or more. Is it possible the example just happened to hit about 1:1? Trying it out myself in the game I can't see any really pattern at all :lol:

The 0.7 part at least makes approximate sense because on deity our tech costs are 130%, and 100/130 is about 0.75.
 
1:1 was tested with save-loading, I'm really very sure about that, aswell as about the 0.7 . I conduct all my trades by those rules now already for a long time, and they always work as I want them.
 
I don't know if the AI cheats on the trade or not; what I do know is a backward AI civ with negative gold and a single city left suddenly got all the techs from maceman to rifleman in a single turn (BTS, monarch)
Since then I always disable tech brokering in my games.
 
Had a wee gander into the XML files, and came over the technologies and leaders files. Noticed that leaders are marked as flavours growth and so forth. Under each technology in the tree, there is then noted preference for some of the flavours for each technology.

Just a random example:
Code:
<Type>TECH_ELECTRICITY</Type>
...
<Flavors>
	<Flavor>
		<FlavorType>FLAVOR_MILITARY</FlavorType>
		<iFlavor>1</iFlavor>
	</Flavor>
	<Flavor>
		<FlavorType>FLAVOR_PRODUCTION</FlavorType>
		<iFlavor>4</iFlavor>
	</Flavor>
	<Flavor>
		<FlavorType>FLAVOR_SCIENCE</FlavorType>
		<iFlavor>7</iFlavor>
	</Flavor>
	<Flavor>
		<FlavorType>FLAVOR_GROWTH</FlavorType>
		<iFlavor>2</iFlavor>
	</Flavor>
</Flavors>

Has there been any analysis into this? I'm assuming this will prioritise which technologies leaders go for, depending on their flavours, and may indicate technologies that the AI tend to not research (or prioritise researching) and thus technologies we can use as trade bait. Or are these trade bait techs basically common knowledge among the experienced players?

Again, this may be common knowledge among the Aces in here, but these two files combined might indicate what paths the various AIs take down the tech tree.

For example, say you have a military flavoured AI, like Bismarck. Will he, at any place in the tech tree, look at the various options and take the tech that has highest military value? Sounds too simplistic, but perhaps an interesting starting point.
 
Has there been any analysis into this? I'm assuming this will prioritise which technologies leaders go for, depending on their flavours, and may indicate technologies that the AI tend to not research (or prioritise researching) and thus technologies we can use as trade bait. Or are these trade bait techs basically common knowledge among the experienced players?

Some of this is common knowledge. I'm hardly an expert, but I know that there are several techs on the path to liberalism that are known to be lower priority to the AI (e.g. Paper). Trading them is strongly recommended against. I believe Aesthetics is another tech that the AI does not prioritize researching that can be used as trade bait (with the proviso that you may wish to hold onto it to protect Literature [for the great library] or Music [if you're trying to interfere with an AI cultural victory]).

Some of this is covered in more detail in the strategy article on winning an OCC game by space race at the deity level.
 
Had a wee gander into the XML files, and came over the technologies and leaders files. Noticed that leaders are marked as flavours growth and so forth. Under each technology in the tree, there is then noted preference for some of the flavours for each technology.

Just a random example:
Code:
<Type>TECH_ELECTRICITY</Type>
...
<Flavors>
	<Flavor>
		<FlavorType>FLAVOR_MILITARY</FlavorType>
		<iFlavor>1</iFlavor>
	</Flavor>
	<Flavor>
		<FlavorType>FLAVOR_PRODUCTION</FlavorType>
		<iFlavor>4</iFlavor>
	</Flavor>
	<Flavor>
		<FlavorType>FLAVOR_SCIENCE</FlavorType>
		<iFlavor>7</iFlavor>
	</Flavor>
	<Flavor>
		<FlavorType>FLAVOR_GROWTH</FlavorType>
		<iFlavor>2</iFlavor>
	</Flavor>
</Flavors>

Has there been any analysis into this? I'm assuming this will prioritise which technologies leaders go for, depending on their flavours, and may indicate technologies that the AI tend to not research (or prioritise researching) and thus technologies we can use as trade bait. Or are these trade bait techs basically common knowledge among the experienced players?

Again, this may be common knowledge among the Aces in here, but these two files combined might indicate what paths the various AIs take down the tech tree.

For example, say you have a military flavoured AI, like Bismarck. Will he, at any place in the tech tree, look at the various options and take the tech that has highest military value? Sounds too simplistic, but perhaps an interesting starting point.

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.
 
Wow. Why bother with flavor if it's drowned out by random factors? I bet you could improve the AI greatly by simply removing that random factor and maybe sprucing up their tech evaluations.

Wait, I don't see any checks against cost. So, if there's a hugely expensive tech that gives the same bonus as a cheaper tech, they will be weighed the same? That probably explains why they love Feudalism and Engineering.
 
Top Bottom