adjustable technology leak rate

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
fomalhaut
Posts: 36
Joined: Thu Feb 13, 2014 8:24 am
Location: Japan

adjustable technology leak rate

Post by fomalhaut »

I like technology leak but sometimes feel that it's too strong.
So I hope to be able to adjust the rate of it in game.ruleset.
User avatar
vodot
Veteran
Posts: 81
Joined: Thu May 17, 2018 4:54 pm

Re: adjustable technology leak rate

Post by vodot »

There is no option for this in 2.6 aside from setting Tech Leak to "Embassies" (The weakest of the three tech leak settings).

If you want to get nuts (LET'S GET NUTS!) then you can find the math itself in 'research.c' in the /common folder. I've copied it below:

Code: Select all

  case TECH_LEAKAGE_EMBASSIES:
    {
      int players = 0, players_with_tech_and_embassy = 0;

      players_iterate_alive(aplayer) {
        const struct research *aresearch = research_get(aplayer);

        players++;
        if (aresearch == presearch
            || (A_FUTURE == tech
                ? aresearch->future_tech <= presearch->future_tech
                : TECH_KNOWN != research_invention_state(aresearch, tech))) {
          continue;
        }

        research_players_iterate(presearch, pplayer) {
          if (player_has_embassy(pplayer, aplayer)) {
            players_with_tech_and_embassy++;
            break;
          }
        } research_players_iterate_end;
      } players_iterate_alive_end;

      fc_assert_ret_val(0 < players, base_cost);
      fc_assert(players >= players_with_tech_and_embassy);
      base_cost *= (double) (players - players_with_tech_and_embassy);
      base_cost /= (double) players;
    }
    break;
To weaken the effect, just tweak the ratio at the end (the 'base_cost *=' bit). Note that by default, the game is reducing the cost by a straight percentage equal to the the ratio of (know_tech+have_embassy)/(all players)— e.g. if 4/10 players know the tech (and you have embassies with 3 of them), the cost of the tech will be reduced by 30%.

Put a 0.5* in there to (globally & permanently, in your copy of the game) cut the effect in half, for example. That would make the reduction only 15%, in the above example.
Last edited by vodot on Sat Jul 14, 2018 8:35 pm, edited 2 times in total.
User avatar
JTN
Elite
Posts: 473
Joined: Wed Jan 30, 2013 12:15 am

Re: adjustable technology leak rate

Post by JTN »

Raised hrm #764944.
Post Reply