Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] (PR#3977) [PATCH] Revised patch which creates new "novice"
Home

[Freeciv-Dev] (PR#3977) [PATCH] Revised patch which creates new "novice"

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: sam+civ@xxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#3977) [PATCH] Revised patch which creates new "novice" skill level
From: "sam+civ@xxxxxxxxxxxxxxxxxxxx" <sam+civ@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 12 Apr 2003 03:36:46 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Hello there,

Again, thank you for the suggestions.  This is a revised version of
my last patch which makes the following changes:

* It patches cleanly against the April 9 CVS snapshot, the most recently
  available CVS tarball.

* It makes sure the novice skill level has the same handicaps as the other 
  skill levels.

* The patch is a MIME attachment (which is still readable by plaintext
  mailers for those of us who feel real men use 'cat file | sendmail whoever'
  to send mail and 'less' to read mail)

I also have a version of this patch which patches cleanly against 1.14.0.

I have no idea how to use autoconf to make a "./configure" script (real
men write their makefiles by hand; real men also know how to read man
pages, something autoconf does not seem to have) so I can not verify
that this patch compiles; however the slightly modified version of the
patch for 1.14.0 compiles and runs cleanly.

- Sam

This patch adds a new "Novice" skill level which requires 250% of the
bulbs of a human player to develop new tech.  Patched against the April
9 CVS snapshot of FreeCiv.

diff -ur freeciv-cvs/common/player.h freeciv-cvs-novice/common/player.h
--- freeciv-cvs/common/player.h Tue Apr  8 21:56:39 2003
+++ freeciv-cvs-novice/common/player.h  Sat Apr 12 01:29:44 2003
@@ -137,6 +137,8 @@
   int skill_level;             /* 0-10 value for save/load/display */
   int fuzzy;                   /* chance in 1000 to mis-decide */
   int expand;                  /* percentage factor to value new cities */
+  int science_cost;             /* Cost in bulbs to get new tech, relative
+                                   to non-AI players (100: Equal cost) */
   int warmth; /* threat of global warming */
   enum barbarian_type barbarian_type;
 };
diff -ur freeciv-cvs/common/tech.c freeciv-cvs-novice/common/tech.c
--- freeciv-cvs/common/tech.c   Mon Apr  7 21:57:03 2003
+++ freeciv-cvs-novice/common/tech.c    Sat Apr 12 01:29:44 2003
@@ -458,6 +458,18 @@
     die("Invalid tech_leakage %d", game.rgame.tech_leakage);
   }
 
+  /* Assisgn a science penalty to the AI at easier skill levels.  This code
+     can also be adpoted to create an extra-hard AI skill level where the AI
+     gets science benefits */
+  if (pplayer->ai.control && pplayer->ai.science_cost > 0 && 
+      pplayer->ai.science_cost != 100) {
+    float fcost, factor;
+    fcost = cost;
+    factor = pplayer->ai.science_cost;
+    fcost *= (factor / 100);
+    cost = fcost;
+  }
+
   /* If we have many players, tech cost may drop to 0.  */
   if (cost == 0) {
     cost = 1;
diff -ur freeciv-cvs/server/stdinhand.c freeciv-cvs-novice/server/stdinhand.c
--- freeciv-cvs/server/stdinhand.c      Tue Apr  8 21:56:42 2003
+++ freeciv-cvs-novice/server/stdinhand.c       Sat Apr 12 01:40:20 2003
@@ -966,6 +966,7 @@
   CMD_TAKE,
   CMD_CREATE,
   CMD_AWAY,
+  CMD_NOVICE,
   CMD_EASY,
   CMD_NORMAL,
   CMD_HARD,
@@ -1155,6 +1156,15 @@
    N_("Set yourself in away mode. The AI will watch your back."),
    N_("The AI will govern your nation but do minimal changes."),
   },
+  {"novice",   ALLOW_CTRL,
+   /* TRANS: translate text between <> only */
+   N_("novice\n"
+      "novice <player-name>"),
+   N_("Set one or all AI players to 'novice'."),
+   N_("With no arguments, sets all AI players to skill level 'novice', and "
+      "sets the default level for any new AI players to 'novice'.  With an "
+      "argument, sets the skill level for that player only.")
+  },
   {"easy",     ALLOW_CTRL,
    /* TRANS: translate text between <> only */
    N_("easy\n"
@@ -1630,7 +1640,7 @@
 ***************************************************************/
 static const char *name_of_skill_level(int level)
 {
-  const char *nm[11] = { "UNUSED", "away", "UNKNOWN", "easy",
+  const char *nm[11] = { "UNUSED", "away", "novice", "easy",
                         "UNKNOWN", "normal", "UNKNOWN", "hard",
                         "UNKNOWN", "UNKNOWN", "experimental" };
   
@@ -1645,7 +1655,8 @@
 {
   int h[11] = { -1,
                H_AWAY,
-               H_NONE,
+ /* novice */   H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
+                        | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE,
  /* easy */    H_RATES | H_TARGETS | H_HUTS | H_NOPLANES 
                         | H_DIPLOMAT | H_LIMITEDHUTS | H_DEFENSIVE,
                H_NONE,
@@ -1667,20 +1678,37 @@
 **************************************************************************/
 static int fuzzy_of_skill_level(int level)
 {
-  int f[11] = { -1, 0, 0, 300/*easy*/, 0, 0, 0, 0, 0, 0, 0 };
+  int f[11] = { -1, 0, 400/*novice*/, 300/*easy*/, 0, 0, 0, 0, 0, 0, 0 };
   
   assert(level>0 && level<=10);
   return f[level];
 }
 
 /**************************************************************************
+Return the AI's science development cost; a science development cost of 100
+means that the AI develops science at the same speed as a human; a science
+development cost of 200 means that the AI develops science at half the speed
+of a human, and a sceence development cost of 50 means that the AI develops
+science twice as fast as the human
+**************************************************************************/
+static int science_cost_of_skill_level(int level) 
+{
+  int x[11] = { -1, 100, 250/*novice*/, 100/*easy*/, 100, 100, 100, 100, 
+                100, 100, 100 };
+  
+  assert(level>0 && level<=10);
+  return x[level];
+}
+
+/**************************************************************************
 Return the AI expansion tendency, a percentage factor to value new cities,
 compared to defaults.  0 means _never_ build new cities, > 100 means to
 (over?)value them even more than the default (already expansionistic) AI.
 **************************************************************************/
 static int expansionism_of_skill_level(int level)
 {
-  int x[11] = { -1, 100, 100, 10/*easy*/, 100, 100, 100, 100, 100, 100, 100 };
+  int x[11] = { -1, 100, 10/*novice*/, 10/*easy*/, 100, 100, 100, 100, 
+                100, 100, 100 };
   
   assert(level>0 && level<=10);
   return x[level];
@@ -1943,7 +1971,9 @@
        cmdlevel_name(first_access_level));
 
     fprintf(script_file, "%s\n",
-       (game.skill_level <= 3) ?       "easy" :
+        (game.skill_level == 1) ?       "away" :
+       (game.skill_level == 2) ?       "novice" :
+       (game.skill_level == 3) ?       "easy" :
        (game.skill_level == 5) ?       "medium" :
        (game.skill_level < 10) ?       "hard" :
                                        "experimental");
@@ -2498,6 +2528,7 @@
   pplayer->ai.handicap = handicap_of_skill_level(level);
   pplayer->ai.fuzzy = fuzzy_of_skill_level(level);
   pplayer->ai.expand = expansionism_of_skill_level(level);
+  pplayer->ai.science_cost = science_cost_of_skill_level(level);
   pplayer->ai.skill_level = level;
 }
 
@@ -2509,6 +2540,7 @@
 {
   switch(level) {
     case 1 : return CMD_AWAY;
+    case 2 : return CMD_NOVICE;
     case 3 : return CMD_EASY;
     case 5 : return CMD_NORMAL;
     case 7 : return CMD_HARD;
@@ -3421,6 +3453,9 @@
   case CMD_AWAY:
     set_away(caller, arg);
     break;
+  case CMD_NOVICE:
+    set_ai_level(caller, arg, 2);
+    break;
   case CMD_EASY:
     set_ai_level(caller, arg, 3);
     break;
@@ -4204,6 +4239,7 @@
 static const int player_cmd[] = {
   CMD_RENAME,
   CMD_AITOGGLE,
+  CMD_NOVICE,
   CMD_EASY,
   CMD_NORMAL,
   CMD_HARD,


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3977) [PATCH] Revised patch which creates new "novice" skill level, sam+civ@xxxxxxxxxxxxxxxxxxxx <=