Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] [PATCH] Patch which creates new "novice" skill level
Home

[Freeciv-Dev] [PATCH] Patch which creates new "novice" skill level

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxxx
Cc: rt@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] Patch which creates new "novice" skill level
From: sam+civ@xxxxxxxxxxxxxxxxxxxx
Date: Fri, 11 Apr 2003 02:18:12 -0700 (PDT)

Hello there,

This patch incorporates both Gregory's and Per's suggestions and
feedback for a patch which gives the AI a tech penalty.  In line
with Greg's suggestions, the science penalty is level-dependent.
Additionally, it is in a style similiar to the set_ai_level_directer
function, and the penalty is in the pplayer->at struct.

Additionally, this patch incorperates Per's suggestion to only have
the science penalty apply for a new "novice" skill level (which also 
has a "fuzzy" of 400 as opposed to Easy's "fuzzy" of 300).  The science
penalty is 250%, which means it costs the AI 2.5 as many bulbs to
get a given tech.

I also have a version of this patch without the new "Novice" level
that applies the 2.5x bulb cost to the "Easy" skill level.

Again, if there are any objections to this patch, please let me know.

I would like to thank everyone for their feedback with my patches.

- Sam

P.S. My thought on Arctic towns: Let them be built, but do not have huts
     give out towns on the pole squares.  The most common reason I  
     have towns on the pole squares is because huts give them to me.

--- freeciv-1.14.0/common/player.h      Mon Nov 18 04:23:38 2002
+++ freeciv-1.14.0-handicap3/common/player.h    Fri Apr 11 00:38:01 2003
@@ -124,6 +124,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;
 };
--- freeciv-1.14.0/common/tech.c        Fri Oct 11 16:35:13 2002
+++ freeciv-1.14.0-handicap3/common/tech.c      Fri Apr 11 00:38:01 2003
@@ -457,6 +457,18 @@
     exit(EXIT_FAILURE);
   }
 
+  /* 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;
--- freeciv-1.14.0/server/stdinhand.c   Fri Nov 15 19:14:22 2002
+++ freeciv-1.14.0-handicap3/server/stdinhand.c Fri Apr 11 00:58:36 2003
@@ -955,6 +955,7 @@
   CMD_METASERVER,
   CMD_AITOGGLE,
   CMD_CREATE,
+  CMD_NOVICE,
   CMD_EASY,
   CMD_NORMAL,
   CMD_HARD,
@@ -1121,6 +1122,15 @@
    N_("The 'create' command is only available before the game has "
       "been started.")
   },
+  {"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"
@@ -1596,7 +1606,7 @@
 ***************************************************************/
 static const char *name_of_skill_level(int level)
 {
-  const char *nm[11] = { "UNUSED", "UNKNOWN", "UNKNOWN", "easy",
+  const char *nm[11] = { "UNUSED", "UNKNOWN", "novice", "easy",
                         "UNKNOWN", "normal", "UNKNOWN", "hard",
                         "UNKNOWN", "UNKNOWN", "experimental" };
   
@@ -1632,20 +1642,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];
@@ -1889,7 +1916,8 @@
        cmdlevel_name(first_access_level));
 
     fprintf(script_file, "%s\n",
-       (game.skill_level <= 3) ?       "easy" :
+       (game.skill_level <= 2) ?       "novice" :
+       (game.skill_level == 3) ?       "easy" :
        (game.skill_level == 5) ?       "medium" :
        (game.skill_level < 10) ?       "hard" :
                                        "experimental");
@@ -2444,6 +2472,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;
 }
 
@@ -2454,6 +2483,7 @@
 static enum command_id cmd_of_level(int level)
 {
   switch(level) {
+    case 2 : return CMD_NOVICE;
     case 3 : return CMD_EASY;
     case 5 : return CMD_NORMAL;
     case 7 : return CMD_HARD;
@@ -3123,6 +3153,9 @@
   case CMD_CREATE:
     create_ai_player(caller,arg);
     break;
+  case CMD_NOVICE:
+    set_ai_level(caller, arg, 2);
+    break;
   case CMD_EASY:
     set_ai_level(caller, arg, 3);
     break;
@@ -3913,6 +3946,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] [PATCH] Patch which creates new "novice" skill level, sam+civ <=