Experimenting with Tech Upkeep

Planning and discussing Freeciv Longturn gaming
User avatar
Corbeau
Elite
Posts: 1018
Joined: Mon Jan 13, 2014 11:13 pm

Experimenting with Tech Upkeep

Postby Corbeau » Tue Jul 18, 2017 1:23 pm

Settings:

[research]
; Method of paying tech upkeep
; "None" - no upkeep
; "Basic" - upkeep is calculated as:
; <Cost of technology> / tech_upkeep_divider - tech_upkeep_free
; "Cities" - upkeep is calculated like "Basic", but multiplied by number of cities
tech_upkeep_style = "Cities"
(Note: I think <Cost of technology> is the cost of ALL techs currently in posession)

; upkeep cost is divided by this value
tech_upkeep_divider = 2000

; basic free tech upkeep
[effect_upkeep_tech_free]
type = "Tech_Upkeep_Free"
value = 3
(I'm not sure what this means)





Result:

Currently researching: Railroad
No. of cities: 12
No. of Libraries: 11
No. of Universities: 0
Cost of current tech: 1402
Bulbs produced per turn: 468
Needed for upkeep: 87
Bulbs used per turn: 381

cazfi
Elite
Posts: 1710
Joined: Tue Jan 29, 2013 6:54 pm

Re: Experimenting with Tech Upkeep

Postby cazfi » Tue Jul 18, 2017 1:36 pm

Corbeau wrote:; basic free tech upkeep
[effect_upkeep_tech_free]
type = "Tech_Upkeep_Free"
value = 3
(I'm not sure what this means)


From doc/README.effects:

Code: Select all

Tech_Upkeep_Free
    If this value is greater than 0, the tech upkeep is reduced by this value.
    For tech upkeep style "Basic" this is total reduction, for tech upkeep
    style "Cities" this reduction is applied to every city.

User avatar
Corbeau
Elite
Posts: 1018
Joined: Mon Jan 13, 2014 11:13 pm

Re: Experimenting with Tech Upkeep

Postby Corbeau » Tue Jul 18, 2017 1:52 pm

So that's actually the number of bulbs? If the value was "0", in the above example (12 cities), upkeep would be 36 more?

I thought that it was something like that, but missed the "applied to every city" part and when I saw the numbr "3", it was absurd.

Anyway, thanks.

User avatar
Corbeau
Elite
Posts: 1018
Joined: Mon Jan 13, 2014 11:13 pm

Re: Experimenting with Tech Upkeep

Postby Corbeau » Wed Jul 19, 2017 8:40 am

After some experimentation, it is safe to say that either something is wrong with the formula or I am not getting something right.

I have set

type = "Tech_Upkeep_Free"
value = 0


in order to get less interference.

So, the formula without this should be:

(<Cost of technology> / tech_upkeep_divider) * No.of cities

Values I have:

Cost of technology: 2200 (I was literally adding up costs as I went along)
Divider: 2000
Cities: 13


Upkeep for these values should be 15, but it is 30. Furthermore, as I was keeping track the whole time, upkeep was persistently x1.5 to x2 of what it should have been, based on this formula. Literally, when I discovered techs that cost, for example, 80 and 111 (with 13 cities), upkeep jumped by 2.

So, does anyone know what EXACTLY "<Cost of technology>" is, because I don't think it means what I think it means.

User avatar
JTN
Elite
Posts: 462
Joined: Wed Jan 30, 2013 12:15 am

Re: Experimenting with Tech Upkeep

Postby JTN » Wed Jul 19, 2017 9:34 am

It would be useful to know details of your experimental setup:
  • What branch/version of code?
  • What ruleset were you starting with?
  • Do you have team_pooled_research enabled?
  • If so, were you on a team? With any AIs? Of what skill level?
One thing I notice in comparing player_tech_upkeep() to base_total_bulbs_required() is that tech leakage isn't taken into account for tech upkeep (nor can it be, I think) -- the game doesn't remember what you actually paid for research, it looks at what techs you now have and recreates a calculation. Could that be significant in your case?

User avatar
Corbeau
Elite
Posts: 1018
Joined: Mon Jan 13, 2014 11:13 pm

Re: Experimenting with Tech Upkeep

Postby Corbeau » Wed Jul 19, 2017 10:17 am

JTN wrote:It would be useful to know details of your experimental setup:
  • What branch/version of code?


2.5.7

  • What ruleset were you starting with?


  • Standard multiplayer. only changes: movement rates and taht one Tech_Upkeep_Free number.

  • Do you have team_pooled_research enabled?
  • If so, were you on a team? With any AIs? Of what skill level?


  • Pooled research was on, but this is most classic single player, almost no contact with other civs, didn't do any diplomacy.

    One thing I notice in comparing player_tech_upkeep() to base_total_bulbs_required() is that tech leakage isn't taken into account for tech upkeep (nor can it be, I think) -- the game doesn't remember what you actually paid for research, it looks at what techs you now have and recreates a calculation. Could that be significant in your case?


    I also tried to check if tech leakage is on, but didn't find the option. However, I don't think so because as I was checking tech costs, they were persistent within classes, depending on the number of requirements.

    If it helps, tech cost was resolved like this:

    ; 1 - Cost of technology is:
    ; MAX((1+parents) * (researchcost/2) * sqrt(1+parents), researchcost)
    ; where num_parents == number of requirement for tech, counted
    ; recursively.

    So, do you know how exactly the tech-upkeep function calculates the cos? If it uses a method independent of the ruleset, this could be it, ony need to find which method it is.

    User avatar
    JTN
    Elite
    Posts: 462
    Joined: Wed Jan 30, 2013 12:15 am

    Re: Experimenting with Tech Upkeep

    Postby JTN » Wed Jul 19, 2017 8:29 pm

    Well, I know in the sense that I have access to the source code and know where to look, but I only quickly skimmed it this morning; I've not been through it line-by-line. It wouldn't surprise me to find a bug, though.

    Links to the relevant bits for S2_5 in case someone beats me to it: base_total_bulbs_required(), player_tech_upkeep().

    User avatar
    Corbeau
    Elite
    Posts: 1018
    Joined: Mon Jan 13, 2014 11:13 pm

    Re: Experimenting with Tech Upkeep

    Postby Corbeau » Wed Jul 19, 2017 9:56 pm

    Ok, had a look, can't decode it, someone with more expertise required :)

    cazfi
    Elite
    Posts: 1710
    Joined: Tue Jan 29, 2013 6:54 pm

    Re: Experimenting with Tech Upkeep

    Postby cazfi » Wed Jul 19, 2017 10:13 pm

    Do you have "Tech_Cost_Factor" effects? In the functions jtn linked there seems to be some inconsistency in its handling. player_tech_upkeep() assumes that factor is 1 by default (without any additional effects), base_total_bulbs_required() handles it without adding 1 to the given effects.

    User avatar
    Corbeau
    Elite
    Posts: 1018
    Joined: Mon Jan 13, 2014 11:13 pm

    Re: Experimenting with Tech Upkeep

    Postby Corbeau » Wed Jul 19, 2017 10:43 pm

    If you are asking me, I'm afraid I don't understand the question.