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

[Freeciv-Dev] (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] (PR#6472) Add some measurement output to server
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 10 Oct 2003 14:19:33 -0700
Reply-to: rt@xxxxxxxxxxxxxx

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.

  - 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:16:45 -0000
@@ -203,6 +210,30 @@
     gamelog(GAMELOG_NORMAL, _("Game ended in a draw as end year exceeded"));
     return TRUE;
   }
+
+  /* Output some ranking and AI debugging info here. */
+  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;
+    if (game.turn % 10 == 0) {
+      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;
 
   /* count barbarians */
   players_iterate(pplayer) {

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