issue with tech_upkeep_free

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
3plus4i
Veteran
Posts: 62
Joined: Wed Aug 17, 2022 1:26 pm

issue with tech_upkeep_free

Post by 3plus4i »

I tried to play around with tech upkeep, but I can't get tech_upkeep_free to work. It simply seems to be ignored, as soon as the first tech is researched, I have to pay upkeep. Changing the value of tech_upkeep_free doesn't make any difference. Though I just realized that the numbers don't work out either way. Does setting a tech cost multiplier for a game not affect tech upkeep?

I have set the divider to 50 and tech cost to 200%. The base research cost for the first tech is 100, increased to 200 with the multiplier, yet I pay 5 bulbs upkeep, regardless whether I put tech_upkeep_free to 20 or 1000. What I expected was to pay no upkeep for techs costing less than 1000 bulbs.

Still on v3.0.3 btw.
cazfi
Elite
Posts: 3165
Joined: Tue Jan 29, 2013 6:54 pm

Re: issue with tech_upkeep_free

Post by cazfi »

First of all, I notice that game.rulesets have confusing documentation. Comment of tech_upkeep_style mentions tech_upkeep_free as if it was a game.ruleset field. There is no such thing.
tech_upkeep_free refers to the Tech_Upkeep_Free effects.
cazfi
Elite
Posts: 3165
Joined: Tue Jan 29, 2013 6:54 pm

Re: issue with tech_upkeep_free

Post by cazfi »

cazfi wrote: Tue Jun 18, 2024 9:02 amFirst of all, I notice that game.rulesets have confusing documentation.
-> https://redmine.freeciv.org/issues/727
3plus4i
Veteran
Posts: 62
Joined: Wed Aug 17, 2022 1:26 pm

Re: issue with tech_upkeep_free

Post by 3plus4i »

Oooh, that possibility didn't even cross my mind. Easily got it to work as an effect now, just have to test if it behaves as expected. The description in game.ruleset isn't entirely clear on whether the reduction is applied on sum of researched techs or per tech.

I'm also not sure how the math works out. tech_upkeep_divider = 50 on a tech costing 100 should give 2, right? sciencebox = "200" should make that 4. Not sure how the game got to 5.
3plus4i
Veteran
Posts: 62
Joined: Wed Aug 17, 2022 1:26 pm

Re: issue with tech_upkeep_free

Post by 3plus4i »

Yeah, the math behind tech upkeep is beyond me. I tested it in a game with the standard sciencebox of 100(%). tech_upkeep_divider = 50 and I removed the tech_upkeep_free effect to see the numbers.

1 tech (1x100 bulbs), upkeep 1
2 techs (2x100), upkeep 5
3 techs (3x100), upkeep 9
4 techs (3x100, 1x150), upkeep 15
5 techs (3x100, 2x150), upkeep 21
6 techs (3x100, 3x150), upkeep 27
7 techs (3x100, 3x150, 1x225), upkeep 36
8 techs (3x100, 3x150, 1x225, 1x338), upkeep 49

The closest fit I can see is each 100 bulb tech adding 4 to upkeep, 150 adding 6, 225 adding 9 etc, twice as much as specified, with an implicit tech_upkeep_free of 3 coming from ... somewhere.
cazfi
Elite
Posts: 3165
Joined: Tue Jan 29, 2013 6:54 pm

Re: issue with tech_upkeep_free

Post by cazfi »

Reading the source code, tech cost gets multiplied by (1 + Tech_Cost_Factor effect)

I'm not sure (didn't check deeply enough) what kind of rounding errors integer math causes along the calculation.

The upkeep is being calculated from the total tech cost calculated first.

civ2civ3 ruleset (and likely others) have base Tech_Upkeep_Free effect with value 3.
3plus4i
Veteran
Posts: 62
Joined: Wed Aug 17, 2022 1:26 pm

Re: issue with tech_upkeep_free

Post by 3plus4i »

I found the tech_upkeep_free effect, totally forgot to look for it before adding my own to effects.ruleset. So at least that one got cleared up.

I understand the tech cost formula, though I'm overriding it with specific costs anyway, since the options don't include an exponential variant. that doesn't explain the upkeep cost. According to the description in game.ruleset, the tech upkeep should be tech cost divided by the specified factor. So with tech_upkeep_divider = 50 the upkeep should be 2% of the total cost, whereas the numbers indicate that it uses 4% instead.
cazfi
Elite
Posts: 3165
Joined: Tue Jan 29, 2013 6:54 pm

Re: issue with tech_upkeep_free

Post by cazfi »

Can you attached your ruleset modifications and a savegame where this issue can be seen?

Note that Tech_Cost_Factor is applied on the cost even if the base cost is one you've explicitly specified, i.e., it's not part of the formula that gets overridden.
Post Reply