# "Tech jumping"

Discussion in 'Civ4 Strategy Articles' started by Willburn, Feb 9, 2006.

1. ### BrazenheartChieftain

Joined:
Mar 6, 2006
Messages:
7
Location:
Boston, MA
I'm not sure I follow this logic. If the beaker to beaker bonus conversion is affected by rounding, why does it matter what I run my sciences at? If after the slider my beakers are at some number not divisible by 4 (in the case of a library, where divisibility by 4 would result in a whole number), don't I still lose the extra beaker regardless?

2. ### DaveMcWDeity

Joined:
Oct 8, 2002
Messages:
6,489
There is one setting that is not affected by rounding: 0%! You can minimize rounding by running 0% as often as possible.

I'm not going to try to prove that statement by logic, but if you crunch the numbers for any example you will find it is true. You may break even in the worst case, but you will never lose beakers.

3. ### BrazenheartChieftain

Joined:
Mar 6, 2006
Messages:
7
Location:
Boston, MA
Ah, I get it. Since the chance of there not being a rounding error is 1/4 with libraries (or worse in more complex situations), you could potentially save a beaker for every city you own in a given turn using this technique. At an average rate of science being 80%, you would run 0% 1/5 turns, and thus save at maximum (1/5 * cities * turns), or about 1/5 your number of cities in beakers per turn, as a rule. Is this correct?

4. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
If I might use an example to illustrate the effect:

A city has a commerce production of 20 and a gold bonus of 25% and a science bonus of 25%.

If you run at 100% tax on one turn and on 100% science another turn, then this city grants you 1.25* 20 = 25 gold and 1.25 * 20 = 25 science.
If you run at 50% tax and 50% science for two turns, then this city grants you 1.25 *10 = 12 gold and 1.25 * 10 = 12 science for two turns, for a total of 24 gold and 24 science.

A loss of 1/25 or 4% of your science + gold in this example (normally the loss will be less for a city with this amount of commerce production).

The effect of switching between 0 and 100% science is relatively bigger in the beginning of the game because cities have a lower output of commerce in the beginning of the game.

The original article that discusses this micromanagement can be found here.
It can be better discussed there as this thread contains a different strategy.

5. ### pholkheroDeviant Mind

Joined:
Feb 24, 2006
Messages:
5,651
Location:
I've found that too, but even later on, you can save yourself a turn or two this way, which, as you all know, in some games, this makes all the difference. Conversely, though, you really can only save a turn or two, and in the end, is that worth it? hmmm...well, figure this: 8 techs that all take 7 turns to research at the non-0-100% way = 56 turns, but if researched the 0-100% way, 49 turns...so maybe it does pay-off

but it is terribly tedious

6. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
The effect can't be that big. Not the difference between 56 and 49 turns. That's a far larger effect than what can be reached by this micromanagement.

I would expect an effect of up to 5% in the beginning of the game (after libraries) and an effect of up to 1% in the late game, or something like that. Mostly even less than those figures.

You could estimate its effect by looking at the tax output at 100% gold and the science output at 100% science. Add those two and compare it with the double of the tax + gold output of a 50% science, 50% gold setting.

7. ### pholkheroDeviant Mind

Joined:
Feb 24, 2006
Messages:
5,651
Location:
I found that it reduces research by about a turn or so (for the *most* part). Therefore, if, instead of taking 56 turns to research 7 techs, you do the all-or-nothing approach, you save a turn for each tech (approx). So, you get 49 turns for 7 techs. OTOH, you could get 8 techs in 56 turns.

8. ### BrazenheartChieftain

Joined:
Mar 6, 2006
Messages:
7
Location:
Boston, MA
Thanks, Roland.

The reason I'm responding in this thread is because I'm responding to a specific argument which was made in this thread, which is that running a binary science rate is always preferable. I believe this statement to be erroneous, although I believe that it is in all practical cases preferable.

I believe it is possible to lose beakers this way if you have nothing but libraries in your cities and all of your cities produce 10 commerce (or some other number that makes the following calculation work):

Method 1: Run your sciences at 80% for 5 turns:

Turn 1: (10 * .8 * 1.25) = 10 science, (10 * .2) = 2 gold.
Turn 2: 10 science, 2 gold
Turn 3: 10 science, 2 gold
Turn 4: 10 science, 2 gold
Turn 5: 10 science, 2 gold
Total: 50 science, 10 gold

Method 2: Run your sciences at 100% for 4 turns, 0% for 1 turn:

Turn 1: (10 * 1 * 1.25) = 12 science, (10 * 0) = 0 gold
Turn 2: 12 science, 0 gold
Turn 3: 12 science, 0 gold
Turn 4: 12 science, 0 gold
Turn 5: (10 * 0 * 1.25) = 0 science, (10 * 1) = 10 gold
Total 48 science, 10 gold

Because in fact running at 100% is what did you in, in this limited scenario. On the average, any science level except 0% will cause 3/4 of your cities with libraries in them to run inefficiently, but in the worst case it is possible to lose beakers.

9. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
Ah, a very good counterexample, using the fact that you might lose a 25% bonus for a turn. You might want to repost that example in this thread, because this trick of switching between 100% and 0% science was first posted there (AFAIK) and presented as an always working strategy.

I also agree that in most practical circumstances, the trick to switch between 0% and 100% science will provide a benefit.

10. ### KayEssGone to the dogs

Joined:
Feb 1, 2004
Messages:
227
Location:
Bangkok
Just to be pedantic, it isn't the loss of bonus that causing it, but rather the rounding. 10 * 1 * 1.25 is 12.5 and you lose this .5 every turn (for a total of 2 overall over the four turns).

It would be nice if some sort of 'dither' algorithm was used that meant that you would regain these fractions every so often. The city maintenance seems to do something like this becuase the total maintenance is spread around the cities in such a way that the empire's total comes out to the calculated amount.

With a library you will lose to rounding in 3/4 of your cities (all those producing science beakers that aren't a multiple of 4). I don't think there's any way that you could micromanage this without hurting yourself overall.

Again (without crunching any numbers) it seems to me that you will always lose from rounding in a number of your cities. At the early part of the game where every bit counts this may be important, but by the time you have the libraries I expect that there's too much commerce to make the few beaker difference that you may gain/lose be of much import.

Interesting stuff though, even if there seems little practical application.

11. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
In general the binary science rate is better. The intuitive reason is that when you have a 25% science bonus and a 25% gold bonus (or other percentages different from 0% or 100%) and a science rate other than 100% or 0%, then you can lose a fraction of gold on the 25% bonus of gold and a fraction of science on the 25% bonus of science. When you use a 0% or 100% science rate, then you can only lose a fraction of gold or a fraction of science, but not both at the same time.

Example: A city with 22 commerce production and a 25% bonus on gold and science.
The city does one turn of 100% gold and one turn of 100% science:
The gold output will be 1.25 * 22 = 27 and the science output will be 1.25 * 22 = 27. The city lost 0.5 gold in one turn and 0.5 science in the other turn.
The city does two turns of 50% gold, 50% science. The city will have an output of 1.25 * 11 = 13 gold and 13 science per turn for a total of 26 science and 26 gold. The city lost 0.75 gold and 0.75 science in every turn.

This is just an example but when you have a 25% bonus on gold and science, then the binary science rate will always be better then the balanced approach. You will not be able to construct a counterexample where there is a 25% bonus on science and tax.

The reason that the counterexample worked is that he used an example where there was only a science bonus of 25% and no bonus on gold income. In the balanced 80-20 science rate, the 25% bonus was applied each turn and in the binary science rate case, the 25% bonus is applied for 4 out ot 5 turns. The numbers are chosen in such a way that the 25% bonus is exactly the same when a 100% science rate is used, then when a 80% science rate is used. This way 5 turns of a 25% bonus are greater then 4 turns of a 25% bonus.

Of course, this has everything to do with the rounding. But the reason that the binary science rate is in general better is also based on the rounding. The reason that this counterexample worked is that Brazenheart chose his numbers in such a way that the 25% bonus of science was used fully in each turn when running an 80% science rate. I think he made the counterexample based on that idea. And that was what I wanted to say to Brazenheart in my short reply and was maybe a bit brief for other posters that were reading that statement.

Then again, most people were not waiting for this lengthy analysis...

12. ### KayEssGone to the dogs

Joined:
Feb 1, 2004
Messages:
227
Location:
Bangkok
That depends on the formula. My guess is that the actual formula used by the game for beakers and culture must be:

floor( floor( commerce * rate ) * bonus )

And for gold it would be:

floor( celing( commerce * rate ) * bonus )

These aren't the formulas in Requis' analysis though. Given these formulae then the binary rates will give you at least a 10% bonus on total tech and gold output and maybe a lot more (around 40%) for some of them.

If on the other hand you use a more nieve formula for science:

floor( commerce * rate * bonus )

Then for low levels of commerce the binary rate is worse because the bonus rate will tip the scales back above 1 so you get a free science beaker.

I can't believe that the game does that though, but I haven't checked it. Requis' post seems to imply the first two formulae though. The bonus for binary science seems to be a lot more worthwhile than I expected it to be.

13. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
Almost. These are the formulas when you only have a tax and a science rate (which is actually the case that we're assuming here). If you also have a culture rate then it works in the following way:

Base Science: floor( commerce * rate )
Base Culture: floor( commerce * rate )
Base Gold: (commerce - Base Science - Base Culture)

The actual science/culture/gold is then calculated by
Science = floor (Base Science * bonus)

Requies analysis of technology research is mostly not about the production of beakers in a city. It considers that and then looks at how the game modifies the amount of beakers produced by all of your cities in your empire into a progress on the research bar. Your total amount of beaker production can be 1000, but the progress on the research bar 1200 per turn. He does give the above research beaker per city formula at the beginning of his thread but does not mention the rounding down after bonusses from buildings are added. There is a rounding down however.

The difference is really not that big. You can test it by comparing the gold + science at three settings, 100% science, 0% gold, 50% science, 50% gold and 0% science, 100% gold.

For instance, in my present game these numbers result in:
100% science, 0% gold: 1624 research, 76 gold, 1700 total output
50% science, 50% gold: 807 research, 910 gold, 1717 total output
0% science, 100% gold: 13 research, 1733 gold, 1746 total output

You would expect a 1723 total output when there was no rounding at the 50-50 setting. So the rounding leads to a relative loss of 6/1723 = 0.35%
Almost negligible. Now this is a late game save (1652AD) and in the beginning of the game the effect will be a lot bigger.

I did the same calculation at the various other timepoints in the game:

Nothing very dramatic. Still, the binary science rate can be usefull, but it's not a miracle for the rate of technological development.

14. ### KayEssGone to the dogs

Joined:
Feb 1, 2004
Messages:
227
Location:
Bangkok
I was taking the rate to be the effective rate. For science and culture it is what you set, but for gold it is the 100 - science - culture as you say. But, the gold is ceiling() because the remainder after divying up the science and culture goes as gold. If you use floor() for gold too then you will lose commerce points in rounding. Think of a city that produces one commerce and has no multipliers and you have the science set at 80% and culture set at 10%. This city will produce one gold not nothing.

The higher numbers only come from having a library and market place in every city, which in a real game isn't going to happen. I think that at 50% you will see a minimum for the difference though because you're doing one turn at each extreme. The calculation for the difference though should be:

total with science @ 100% * number of turns
plus
total with science @ 0% * number of turns

So you would get 1717 * 2 versus 1700 + 1746. This actually makes it even closer in this case. What happens when you wanted to run the science at 90% or 10% though? I can't load a game right now to see. The difference is of course very dependant on the mix of improvements you have throughout your empire as well and for some situations the difference could be more, in others it may be less.

And yes, Wilburn, didn't mean to hijack the thread, just getting carried away in the details here...

15. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
In my calculation, the city would also get 1 gold.

However if you set culture and science at 30% in a city with a commerce production of 2, then the city will produce 2 gold, although 40% of 2 commerce is 1 gold rounded up.
The reason is that the game calculates 0 science and 0 culture (because of rounding down) and then calculates gold as 2-0-0=2.
Afterwards the various multipliers for the science, gold and culture rate are applied.

Actually, at the higher difficulty levels, you typically have a marketplace in every city that has a library, because a city that has a high commerce rate is good for gold as well as for science. And at these levels, the maintenance costs are so high, that you can't get away without building the gold multiplying buildings (except for military rushing type games on small maps that typically are finished so early that none of this is important).

The game from which the numbers stem had about an equal amount of gold as science increasing buildings. That can be seen by that fact that the science production at 100% science is close to the gold production at 100% gold.

Okay, you're multiplying everything by a factor of 2. That will make no difference for the percentage, i.e. 100/1000=200/2000.

16. ### WillburnWarlord

Joined:
Sep 29, 2005
Messages:
204
hehe i dont have any problems with the thread beeing "hijacked" as you say it since its fairly on topic. Also ive been quite busy preparing and playing the Clan Cup Championship of civ4 so I havent had much time to check on this thread.

Interesting observation that you sometimes may earn on not going for 100% with a only a libary. Will keep that in mind.

17. ### KayEssGone to the dogs

Joined:
Feb 1, 2004
Messages:
227
Location:
Bangkok
Whohoo, I have permission to batter this a bit more

I think you're right and that means that I have a mistake in my model. I haven't seen the actual formula that is used in any other thread (but I've probably missed it). I can think of two ways of doing it and which they actually did seems as much a matter of programming convenience as anything else.

For science and culture you could have one of these two:

floor( floor( commerce * rate ) * bonus )

floor( commerce * rate * bonus )

Clearly the second formula gives a better return on bonus multipliers than the first.

As for gold, my first guess with ceiling() is clearly flawed as you point out. Given that I think the only way it can be done is:

floor( commerce - floor( commerce * scienc_rate ) - floor( commerce * culture_rate ) * bonus )

or

floor( floor( commerce - floor( commerce * science_rate ) - floor( commerce * culture_rate ) ) * bonus )

I'm not being that clear with my terms, but I hope that the context makes it obvious what I mean.

At 50% percent it won't, but I think at every other percentage it will squew the result somewhat, but not by the amounts I had initially.

I think I shall have to go back to the game and see what it does on some of these edge conditions. Unfortunately these days I have more time to talk about playing than I actually have to play as the game is not stable enough to play on my normal login.

18. ### Roland JohansenDeity

Joined:
Apr 29, 2003
Messages:
4,292
Location:
the Netherlands
I guess, you'd want to change the way the formula works so that rounding has a lesser effect. I agree that in that case, you'd want to postpone the rounding until the latest possible moment. That would lessen the effect of the binary science rate.

At 10% gold, 90% science you could compare the gold + science output with 0.1 times the 100% gold output + 0.9 times the 100% science output (or alternatively 10 turns of 10% gold, 90% science compared to 1 turn 100% gold + 9 turns 100% science). The percentage loss at 10% gold, 90% science might be a little higher than at 50% gold, 50% science. But I don't think it will make a big difference.

19. ### KayEssGone to the dogs

Joined:
Feb 1, 2004
Messages:
227
Location:
Bangkok
Quite. At the early part of the game it's possible that it will be worth worrying about, but later on? If that's a concern then you should be playing at a higher level.

20. ### LeExp.Chieftain

Joined:
Mar 28, 2006
Messages:
3
Nice!!! now I can research up too military tradition faster, turn off my science, save my money and upgrade 50 knights into Cavalry/Cossaks and go take the frontline out.