Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2003:
[Freeciv-Dev] (PR#4539) rules against smallpox (tutorials/nopox page)
Home

[Freeciv-Dev] (PR#4539) rules against smallpox (tutorials/nopox page)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: cskecskes@xxxxxxxxxx, juhani.heino@xxxxxxxxxx
Subject: [Freeciv-Dev] (PR#4539) rules against smallpox (tutorials/nopox page)
From: "Guest" <rt-guest@xxxxxxxxxxx>
Date: Sun, 7 Dec 2003 13:59:02 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=4539 >

From: Marek Baczynski (imbaczek(at)poczta.onet.pl)

I played with gnuplot a bit and implemented what I've been talking about
recently. (Can't find that ticket, though.)

The patch adds a new tech_cost_style to game.ruleset. Should be easy to
understand. Just tell me what you think (other than it's not realistic
and intuitive.) I believe that even if this idea is not good, this is
the way to go.
diff -ruN -X freeciv/diff_ignore -x .. freeciv/common/tech.c 
baczek-freeciv/common/tech.c
--- freeciv/common/tech.c       2003-11-30 20:34:46.000000000 +0100
+++ baczek-freeciv/common/tech.c        2003-12-07 22:23:04.000000000 +0100
@@ -16,6 +16,7 @@
 #endif
 
 #include <assert.h>
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -373,6 +374,11 @@
      num_parents == number of requirement for tech, counted recursively.
  2 - Cost are read from tech.ruleset. Missing costs are generated by
      style 1.
+ 3 - Like style 1, but is also a function of number of cities the player
+     owns, such that
+     cost = (researchcost * num_researched) *
+            exp(max(cities - freecities, 0) * 
+                ln(2) / (cities_to_double - freecities))
 
  tech_leakage:
  0 - No reduction of the technology cost.
@@ -383,9 +389,15 @@
  3 - Technology cost is reduced depending on the number of normal
      players (human and AI) which already know the tech.
 **************************************************************************/
+
+#define CITY_DOUBLE_RESEARCH_COST 30
+#define CITY_FREE_FOR_RESEARCH 4
+
 int base_total_bulbs_required(struct player *pplayer, Tech_Type_id tech)
 {
   int cost, tech_cost_style = game.rgame.tech_cost_style;
+  int cities;
+  double citycost;
 
   if (!is_future_tech(tech) && get_invention(pplayer, tech) == TECH_KNOWN) {
     /* A non-future tech which is already known costs nothing. */
@@ -413,6 +425,13 @@
     cost = (advances[tech].preset_cost * game.researchcost) /
        GAME_DEFAULT_RESEARCHCOST;
     break;
+  case 3:
+    cost = pplayer->research.techs_researched * game.researchcost;
+    cities = city_list_size(&pplayer->cities);
+    citycost = exp(MAX(cities - CITY_FREE_FOR_RESEARCH, 0) *
+               M_LN2 / (CITY_DOUBLE_RESEARCH_COST - CITY_FREE_FOR_RESEARCH));
+    cost *= citycost;
+    break;
   default:
     die("Invalid tech_cost_style %d %d", game.rgame.tech_cost_style,
        tech_cost_style);
diff -ruN -X freeciv/diff_ignore -x .. freeciv/server/ruleset.c 
baczek-freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2003-11-30 20:34:58.000000000 +0100
+++ baczek-freeciv/server/ruleset.c     2003-12-07 19:11:06.000000000 +0100
@@ -2464,7 +2464,7 @@
 
   game.rgame.tech_cost_style =
       secfile_lookup_int(&file, "civstyle.tech_cost_style");
-  if (game.rgame.tech_cost_style < 0 || game.rgame.tech_cost_style > 2) {
+  if (game.rgame.tech_cost_style < 0 || game.rgame.tech_cost_style > 3) {
     freelog(LOG_ERROR, "Bad value %i for tech_cost_style. Using 0.",
            game.rgame.tech_cost_style);
     game.rgame.tech_cost_style = 0;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#4539) rules against smallpox (tutorials/nopox page), Guest <=