On tech diffusion

I like the concept of tech' diffusion, but I've come to dislike a certain aspect of its implementation. Specifically, I don't like how one's beaker production is inflated (sometimes drastically) when researching a tech' which many others have.

The issue is that in tech' trades it's no longer possible to tell whether a trade is a good deal or not. If I'm swapping a 1000-beaker tech for another 1000-beaker tech', nominally it's an equal trade; however, if for one of those tech's my beaker production would be inflated by a factor of (say) five the trade is clearly very unbalanced - and there's no way to see that on the trade screen.

Am I right in that the inflated beaker production is reflected in the GNP statistic also, leading to huge spikes in the time-series graph during periods when widely-known technologies were being researched?

I think I'd prefer that tech' diffusion were implemented similarly to the tech' learning from captured cities: that is, if you're a long way behind, you get some free beakers added each turn to tech's which are known by other civ's with whom you have contact. In this way you'd be able to judge the trades accurately, and you wouldn't have to open the science advisor to see how long a tech' will take to research. This also seems more intuitive to me: my civ' would start learning about the technology through contact with other civ's even if I didn't apply my own scientists to study it.

Does this bother anyone else?

Cheerio.


This way does make more logical sense.
Though it probably requires a lot of programming.
 
45°38'N-13°47'E;13120507 said:
I'm happy you like it; it still needs some tweaking, I will make it handicap-level dependant because right now it's too powerful for harder level if you're lagging behind, making the game too easy. On the contrary, it makes the game harder if you're the one in the lead in terms of techs


As I said, I think the whole idea is brilliant, and it works really well, however you are right it should be "softened" a bit, as it is nearly impossible to be tech leader at the moment...

Is there anything I can to in the coding to quickly soften this feature? Any file I should change? As I think the concept itsself is brilliant and a huge improvement..:goodjob:
 
I'm resuming this thread because in my latest test I've seen that some AI civs are falling behind too much again. I think the problem is also connected with the new option to "cease relations" (which is being used a lot, it seems) because it didn't happen so much in the past and I can't think of anything else. I'm getting again some smaller civs lagging behind of 1 era or more when reaching industrial/modern. I really can't stand that a civ is reasearching Industrialism while I'm researching Interstellar Travel. It just doesn't seem right.
I'm not sure what we can do about it. Maybe increase tech diffusion for really backward civs? Or Gift them techs that other civs have discovered?
Other suggestions or opinions?
 
But does "cease relations" actually block TD towards a civ?
Or is it just a matter of rebalacing again?
 
But does "cease relations" actually block TD towards a civ?
Or is it just a matter of rebalacing again?
no, it doesn't but since you can't trade techs, I suppose some civs fall behind more quickly.
 
I think the tech diffusion should be related to the reverse of exponential of acquired tech (very slow acquisition if less than 10% get it, moderate if 50%, fast if 90%). It's the current system, isn't ?
Maybe you can make a low threshold where the lowest civ cannot have less than 15 tech late. This way, if the faster civ have 1000sci points, when the lowest is 15 tech below, it get 100% of the fastest civ tech points. If the fastest slow down, the slowest slowdown as well.
So you still have the advantages but not so much behind !
 
From AND2 and SVN Bug Reports - A New Dawn 2 ONLY

About TechDiffusion I have an idea with a different aproach:

Give :science: points to every unlearned techs of civs every turn by the following formula:

Cont x HCL x BUG /turn

Cont = Civ's number of contacts that already know that tech
HCL = variable depending on handicap level (since the AI can use flex.dif. too)
BUG = editable variable in BUG options, to give the players some hands on it

This way civs that are very behind would learn slowly but simultaniusly many techs, all that they don't know at the moment, while the ones not so behind still learn all they don't know at the moment, but that is still less.

I dont know how memory consuming would it be, to check every tech every turn and calculate how much :science: to add to them. If it is stressful for the memory, than it could be done only every N turns and multiply the whole formula by N, which could be also editable in BUG.

Do you think it would work?
Looks like I could not be clear enough. English is not my native tounge.

What I thourht about was not how the actual TD code should work, but an additional effect. To say, one more layer or one more option.

My idea is not (only) to affect a civs research output but the techs themselves. Each and every one by one.

Try to put it by an example:
America (A) has connection to 4 other civs, and is beelining for Polytheism.
Others are Babilon (B), Carthage (C), Dutch (D) and Egypt (E).
B, C and D knows Hunting, while The Wheel is known by B and C only.

So every turn A gets 3:science: for Hunting and 2:science: for Wheel, altough he is researching none. If in that given game Hunting costs 100:science:, A gets it for free after 34turns (3x34=102) and if TheWheel costs 150:science) A gets that after 75turns (75x2=150).

Now let's say that E is a human player on Settler difficulty. He does the same as A, but faster, because there is a (say) 1.5x multiplier on Settler. In this case E gets Hunting in 23turns (3x1.5x23=103.5) and The Wheel in 50turns (2x1.5x50=150).

So civs could get techs even not choosing them. Sometimes it happens, that a minor civ does not know Writing (to become a full civ) but is researching Philosophy.

...or am I mistaken at some point?
 
45°38'N-13°47'E;13282950 said:
no, it doesn't but since you can't trade techs, I suppose some civs fall behind more quickly.

Maybe tone down the rate that leaders request others to cease relations a little?
 
I like the concept of this, but its current implementation can really break the game, especially on large maps and high difficulty levels.

It can easily have the opposite effect early in the game. While the map generator tries to take into account for resources and such when spawning players, it may not take into account for the number of nearby opponents. If you spawn in the middle of a continent you will have a significant advantage versus the corners. Or in the case of Huge/Giant maps, there may be some continents with 5-6 civs and some with 1-2. PerfectWorld map generator frequently does this. Anyone who spawns on one of these smaller continents is basically screwed and will be very far behind in tech by the time a caravel sails by.

Now you may be thinking you can catch up quickly after meeting another civ, but by that time you definitely will not have a religion (literally impossible to get one on a big map with this setting if you spawn alone) and will have missed out on all of the early wonders. This compounds the score gap and makes for a really boring early game experience. The only hope that you as a player have to catch up in this situation is if you're playing on a difficulty below your skill level. I think this may have been the situation when you were testing it. I actually had a great Monarch game with this setting on, but as soon as I moved up to Emperor/Immortal which is closer to where the game is normally "competitive" to me it felt really broken. I actually wish I had saves of my starts so I could go back and play them with diffusion off to illustrate just how much of a difference it makes. I might do that for my next game.

Another major negative is that you can't beeline towards techs with this setting, and in fact, you are significantly penalized for doing so. I think this is kind of a core concept of civ when it comes to beating the cheating AI that shouldn't be messed with. To expand upon that, usually a good strat on higher difficulties is working towards certain techs in order to get an advantage over the AI (be it a wonder, religion, unit, or whatever) because you cannot stay ahead in tech across the board. With the way diffusion is currently setup, the AI will pick up 3 other "known" techs while you're researching your far away one, and then use the advantage gained from those to beat you to your initial target tech.

--

Anyway, I can also see the positive behind your intent, because longer games are awesome. There's so much great content in this mod that players should really be encouraged to play through to later eras.

My suggestion to fix it is simple: have diffusion start gradually. There's no sense in "diffusing" the first couple techs that civs start with, for example. You can add points in the game where it picks up. Natural ones to me seem to be around Alphabet/Writing, then Optics, Printing Press, etc. This will eliminate the problem you originally wanted to solve (nukes vs pikemen) while at the same time preserving the challenge for those who prefer to play high difficulties, and fixing start bias.
 
Anyone who spawns on one of these smaller continents is basically screwed and will be very far behind in tech by the time a caravel sails by.

Not always true. I've just finished a game where I've started isolated and I've finished the game (Mastery Victory) far ahead of every other civs (still stuck at modern era, some even farther behind). It also depends on options: for example playing with Rev or Barbarian Civs spawns other civs so unless you get a very bad start on a very small island, you should have someone to trade with. And I mostly play on Perfect Mongoose mapscript.

Another major negative is that you can't beeline towards techs with this setting, and in fact, you are significantly penalized for doing so.

Again, not always true. I often beeline for Monotheism in order to get Judaism and I mostly am able to. Of course the higher the difficulty level, the less you can expect to be able to beeline to something. AI is there to win too, they won't let you do whatever you wish.

I think this is kind of a core concept of civ when it comes to beating the cheating AI that shouldn't be messed with. To expand upon that, usually a good strat on higher difficulties is working towards certain techs in order to get an advantage over the AI (be it a wonder, religion, unit, or whatever) because you cannot stay ahead in tech across the board.

With higher difficulty levels you're not supposed to stay ahead in techs. You should be able to struggle but definetely not stay ahead. Not even on Noble, in my view: you should be able to equal some other civs at noble but not run away too much.

My suggestion to fix it is simple: have diffusion start gradually. There's no sense in "diffusing" the first couple techs that civs start with, for example. You can add points in the game where it picks up. Natural ones to me seem to be around Alphabet/Writing, then Optics, Printing Press, etc. This will eliminate the problem you originally wanted to solve (nukes vs pikemen) while at the same time preserving the challenge for those who prefer to play high difficulties, and fixing start bias.

I'm not sure but at some point I scaled tech diffusion by era, I have to check if it's still like that because Afforess created a new tech diffusion algorythm and I don't remember it. Problem is, how should it work? I mean, I'm in the lead and I discover let's say Printing Press which increases tech diffusion. Then this tech hinders me, if I'm in the lead, helping others. If I'm far behind, shoud I be forced to go after Printing Press to receive more tech diffusion? I'm not sure, I'm not convinced although some kind of solution should take this thing into account. Possibly it should really go like that, I mean tech diffusion increases when you reach certain techs, I'm simply not sure if it could work and how to make it work.
 
45°38'N-13°47'E;13284150 said:
I'm not sure but at some point I scaled tech diffusion by era, I have to check if it's still like that because Afforess created a new tech diffusion algorythm and I don't remember it. Problem is, how should it work? I mean, I'm in the lead and I discover let's say Printing Press which increases tech diffusion. Then this tech hinders me, if I'm in the lead, helping others. If I'm far behind, shoud I be forced to go after Printing Press to receive more tech diffusion? I'm not sure, I'm not convinced although some kind of solution should take this thing into account. Possibly it should really go like that, I mean tech diffusion increases when you reach certain techs, I'm simply not sure if it could work and how to make it work.

Right now tech diffusion scales based on how many teams know the tech. If less than 1/3 of the teams (all teams, not just ones you have met) have the tech, diffusion is very slow. This prevents tech diffusion from unfairly giving up your hard earned research. However, once the 1/3 barrier is reached, it begins diffusing faster. Then, when 2/3 of teams have it, it diffuses much much faster (to help far behind civs).

There is nothing there for era scaling. Keep in mind, eras are a poor way to scale tech research, each civ has their own game era. You might be in the medieval while AI's are still in ancient.

I rather like the effect Tech Diffusion has on gameplay. Original research should be *hard*.

One thing that might help is tech diffusion scaling based on score rank - to avoid the top players from getting free research, and help weaker nations.
 
One thing that might help is tech diffusion scaling based on score rank - to avoid the top players from getting free research, and help weaker nations.

What about scaling it for number of cities (i.e. civs with less cities get a higher tech diffusion rate)? Usually backwards civs are like that because they don't have enough cities to produce a good science output. It's ok to me that some civs can be in medieval era while other are still in ancient. That difference is anyway less obvious from industrial era onward. I can't think of civs in renaissance while others are in modern era. 2 eras away is too much IMO especially starting from renaissance/industrial.

Edit: More precisely, number of cities in comparison to other civs. Of course it doesn't make sense to help civs with 3 cities at the start of the game when everyone has 3 cities.
 
Maybe help to put Tech Diffusion in mathematical form, not code form but regular math. That way we can debate better? If so, please post your best mathematical translation of that feature.
 
Maybe help to put Tech Diffusion in mathematical form, not code form but regular math. That way we can debate better? If so, please post your best mathematical translation of that feature.

Sure.

There are a few key variables here:

iTeams = number of alive teams in the game
iMetTeams = number of alive teams we have met in the game
iTeamsHaveTech = number of teams who we have met and have the tech
iModifier = the tech research rate modifier due to tech diffusion = 0 initially

exponent = iTeamsHaveTech * 0.5

TECH_DIFFUSION_KNOWN_TEAM_MODIFIER = 70 //set in TechDiffusion_GlobalDefines.xml

iModifier = TECH_DIFFUSION_KNOWN_TEAM_MODIFIER - (TECH_DIFFUSION_KNOWN_TEAM_MODIFIER * (0.85 ^ exponent + 0.5))
iModifier = TECH_DIFFUSION_KNOWN_TEAM_MODIFIER - (TECH_DIFFUSION_KNOWN_TEAM_MODIFIER * (0.85 ^ exponent) + 0.5)


TECH_DIFFUSION_WELFARE_THRESHOLD = 90 //set in TechDiffusion_GlobalDefines.xml
TECH_DIFFUSION_WELFARE_MODIFIER = 1000 //set in TechDiffusion_GlobalDefines.xml

iTechScorePercent = percent between 0 and 100, based on your tech score / highest tech score in the game

iModifier = iModifier + TECH_DIFFUSION_WELFARE_MODIFIER - (TECH_DIFFUSION_WELFARE_MODIFIER * (0.98 ^ (TECH_DIFFUSION_WELFARE_THRESHOLD - iTechScorePercent) + 0.5))

The iModifier value is then used to increase your tech research rate.
 
Then that modifier gets divided by 100 and multiplied by research rate and it's added to BASE_RESEARCH_RATE.

Code:
int CvPlayer::calculateBaseNetResearch(TechTypes eTech) const
{
	TechTypes eResearchTech;

	if (eTech != NO_TECH)
	{
		eResearchTech = eTech;
	}
	else
	{
		eResearchTech = getCurrentResearch();
	}

[COLOR="Red"]	return (((GC.getDefineINT("BASE_RESEARCH_RATE") + getCommerceRate(COMMERCE_RESEARCH)) * calculateResearchModifier(eResearchTech)) / 100);[/COLOR]
}

Could the problem be here? I mean, since it's an additive modifier it should be huge in order to influence research. What about making it multiplicative? Wouldn't that be better for scaling through differently developed civs?
 
What about multiplying iModifier in int CvPlayer::calculateResearchModifier(TechTypes eTech) with ratio between best score and single civ score (only for backward civs). That way if top civ score is 2000 while a backward civ score is 400, iModifier gets multiplied be 5. Could it work?

I'm not sure how it works because I haven't tested it yet, but what about something like this?
Code:
		if( iTechScorePercent < iWelfareThreshold )
		{
			if( knownExp > 0.0 )
			{
				int iWelfareMod = GC.getTECH_DIFFUSION_WELFARE_MODIFIER();
				//ensure tech diffusion can not hurt research, only help
				iModifier += std::max(0, (iWelfareMod - (int)(iWelfareMod * pow(0.98, iWelfareThreshold - iTechScorePercent) + 0.5)));	
[COLOR="Red"]				int iRatio = 0;
				int iBestScore = MIN_INT;				
				for (int iI = 0; iI < MAX_PLAYERS; iI++)
				{
					if (GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam())
					{
						for (int iJ = 0; iJ < MAX_CIV_PLAYERS; iJ++)
						{
							int iScore = GET_PLAYER((PlayerTypes)iJ).calculateScore(false);
							if (iScore >= iBestScore)
							{
							iBestScore = iScore;
							}
						}			
						iRatio = iBestScore / GET_PLAYER((PlayerTypes)iI).calculateScore(false);
					}		
				}
				iModifier *= iRatio;[/COLOR]
			}
		}
Red part is what I've added. Could it work?
Or maybe adding something like if Player != Human.
 
Ok, here's what I've changed; it looks like it's working for the moment, but I will test a little more before uploading these changes.
Afforess, what do you think of the code? I'm not good at optimizing code but at least it doesn't crash and it seems to work as intended.

Code:
		if( iTechScorePercent < iWelfareThreshold )
		{
			if( knownExp > 0.0 )
			{
				int iWelfareMod = GC.getTECH_DIFFUSION_WELFARE_MODIFIER();
				//ensure tech diffusion can not hurt research, only help
				iModifier += std::max(0, (iWelfareMod - (int)(iWelfareMod * pow(0.98, iWelfareThreshold - iTechScorePercent) + 0.5)));	
[COLOR="Red"]				int iRatio = 0;
				int iBestScore = MIN_INT;				
				for (int iI = 0; iI < MAX_PLAYERS; iI++)
				{
					if (GET_PLAYER((PlayerTypes)iI).getTeam() == getTeam())
					{
						for (int iJ = 0; iJ < MAX_CIV_PLAYERS; iJ++)
						{
							int iScore = GET_PLAYER((PlayerTypes)iJ).calculateScore(false);
							if (iScore >= iBestScore)
							{
							iBestScore = iScore;
							}
						}			
						iRatio = std::max(1, (iBestScore / (1+GET_PLAYER((PlayerTypes)iI).calculateScore(false, false))));
					}		
				}
				iModifier *= iRatio;[/COLOR]
			}
		}

This way a small civ which has 1/5 of the score of the top civ gets a *5 boosted tech diffusion.
 
Sure.

There are a few key variables here:

iTeams = number of alive teams in the game
iMetTeams = number of alive teams we have met in the game
iTeamsHaveTech = number of teams who we have met and have the tech
iModifier = the tech research rate modifier due to tech diffusion = 0 initially

exponent = iTeamsHaveTech * 0.5

TECH_DIFFUSION_KNOWN_TEAM_MODIFIER = 70 //set in TechDiffusion_GlobalDefines.xml

iModifier = TECH_DIFFUSION_KNOWN_TEAM_MODIFIER - (TECH_DIFFUSION_KNOWN_TEAM_MODIFIER * (0.85 ^ exponent + 0.5))

TECH_DIFFUSION_WELFARE_THRESHOLD = 90 //set in TechDiffusion_GlobalDefines.xml
TECH_DIFFUSION_WELFARE_MODIFIER = 1000 //set in TechDiffusion_GlobalDefines.xml

iTechScorePercent = percent between 0 and 100, based on your tech score / highest tech score in the game

iModifier = iModifier + TECH_DIFFUSION_WELFARE_MODIFIER - (TECH_DIFFUSION_WELFARE_MODIFIER * (0.98 ^ (TECH_DIFFUSION_WELFARE_THRESHOLD - iTechScorePercent) + 0.5))

The iModifier value is then used to increase your tech research rate.

Noob question over here. I'm trying to understand your formula (I'm a curious person) here, and for that I tried to see best and worst scenario for this to be applied.


Best scenario: 50 civs in dll, all civs already met, I world builded a stupid civ and decided to take its control. The iTechScorePercent is ~0, exponent = 49/2 = 24.5 (I'm presuming it's a float), and the rest is set as default.

1st iModifier = 70 - (70 * (0.85 ^ 24.5 + 0.5)) = 70 - (70 * 0.52) = 70 - 36.3 = 33

2nd iModifier = 33 + 1000 - (1000 * (0.98 ^ (90 - 0) +0.5)) = 1033 - (1000 * 0.66) = 372

So now it is divided by 100 (3.72) and multiplied by my research rate to be then added to my research rate. So I'll be actually making 4.72x my research rate right? If I'm wrong please point me where/why.

Worst scenario: No civs know the tech I want, and I'm the tech leader. The iTechScorePercent is 100, exponent is 0.

1st iModifier = 70 - (70 * (0.85 ^ 0 + 0.5)) = 70 - (70 * 1.5) = -35

2nd iModifier = -35 + 1000 - (1000 * (0.98 ^ (90 - 100) + 0.5)) = 965 - (1000 * 1.72) = -755

So now it's divided by 100 (-7.55) and multiplied by my research rate and added to my research meaning a -6.55x my tech rate??? Well I'm obviously wrong here, but what's the error?
 
Simple mistake that is throwing everything off, and it's my fault:

TECH_DIFFUSION_KNOWN_TEAM_MODIFIER * (0.85 ^ exponent + 0.5)

should be

(TECH_DIFFUSION_KNOWN_TEAM_MODIFIER * (0.85 ^ exponent) + 0.5)

The exponent has 0.5 added to it to effectively "round up". Due to order of operations, the 0.5 is added at the very last step for that set of parenthesis.

Also, if the modifier is negative it is not used, tech diffusion can not hurt your research rate.
 
So correcting my math:

Best Scenario
1st iModifier = 70 - (70 * (0.85 ^ 24.5) + 0.5) = 70 - (70 * 0.02 + 0.5) = 70 - 1.8 = 68.2 = 68

For the second I guess the same correction is done right?

So instead of (TECH_DIFFUSION_WELFARE_MODIFIER * (0.98 ^ (TECH_DIFFUSION_WELFARE_THRESHOLD - iTechScorePercent) + 0.5))
It should be (TECH_DIFFUSION_WELFARE_MODIFIER * (0.98 ^ (TECH_DIFFUSION_WELFARE_THRESHOLD - iTechScorePercent)) + 0.5)

2nd iModifier = 68 + 1000 - (1000 * (0.98 ^ (90 - 0)) + 0.5) = 1068 - (1000 * 0.16 + 0.5) = 905.19 = 905

So dividing by 100 (9.05), multiplying by tech rate and adding to it, we achieve 10.05x our tech rate.

And in Worst scenario

1st iModifier = 70 - (70 * (0.85 ^ 0) + 0.5) = 70 - (70 * 1 + 0.5) = -0.5 = 0

2nd iModifier = 0 + 1000 - (1000 * (0.98 ^ (90 - 100)) + 0.5) = 1000 - (1000 * 1.22 + 0.5) = -224.38 = -224

As it's negative it's turned into 0, and doesn't do anything to your tech rate.

Now is it right?
 
Top Bottom