Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#10722) Not enough grasslands/plains
Home

[Freeciv-Dev] (PR#10722) Not enough grasslands/plains

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mburda@xxxxxxxxx, miky40@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10722) Not enough grasslands/plains
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Dec 2004 01:34:52 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10722 >

Attached is a patch that will print this information while running
mapgen (just change the log level to LOG_NORMAL).  Also attached is the
same thing for 1.14.

With this it's easy to see that even the "fix" doesn't bring the
percentages close to what they were in 1.14.  Whether this is good or
bad I can't say.

jason

? print_map.diff
Index: server/generator/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.c,v
retrieving revision 1.18
diff -u -r1.18 mapgen.c
--- server/generator/mapgen.c   25 Nov 2004 05:31:59 -0000      1.18
+++ server/generator/mapgen.c   2 Dec 2004 09:34:33 -0000
@@ -979,6 +979,37 @@
 }
 
 /**************************************************************************
+  Debugging function to print information about the map that's been
+  generated.
+**************************************************************************/
+static void print_mapgen_map(void)
+{
+  const int loglevel = LOG_DEBUG;
+  int terrain_count[T_COUNT];
+  int total = 0;
+
+  terrain_type_iterate(t) {
+    terrain_count[t] = 0;
+  } terrain_type_iterate_end;
+
+  whole_map_iterate(ptile) {
+    Terrain_type_id t = map_get_terrain(ptile);
+
+    assert(t >= 0 && t < T_COUNT);
+    terrain_count[t]++;
+    if (!is_ocean(t)) {
+      total++;
+    }
+  } whole_map_iterate_end;
+
+  terrain_type_iterate(t) {
+    freelog(loglevel, "%20s : %4d %d%%  ",
+           get_terrain_name(t), terrain_count[t],
+           (terrain_count[t] * 100 + 50) / total);
+  } terrain_type_iterate_end;
+}
+
+/**************************************************************************
   See stdinhand.c for information on map generation methods.
 
 FIXME: Some continent numbers are unused at the end of this function, fx
@@ -1094,6 +1125,8 @@
   }
 
   assign_continent_numbers(FALSE);
+
+  print_mapgen_map();
 }
 
 /**************************************************************************
? civworld
? diff
? map
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/Attic/mapgen.c,v
retrieving revision 1.99.2.1
diff -u -r1.99.2.1 mapgen.c
--- server/mapgen.c     26 Jul 2004 03:44:19 -0000      1.99.2.1
+++ server/mapgen.c     2 Dec 2004 09:33:11 -0000
@@ -1173,6 +1173,38 @@
 }
 
 /**************************************************************************
+  Debugging function to print information about the map that's been
+  generated.
+**************************************************************************/
+static void print_mapgen_map(void)
+{
+  const int loglevel = LOG_DEBUG;
+  int terrain_count[T_COUNT];
+  int total = 0;
+  int t;
+
+  for (t = 0; t < T_COUNT; t++) {
+    terrain_count[t] = 0;
+  }
+
+  whole_map_iterate(x, y) {
+    t = map_get_terrain(x, y);
+
+    assert(t >= 0 && t < T_COUNT);
+    terrain_count[t]++;
+    if (t != T_OCEAN) {
+      total++;
+    }
+  } whole_map_iterate_end;
+
+  for (t = 0; t < T_COUNT; t++) {
+    freelog(loglevel, "%20s : %4d %d%%  ",
+           get_terrain_name(t), terrain_count[t],
+           (terrain_count[t] * 100 + 50) / total);
+  }
+}
+
+/**************************************************************************
   See stdinhand.c for information on map generation methods.
 
 FIXME: Some continent numbers are unused at the end of this function, fx
@@ -1224,6 +1256,8 @@
 
   if (map.num_continents>0)
     update_island_impr_effect(-1, map.num_continents);
+
+  print_mapgen_map();
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]