So I'll do some more digging on this new code for tech diffusion, to see some examples to this feature (and hopefully to help newcomers or people who doesn't understand C++ code who want to better understand this feature).
For now, these are all modifiers which are applied to Tech Diffusion:
To a specific Player:
-To each known civ which got the tech already;
-----More if you have OB with it or if the civ is your vassal;
-----More if you're at war or if you're a vassal of the civ;
-Less if only less then 1/3 of all the civs have the tech;
-More if more then 2/3 of all the civs have the tech;
-More the more civs you know in the game (related to the total number of civs);
-More the bigger the gap between the best civ and the player in known techs;
-More the bigger the gap between the best civ and the player in score;
To the ones who just want to know what modifies it, there is your answer.
Now, to the weight of them. I separated them to show how the math applies to it all. It's in that order, now let's check the interactions:
First it checks from all civs, to all civs we know, which have the tech in question. For each you sum 0.5. But also for each you check if: It has OB or is a vassal? This civ contributes 2, instead of 0.5 to the sum. Is it at war with you, or is it your Master? This civ contributes with 1 to the sum instead of 0.5. All the others that are known and have the tech contribute with 0.5. Those who don't have the tech or are unkown don't contribute at all. So the more OBs and Vassals with civs that know the tech the better. Best yield (98) Worst yield (0)
After this the game checks if anyone you know has the tech by the previous function described above (it just checks if the above sum yielded more then 0, which should when there is at least someone you know that has the tech). If yes, then it checks the 2 following conditions: Have less then a third, between 1/3 and 2/3 or above 2/3 of the civs got the tech in question?
If Less then 1/3, the sum is divided by 100, if more then 2/3, the sum is multiplied by 3, if in between nothing is changed. So for this part, if less then a third of the civs don't know the tech, this number becomes really small. And after that the value is again multiplied, but now by the ratio between Known Civs and All Civs. So the more civs you know in the game, the less this ratio affects badly the value (which I'll call from now on
knownExp, the name it's used on the Tech Diffusion code). If you know everyone, the value is unchanged because the ratio will yield 1, and it's multiplied to knownExp, so it results in the previous value. OBS: This ratio is between Known Civs and All Civs, so this has nothing to do with civs
who know the tech, it's just a measurement of how many civs you know in the game, if you are well known then you have more tech diffusion. Best yield (294) Worst yield (0.0002)
Here is when this
knownExp ends being calculated and starts affecting other variables. Now we will change the
iModifier, the final variable to yield our tech diffusion modifier. It is started with the value
100. This following part will only happen if we know someone who got the tech (knownExp > 0, so if we went through the previous part, we will enter this one).
In this first operation we will get iModifier by adding it with iTechDiffusion. iTechDiffusion OTOH will be calculated using the following formula:
MAX[0, techDiffMod - (int)(techDiffMod * 0.85 ^ knownExp + 0.5)]
Where
MAX means the maximum value will be chosen between the result of the formula and 0
(int) denotes it'll yield an integer value, and the rounding is always down (e.g 6.9 = 6)
techDiffMod is defined in TechDiffusion_GlobalDefines.xml, and it's
70
knownExp is the only value calculated so far
and the math order of this formula is: 0.85^knownExp, then this multiplies techDiffMod, then it adds 0.5 (for the rounding issue) and finally you get techDiffMod and subtracts by this. This will always result in 70 - (x% of 70). Not surprisingly Best yield (70) Worst yield (0). With this we apply the following formula: iModifier(new) = iModifier(old) + iTechDiffusion, so iModifier(new) = 100 + (0, 70), which may result at Best (170) or at worst (100).
And now we reach the point where things may get a lot bigger or not. The game discovers the best player in tech points and checks our % of techs related to him (saved in iTechScorePercent). If we have 90% (defined in global defines as TECH_DIFFUSION_WELFARE_THRESHOLD) or less, then this part of the formula kicks in. Now we have iModifier with at best 170, or at worst 100, to add to another variable (iWelfareTechDiffusion). The formula is the following:
MAX[0, iWelfareMod - (int)(iWelfareMod * (0.98 ^ (iWelfareThreshold - iTechScorePercent)) + 0.5)]
Where
MAX as previously explained yields 0 or the formula result, which is higher
(int) denotes it'll yield an integer
iWelfareMod defined
1000 in TechDiffusion_GlobalDefines.xml
iWelfareThreshold defined
90 in TechDiffusion_GlobalDefines.xml
iTechScorePercent the % of our tech points related to the best in tech points
iModifier is the previous value already calculated (min 0, max 70)
and the math order is similar to the previous one: discover 0.98 ^ (90 - iTechScorePercent), then multiply by 1000, then add 0.5, get the integer result of this and subtract it from 1000 + iModifier. Best yield (838) Worst yield (20).
Now we will check if this value will be applied to iModifier or not, and if it'll suffer any new modifications too. Now we check
scores! For every civ in game we check their scores to see who has the highest score. Now we store it and take the ratio BestScore/OurScore. If this is less then or equal to 1 (OurScore >= BestScore, so actually we have the best Score), forget about iWelfareTechDiffusion and your result may be at best 170 or at worst 100, as stored in iModifier. OTOH if we are below the best score then we take the ratio and multiply it by iWelfareTechDiffusion. As this ratio has to be >1, iWelfareTechDiffusion may only increase by this. Finally we make iModifier(new) = iModifier(old) + iWelfareTechDiffusion
Now this is hard to calculate. At worst we will have exactly what iWelfareTechDiffusion would yield (in case 20). At best is impossible to predict, but we can suppose a civ with 5000 score, and a new worlder with 100. The ratio becomes 50, so this means (50 * 838) + 170 which yields 42070.
According to 45° (I have no idea where this is in the code), this iModifier is applied to your
/turn. You divide it by 100 and multiply it by your tech production. I have no idea if this considers fractions or not. If it accepts, then even the slightest tech diffusion value influences your research rate (I truly think it accepts). If not only values of iModifier > 100 do any difference (and only multiples of 100).
So if the weight of the factor is what matters to you, then here is your answer: Score Rate > Tech Points Rate > Rate of Civs which know the tech. Then for every civ you know: (Number of known civs which know the tech: OBs and Vassals > At War and Masters > None of these) > Known Civs rate. This may be deceiving, because some values are dependent to others, so in words: The capability of generating tech diffusion from the best yield of iModifier if we have >= 90% of the best tech points civ in the game is at best 170, which supposedly makes your
/turn be mutiplied by 1.7. To this everything until iWelfareTechDiffusion is considered. But if we have < 90%, we add to this iModifier a value ranging from 20 to 41900+ which may mutiply our research by something between 1.2 (if iModifier was at minimal value of 100) or 1.9 (if iModifier was at maximum value of 170) to more then 40x your tech. So actually the rate of tech points and the rate of score are the most important to tech diffusion, and they care little for everything explained above them. So if you are a new worlder that has just been born, with 100 score, and a ship from the best score and techer of the game right outside your city, your knownExp will yield at worst 0.03, resulting in an iModifier (before iWelfareTechDiffusion) of 100 (minimum). But getting iWelfareTechDiffusion (and imagine that guy has 2000 score) your iWelfareTechDiffusion will yield something like 16760, so actually your final iModifier will be 16860, or 16.86x your
/turn. Nice heh
I guess the only mistakes I may have let pass are related to the difference between Team and Civ. I always considered Civs rather then Teams (not only this is different in different parts of the code, as I don't know exactly what's the meaning of a team in RoM-AND and BtS). If the devs may take a look at what I've written, please let me know if I did a mistake, I don't want to mislead the players.