Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] (PR#3955) [PATCH] Make AI tech handiap a parameter
Home

[Freeciv-Dev] (PR#3955) [PATCH] Make AI tech handiap a parameter

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3955) [PATCH] Make AI tech handiap a parameter
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Tue, 8 Apr 2003 03:15:04 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Forwarding patch to RT...

Date: Mon,  7 Apr 2003 17:51:27 -0700 (PDT)
From: sam+civ@xxxxxxxxxxxxxxxxxxxx
To: freeciv-dev@xxxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] Improved patch which makes tech handiap a
    parameter

Hello there,

With the help of Vallimar, I now have a FreeCiv patch which makes the
tech handicap a user-adjustable parameter.  In addition, the patch also
allows the AI's city growth to be slowed down.

I understand there is sone controversey with this patch among the FreeCiv
community.  It is my sincere hope that, by making this an adjustable 
parameter, we can satisfy the desires of both those who want to make 
the game easier for newbies, and the desires of those who enjoy a 
challenge from the AI, even at the easy skill level.

If there are any objections to this patch, please voice them here on
the list.  I feel very strongly that this needs to be part of the
FreeCiv tree; almost every time people discuss FreeCiv in a public forum,
people complain that the AI is too difficult to defeat.  In fact, I am
helping someone who is frustrated with the AI, even at "easy" level,
to compile and install FreeCiv with the earlier version of the tech 
handicap patch.

While I have gotten good enough to defeat the AI, even at hard level (I
was up to 6am last night defeating two "hard" AI opponents on a tiny
40x32 map [1]), I would never have stayed interested in FreeCiv to become
this good without the "training wheels" of a tech handicap.

I also appreciate the interest in the Tectonic plate patch; I personlly
feel this will be ready for inclusion in to the main tree when there
is some way of giving the client a progress bar showing the time it will
take to generate the map.  

I also like the idea of pluggable map generators; there are a number of
ideas I would like to see become map generators, such as John Beale's
gforge, but the present method of having them hard-wired in the source
can quickly cause the source to become unwieldly if we add too many
generators.

There are a number of fractal generators out there which use fractals
to generate maps; these generators should generate maps almost as 
satisfatory as the tectonic generator at a fraction of the computational
cost of the tectonic generator.

Again, Vallimar did a lot of work making this a changable parameter;
I really appreciate his help.

- Sam

[1] I did disable fog of war, since the AI can always see the entire map

diff -ur freeciv-1.14.0/common/game.c freeciv-1.14.0-handicap/common/game.c
--- freeciv-1.14.0/common/game.c        Fri Oct 11 16:35:13 2002
+++ freeciv-1.14.0-handicap/common/game.c       Mon Apr  7 16:57:41 2003
@@ -714,6 +714,9 @@
   game.watchtower_extra_vision=GAME_DEFAULT_WATCHTOWER_EXTRA_VISION,
   game.allowed_city_names = GAME_DEFAULT_ALLOWED_CITY_NAMES;
 
+  game.slowai_tech = GAME_DEFAULT_SLOWAI_TECH;
+  game.slowai_grow = GAME_DEFAULT_SLOWAI_GROW;
+
   sz_strlcpy(game.rulesetdir, GAME_DEFAULT_RULESETDIR);
 
   game.firepower_factor = 1;
diff -ur freeciv-1.14.0/common/game.h freeciv-1.14.0-handicap/common/game.h
--- freeciv-1.14.0/common/game.h        Fri Oct 11 16:35:13 2002
+++ freeciv-1.14.0-handicap/common/game.h       Mon Apr  7 17:02:02 2003
@@ -217,6 +217,9 @@
     bool load_private_map; /* Only makes sense if the players are loaded. */
     bool load_settings;
   } load_options;
+
+  int slowai_tech;
+  int slowai_grow;
 };
 
 /* Unused? */
@@ -455,4 +458,11 @@
 
 #define GAME_START_YEAR -4000
 
+#define GAME_DEFAULT_SLOWAI_TECH 100
+#define GAME_MIN_SLOWAI_TECH 50
+#define GAME_MAX_SLOWAI_TECH 400
+#define GAME_DEFAULT_SLOWAI_GROW 100
+#define GAME_MIN_SLOWAI_GROW 25
+#define GAME_MAX_SLOWAI_GROW 100
+
 #endif  /* FC__GAME_H */
diff -ur freeciv-1.14.0/common/tech.c freeciv-1.14.0-handicap/common/tech.c
--- freeciv-1.14.0/common/tech.c        Fri Oct 11 16:35:13 2002
+++ freeciv-1.14.0-handicap/common/tech.c       Mon Apr  7 17:07:35 2003
@@ -457,6 +457,17 @@
     exit(EXIT_FAILURE);
   }
 
+  /* For casual players, the AI gets tech far too fast.  This
+     slows down how fast the AI gets tech by the value in 
+     game.slowai_tech */
+  if (!game.is_new_game && pplayer->ai.control && game.slowai_tech != 100) {
+      float fcost, factor;
+      fcost = cost;
+      factor = game.slowai_tech;
+      fcost *= (factor / 100);
+      cost = fcost;
+      }
+
   /* If we have many players, tech cost may drop to 0.  */
   if (cost == 0) {
     cost = 1;
diff -ur freeciv-1.14.0/server/savegame.c 
freeciv-1.14.0-handicap/server/savegame.c
--- freeciv-1.14.0/server/savegame.c    Sun Dec  8 15:32:30 2002
+++ freeciv-1.14.0-handicap/server/savegame.c   Mon Apr  7 17:10:13 2003
@@ -1862,6 +1862,12 @@
        secfile_lookup_int_default(file, game.allowed_city_names,
                                   "game.allowed_city_names"); 
 
+    game.slowai_tech = secfile_lookup_int_default(file,
+        GAME_DEFAULT_SLOWAI_TECH, "game.slowai_tech");
+
+    game.slowai_grow = secfile_lookup_int_default(file,
+        GAME_DEFAULT_SLOWAI_GROW, "game.slowai_grow");
+
     if(game.civstyle == 1) {
       string = "civ1";
     } else {
@@ -2184,6 +2190,8 @@
   secfile_insert_int(file, game.watchtower_vision, "game.watchtower_vision");
   secfile_insert_int(file, game.watchtower_extra_vision, 
"game.watchtower_extra_vision");
   secfile_insert_int(file, game.allowed_city_names, "game.allowed_city_names");
+  secfile_insert_int(file, game.slowai_tech, "game.slowai_tech");
+  secfile_insert_int(file, game.slowai_grow, "game.slowai_grow");
 
   if (TRUE) {
     /* Now always save these, so the server options reflect the
diff -ur freeciv-1.14.0/server/settlers.c 
freeciv-1.14.0-handicap/server/settlers.c
--- freeciv-1.14.0/server/settlers.c    Fri Nov 15 19:14:22 2002
+++ freeciv-1.14.0-handicap/server/settlers.c   Mon Apr  7 17:01:55 2003
@@ -34,6 +34,7 @@
 #include "aiunit.h"
 #include "aidata.h"
 
+#include "rand.h"
 #include "settlers.h"
 
 /* negative: in_city_radius, 0: unassigned, positive: city_des */
@@ -1262,8 +1263,8 @@
   /* Decide whether to build a new city:
    * if so, modify: gx, gy, best_newv, best_act
    */
-  if (unit_flag(punit, F_CITIES) &&
-      pplayer->ai.control) {
+  if (unit_flag(punit, F_CITIES) && pplayer->ai.control &&
+      (myrand(101) <= game.slowai_grow)) {
     int nx, ny;
     int want = evaluate_city_building(punit, &nx, &ny, &ferryboat);
 
diff -ur freeciv-1.14.0/server/stdinhand.c 
freeciv-1.14.0-handicap/server/stdinhand.c
--- freeciv-1.14.0/server/stdinhand.c   Fri Nov 15 19:14:22 2002
+++ freeciv-1.14.0-handicap/server/stdinhand.c  Mon Apr  7 17:15:40 2003
@@ -820,6 +820,24 @@
             "40=debuging logging."), NULL, 
          0, 40, 20)
 
+  GEN_INT("slowaitech", game.slowai_tech, SSET_RULES_FLEXIBLE, 
+          SSET_SERVER_ONLY, N_("Adjust AI tech advancement by %"),
+         N_("This value determines how much slower the AI will learn "
+            "new technologies compared to human players. Setting this to "
+            "a value greater than 100 will slow their advancement.  For "
+            "example, giving this a value of 200 slows down the AI's tech "
+            "advancment by half."), NULL, GAME_MIN_SLOWAI_TECH, 
+         GAME_MAX_SLOWAI_TECH, GAME_DEFAULT_SLOWAI_TECH)
+
+  GEN_INT("slowaigrowth", game.slowai_grow, SSET_RULES_FLEXIBLE, 
+          SSET_SERVER_ONLY, N_("Adjust city growth by %"),
+         N_("This value determines how much slower the AI will expand in "
+         "relation to human players. Setting a percent value under "
+         "100 will cause them to expand at about the specified rate "
+         "as compared to normal AI expansion."), NULL, 
+         GAME_MIN_SLOWAI_GROW, GAME_MAX_SLOWAI_GROW, GAME_DEFAULT_SLOWAI_GROW)
+
+
   GEN_END
 };
 





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3955) [PATCH] Make AI tech handiap a parameter, Gregory Berkolaiko <=