Technology cost

DonQuigleone

Warlord
Joined
Feb 26, 2010
Messages
102
Hi,

What factors go into determining how much your technologies cost?

Also, which files contain the modifiers that determine the speed you research technologies at?
 
I'm currently in the process of reforming and streamlining the factors influencing technology cost, as well as making them more transparent in the interface.

Standard BtS factors:

Base cost + game speed modifier + difficulty modifier

RFC/DoC add the following:
- civ specific modifiers
- discount for small empires
- discount for recently born civs
- discount for civs behind in the tech race (lower quartile)
- penalty for civs ahead in the tech race (upper quartile)

The BtS stuff is in the XML (techs, game speed and handicap infos respectively). Civ modifiers are in CvRhyes.cpp. The other modifiers can be found in CvTeam::getResearchCost() and going from there.
 
I'm currently in the process of reforming and streamlining the factors influencing technology cost, as well as making them more transparent in the interface.

Standard BtS factors:

Base cost + game speed modifier + difficulty modifier

RFC/DoC add the following:
- civ specific modifiers
- discount for small empires
- discount for recently born civs
- discount for civs behind in the tech race (lower quartile)
- penalty for civs ahead in the tech race (upper quartile)

The BtS stuff is in the XML (techs, game speed and handicap infos respectively). Civ modifiers are in CvRhyes.cpp. The other modifiers can be found in CvTeam::getResearchCost() and going from there.

At what point do you lose the discount for being small?
 
The discount decreases with your number of cities until you are at 0 with 5 cities.
 
The discount decreases with your number of cities until you are at 0 with 5 cities.

I was playing around adding cities to my civ to see how tech costs go up, and I found it very difficult to make out any patterns. For instance, I started as China, increased my civ's size to 15 cities, and didn't see any increase in tech costs. I then played the first few turns as Arabia, and over the first few turns the cost went up from ~4000 for Astronomy to ~4500 for Astronomy, though I don't know if that was more due to the sudden increase in size as all the cities flip, or your increase in score. It's behaves extremely strangely.

Is there any optimum number of cities you should have to maximise how fast you tech? Anything else I should do to maximise my technology speed?
 
Sorry, when I hear the word maximize my brain switches off.
 
RFC/DoC add the following:
- discount for recently born civs

This one is a bit redundant, because even late-game civs don't start out with very much territory and improvements.
Because they need to start growing, they're not generally working commerce tiles like Cottages to begin with.
 
I think it exists to mitigate the effects of exactly that somewhat.
 
I was playing around adding cities to my civ to see how tech costs go up, and I found it very difficult to make out any patterns. For instance, I started as China, increased my civ's size to 15 cities, and didn't see any increase in tech costs. I then played the first few turns as Arabia, and over the first few turns the cost went up from ~4000 for Astronomy to ~4500 for Astronomy, though I don't know if that was more due to the sudden increase in size as all the cities flip, or your increase in score. It's behaves extremely strangely.

Is there any optimum number of cities you should have to maximise how fast you tech? Anything else I should do to maximise my technology speed?

hope posting code is not against the rules, if it is please delete.

here you go, the three most relevant functions to analyze. CvTeam.cpp if more interested. Team modifiers are here: http://forums.civfanatics.com/showthread.php?t=545161


PHP:
int CvTeam::getResearchCost(TechTypes eTech, bool bModifiers) const
{
	int iCost;

	FAssertMsg(eTech != NO_TECH, "Tech is not assigned a valid value");

	iCost = GC.getTechInfo(eTech).getResearchCost();

	//iCost *= GC.getHandicapInfo(getHandicapType()).getResearchPercent(); //Rhye
	iCost *= GC.getHandicapInfo(getHandicapType()).getResearchPercentByID(getLeaderID()); //Rhye
	iCost /= 100;

	iCost *= getScenarioResearchModifier();
	iCost /= 100;

	iCost *= getCivilizationResearchModifier();
	iCost /= 100;

	iCost *= GC.getWorldInfo(GC.getMapINLINE().getWorldSize()).getResearchPercent();
	iCost /= 100;

	iCost *= GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getResearchPercent();
	iCost /= 100;

	// Leoreth: use tech era instead of start era to fix unintentional changes for late scenarios and make adjusting tech costs easier
	//iCost *= GC.getEraInfo(GC.getGameINLINE().getStartEra()).getResearchPercent();
	iCost *= GC.getEraInfo((EraTypes)GC.getTechInfo(eTech).getEra()).getResearchPercent();
	iCost /= 100;

	iCost *= std::max(0, ((GC.getDefineINT("TECH_COST_EXTRA_TEAM_MEMBER_MODIFIER") * (getNumMembers() - 1)) + 100));
	iCost /= 100;

	if (bModifiers)
	{
		iCost *= getPopulationResearchModifier();
		iCost /= 100;

		iCost *= getTechLeaderModifier();
		iCost /= 100;

		iCost *= getSpreadResearchModifier(eTech);
		iCost /= 100;

		iCost *= getTurnResearchModifier();
		iCost /= 100;
	}

	return std::max(1, iCost);
}

population modificator
PHP:
int CvTeam::getPopulationResearchModifier() const
{
	int iModifier = 100;

	int iMultiplier;
	int iNumCities = getNumCities();

	if (getID() < NUM_MAJOR_PLAYERS)
	{
		// Rhye: discount for small empires
		if (iNumCities < 5)
		{
			iMultiplier = 5 * std::max(0, GET_PLAYER(getLeaderID()).getCurrentEra() - 2);

			iModifier += iMultiplier * (5 - iNumCities);
		}
	}

	return iModifier;
}

tech leader modifier
PHP:
int CvTeam::getTechLeaderModifier() const
{
	int iModifier = 100;

	// Leoreth: penalty for the tech leader
	if (GC.getGame().getTechRank(getID()) == 0 && GC.getGame().getGameTurn() - getTurnForYear(startingTurnYear[getID()]) > getTurns(30))
	{
		int iBestValue = getTotalTechValue();
		int iDenominator = 0;
		int iAverageValue = 0;

		for (int iI = 0; iI < NUM_MAJOR_PLAYERS; iI++)
		{
			if (iI != getID() && GET_PLAYER((PlayerTypes)iI).isAlive() && !GET_TEAM((TeamTypes)iI).isVassal(getID()))
			{
				iAverageValue += GET_TEAM((TeamTypes)iI).getTotalTechValue();
				iDenominator += 1;
			}
		}

		// Leoreth: average is skewed for too few civs, also ruins the Babylonian UP
		if (iDenominator > 5)
		{
			iAverageValue /= iDenominator;

			// extra costs come in 10% increments
			int iSurplus = (100 * iBestValue / iAverageValue - 100) / 10;

			iModifier += 10 * iSurplus;
		}
	}

	return iModifier;
}
 
Top Bottom