# Technology Cost

This cost of a given technology is determined by the following.

- TECHS: Techs you've discovered already (including trading/pods/artifacts, but not the ones you started with) + unknown variable A - unknown variable B.
- MOSTTECHS: This number is equals to the max number of technologies discovered by any faction. Unknown variable A is added to this number.
- DIFF: This is 1 on citizen difficulty, 2 on specialist, 3 on talent or librarian, 4 on thinker, 5 on transcend.
- TURNS: Number of turns.

1. Find (DIFF*4)+8. AIs instead use 29-(DIFF*3). If this number is smaller than -12 then use -12 for this number. If this number is bigger than 12, then use 12 for this number.

2. Take TECHS, and subtract TURNS/8 (or TURNS/12 with tech stagnation), to a minimum of 0 and a maximum equal to the result of step 1 (or 1.5 times the result of step 1 with tech stagnation).

3. Add the result of step 2 to the result of step 1.

4. Take (MOSTTECHS - TECHS)/5 , rounding up. Subtract this from the result of step 3, but no more than 30% the result of step 3 (rounding normally) plus 1. AIs instead divide by a number dependent on difficulty, ranging from 3 on Transcend to 8 on Citizen, and the maximum percentage ranges from 0% plus 1 on citizen to 50% plus 1 on transcend.

5. Take TECHS, and add 1 for factions with a natural penalty to research, or subtract 1 for factions with a natural bonus to research. If the result is less than 1, use 1. Multiply this by the result of step 4.

6. Modify by WORLDSIZE and faction and alpha(x).txt tech cost modifiers, and add 50% with tech stagnation.