Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7514) move is_good_tile into mapgen
Home

[Freeciv-Dev] (PR#7514) move is_good_tile into mapgen

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7514) move is_good_tile into mapgen
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Feb 2004 14:14:54 -0800
Reply-to: rt@xxxxxxxxxxx

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

This patch moves is_good_tile() into mapgen and renames it as 
get_tile_value().

I'd like to point out that this function is awful.  Forests are way too 
high.  Grassland is too low.  Wheat is too low.  Whales are _WAY_ too 
low.  Tundra with specials is too low.  Etc, etc.

I also want to remove the terrain references from this function.  I 
thought of putting in

   base_tile_shield_value() + base_tile_food_value()
     + base_tile_trade_value()

but this is not right either.  Hills for instance would only get 1 point 
but they are easily improvable, whereas arctic gets 1 point and is 
practically unusable.

Possible solutions:

- Put the goodness value into the ruleset, and use that value.  Note 
you'd need separate values for the two specials.
- Make a more complex function that looks at the improvability of a 
tile.  Like adding on half of the bonus for mining, half the bonus for 
building a road, half the bonus for building a city, half the bonus for 
irrigation, etc.

But for now I'm just moving it into mapgen.

jason

? coasts.diff
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.162
diff -u -r1.162 map.c
--- common/map.c        2004/02/23 05:31:19     1.162
+++ common/map.c        2004/02/24 22:03:41
@@ -432,35 +432,6 @@
 /***************************************************************
 ...
 ***************************************************************/
-int is_good_tile(int x, int y)
-{
-  switch (map_get_terrain(x, y)) {
-
-    /* range 0 .. 5 , 2 standard */
-
-  case T_FOREST:
-    return (map_get_special(x, y) == S_NO_SPECIAL) ? 3 : 5;
-  case T_GRASSLAND:
-  case T_PLAINS:
-  case T_HILLS:
-    return (map_get_special(x, y) == S_NO_SPECIAL) ? 2 : 4;
-  case T_DESERT:
-  case T_OCEAN:/* must be called with usable seas */    
-    return (map_get_special(x, y) == S_NO_SPECIAL) ? 1 : 3;
-  case T_SWAMP:
-  case T_JUNGLE:
-  case T_MOUNTAINS:
-    return (map_get_special(x, y) == S_NO_SPECIAL) ? 0 : 3;
-  /* case T_ARCTIC: */
-  /* case T_TUNDRA: */
-  default:
-    return (map_get_special(x, y) == S_NO_SPECIAL) ? 0 : 1;
-  }
-}
-
-/***************************************************************
-...
-***************************************************************/
 bool is_hut_close(int x, int y)
 {
   square_iterate(x, y, 3, x1, y1) {
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.176
diff -u -r1.176 map.h
--- common/map.h        2004/02/18 22:26:45     1.176
+++ common/map.h        2004/02/24 22:03:42
@@ -295,7 +295,6 @@
 bool terrain_is_clean(int x, int y);
 bool is_at_coast(int x, int y);
 bool is_hut_close(int x, int y);
-int is_good_tile(int x, int y);
 bool is_special_close(int x, int y);
 bool is_sea_usable(int x, int y);
 int get_tile_food_base(struct tile * ptile);
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.129
diff -u -r1.129 mapgen.c
--- server/mapgen.c     2004/02/23 05:31:21     1.129
+++ server/mapgen.c     2004/02/24 22:03:43
@@ -995,6 +995,35 @@
   freelog(LOG_VERBOSE, "Map has %d continents", map.num_continents);
 }
 
+/****************************************************************************
+  Return an approximation of the goodness of a tile to a civilization.
+****************************************************************************/
+static int get_tile_value(int x, int y)
+{
+  switch (map_get_terrain(x, y)) {
+
+    /* range 0 .. 5 , 2 standard */
+
+  case T_FOREST:
+    return (map_get_special(x, y) == S_NO_SPECIAL) ? 3 : 5;
+  case T_GRASSLAND:
+  case T_PLAINS:
+  case T_HILLS:
+    return (map_get_special(x, y) == S_NO_SPECIAL) ? 2 : 4;
+  case T_DESERT:
+  case T_OCEAN:/* must be called with usable seas */    
+    return (map_get_special(x, y) == S_NO_SPECIAL) ? 1 : 3;
+  case T_SWAMP:
+  case T_JUNGLE:
+  case T_MOUNTAINS:
+    return (map_get_special(x, y) == S_NO_SPECIAL) ? 0 : 3;
+  /* case T_ARCTIC: */
+  /* case T_TUNDRA: */
+  default:
+    return (map_get_special(x, y) == S_NO_SPECIAL) ? 0 : 1;
+  }
+}
+
 /**************************************************************************
  Allocate islands array and fill in values.
  Note this is only used for map.generator <= 1 or >= 5, since others
@@ -1050,7 +1079,7 @@
     
     /* Now actually add the tile's value to all these continents */
     for (j = 0; j < seen_conts; j++) {
-      islands[conts[j]].goodies += is_good_tile(x, y);
+      islands[conts[j]].goodies += get_tile_value(x, y);
     }
   } whole_map_iterate_end;
   
@@ -1096,7 +1125,7 @@
   if (min == 0) {
     freelog(LOG_VERBOSE,
             "If we continue some starting positions will have to have "
-            "access to zero resources (as defined in is_good_tile). \n");
+            "access to zero resources (as defined in get_tile_value). \n");
     freelog(LOG_FATAL,
             "Cannot create enough starting position and will abort.\n"
             "Please report this bug at " WEBSITE_URL);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7514) move is_good_tile into mapgen, Jason Short <=