Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6472) Add some measurement output to server
Home

[Freeciv-Dev] Re: (PR#6472) Add some measurement output to server

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#6472) Add some measurement output to server
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 10 Oct 2003 14:28:24 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, 10 Oct 2003, Per I. Mathisen wrote:
> On request, this is a modified version of the AI measurement patch. It
> adds some interesting info about each player to the gamelog every 10
> turns. This can be used to measure AIs or generate interesting statistics
> on pubserver.

Forget the previous patch. It was braindead. Read this one instead.

  - Per

Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.139
diff -u -r1.139 srv_main.c
--- server/srv_main.c   23 Sep 2003 15:59:05 -0000      1.139
+++ server/srv_main.c   10 Oct 2003 21:25:47 -0000
@@ -532,6 +532,31 @@
   marco_polo_make_contact();
   make_history_report();
   send_player_turn_notifications(NULL);
+
+  /* Output some ranking and AI debugging info here. */
+  if (game.turn % 10 == 0) {
+    players_iterate(pplayer) {
+      int workers = 0, food = 0, shields = 0, trade = 0, settlers = 0;
+
+      /* Compile statistics */
+      unit_list_iterate(pplayer->units, punit) {
+        if (unit_flag(punit, F_CITIES)) {
+          settlers++; 
+        }
+      } unit_list_iterate_end;
+      city_list_iterate(pplayer->cities, pcity) {
+        workers += pcity->size;
+        shields += pcity->shield_prod;
+        food += pcity->food_prod;
+        trade += pcity->trade_prod;
+      } city_list_iterate_end;
+      gamelog(GAMELOG_NORMAL, "INFO %s cities %d, pop %d "
+              "food %d, prod %d, trade %d, settlers %d, units %d",
+              pplayer->name, city_list_size(&pplayer->cities), workers, food,
+              shields, trade, settlers, unit_list_size(&pplayer->units));
+    } players_iterate_end;
+  }
+
   freelog(LOG_DEBUG, "Turn ended.");
   game.turn_start = time(NULL);
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#6472) Add some measurement output to server, Per I. Mathisen <=