Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] (PR#3973) Re: (PR#3977) [PATCH] Revised patch which create
Home

[Freeciv-Dev] (PR#3973) Re: (PR#3977) [PATCH] Revised patch which create

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: sam+civ@xxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#3973) Re: (PR#3977) [PATCH] Revised patch which creates new "novice" skill level
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Thu, 17 Apr 2003 13:03:18 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Hi,

You patch applied well against CVS, I updated the thing which I didn't 
like (the floats) and also fixed a bug which appeared when I tried to load 
games with a novice.  The problem seems to be that update_research was 
called before the science_rate was properly set.

Please check the patch.  I think it is ready for inclusion.

Few comments: 
1. When sending an update of a patch to RT make sure to include the 
original (PR#).  Otherwise we have to spend time cleaning RT and sorting 
the patches instead of reviewing and committing ;)

2. When mailing to RT, do not CC to freeciv-dev, it will be done 
automatically.

3. To create Makefiles just run ./autogen.sh

Best wishes,
G.

? pf_fix.diff
? trir.gz
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.97
diff -u -r1.97 player.h
--- common/player.h     2003/04/08 20:36:10     1.97
+++ common/player.h     2003/04/17 18:31:52
@@ -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;
 };
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.61
diff -u -r1.61 tech.c
--- common/tech.c       2003/04/07 17:10:44     1.61
+++ common/tech.c       2003/04/17 18:31:52
@@ -458,6 +458,14 @@
     die("Invalid tech_leakage %d", game.rgame.tech_leakage);
   }
 
+  /* Assign 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) {
+    assert(pplayer->ai.science_cost > 0);
+    cost = (cost * pplayer->ai.science_cost) / 100;
+  }
+
   /* If we have many players, tech cost may drop to 0.  */
   if (cost == 0) {
     cost = 1;
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.114
diff -u -r1.114 savegame.c
--- server/savegame.c   2003/02/17 22:49:28     1.114
+++ server/savegame.c   2003/04/17 18:31:53
@@ -44,6 +44,7 @@
 #include "ruleset.h"
 #include "spacerace.h"
 #include "srv_main.h"
+#include "stdinhand.h"
 #include "unittools.h"
 
 #include "aicity.h"
@@ -631,14 +632,20 @@
      * from A_FUTURE (which shouldn't ever be here anyway). */
     plr->ai.tech_goal = A_UNSET;
   }
+  /* Some sane defaults */
   plr->ai.handicap = 0;                /* set later */
   plr->ai.fuzzy = 0;           /* set later */
   plr->ai.expand = 100;                /* set later */
+  plr->ai.science_cost = 100;  /* set later */
   plr->ai.skill_level =
     secfile_lookup_int_default(file, game.skill_level,
                               "player%d.ai.skill_level", plrno);
   if (plr->ai.control && plr->ai.skill_level==0) {
     plr->ai.skill_level = GAME_OLD_DEFAULT_SKILL_LEVEL;
+  }
+  if (plr->ai.control) {
+    /* Set AI parameters */
+    set_ai_level_directer(plr, plr->ai.skill_level);
   }
 
   plr->economic.gold=secfile_lookup_int(file, "player%d.gold", plrno);
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.276
diff -u -r1.276 stdinhand.c
--- server/stdinhand.c  2003/04/12 18:24:42     1.276
+++ server/stdinhand.c  2003/04/17 18:31:53
@@ -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;
@@ -4200,6 +4235,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]