Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7548) improvement & generalization of get_tile_value
Home

[Freeciv-Dev] (PR#7548) improvement & generalization of get_tile_value

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7548) improvement & generalization of get_tile_value
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Feb 2004 14:43:28 -0800
Reply-to: rt@xxxxxxxxxxx

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

This patch attempts to improve and generalize get_tile_value.

Rather than a short and incomplete switch statement we have a formula:

- One point for each food, shield, or trade the tile provides.
- Half a point for each extra food, shield, or trade provided by 
irrigation, mining, or road.  (Note the bonus can apply to irrigation or 
mining but not both.)

Can this calculation be improved?  Certainly.  For instance if we follow 
the CMA guidelines Pille gave the food/production/trade ratios should 
probably be something like 10/5/4.  We also might take into account how 
long irrigation, mining, roads take.  Rather than dividing by two (and 
rounding down) we might keep the extra significant digit.

Improving this function is probably a good way to get fairer maps.  Any 
"good" players want to comment on this?  Remember this function is only 
used at map generation time to assess a tile's worth to a starting 
civilization.

Below is a table of tiles and their goodness.

Terrain         Old     New
Desert/Oasis    3       6
Desert/Oil      3       6
Desert/Rvr/Oil  3       7
Desert/Rvr      3       4
Desert          1       3
Forest/Pheas    5       5
Forest/Silk     5       7
Forest/Rvr/Ph   5       6
Forest/Rvr      5       4
Forest          3       3
Glacier         0       1
Grassland/Res   4       5
Grassland/Rvr/R 4       6
Grassland/Rvr   4       5
Grassland       2       4
Hills/Coal      4       6
Hills/Wine      4       8
Hills           2       4
Jungle/Fruit    3       6
Jungle/Gems     3       5
Jungle/Rvr/Fr   3       7
Jungle/Rvr/Ge   3       6
Jungle/Rvr      3       4
Jungle          0       3
Mountains/Gold  3       8
Mountains/Iron  3       5
Mountains       0       2
Ocean/Fish      3       5
Ocean/Whales    3       7
Ocean           1       3
Plains/Buffalo  4       6
Plains/Wheat    4       6
Plains/Rvr/Buf  4       7
Plains/Rvr/Wht  4       7
Plains/Rvr      4       5
Plains          2       4
Swamp/Spice     3       7
Swamp           0       3
Tundra/Furs     1       6
Tundra/Game     1       5
Tundra/River    1       3
Tundra          0       2

Basically what it comes down to is that the old method is bad.  The new 
method is better but still weights trade too much and food too little.

jason

? output
? rc
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.130
diff -u -r1.130 mapgen.c
--- server/mapgen.c     2004/02/26 13:19:47     1.130
+++ server/mapgen.c     2004/02/26 22:40:53
@@ -1000,28 +1000,39 @@
 ****************************************************************************/
 static int get_tile_value(int x, int y)
 {
-  switch (map_get_terrain(x, y)) {
+  struct tile *ptile = map_get_tile(x, y);
+  enum tile_terrain_type old_terrain;
+  enum tile_special_type old_special;
+  int value, irrig_bonus, mine_bonus;
 
-    /* range 0 .. 5 , 2 standard */
+  /* Give one point for each food / shield / trade produced. */
+  value = (get_food_tile(x, y)
+          + get_shields_tile(x, y)
+          + get_trade_tile(x, y));
 
-  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;
-  }
+  old_terrain = ptile->terrain;
+  old_special = ptile->special;
+
+  map_set_special(x, y, S_ROAD);
+  map_irrigate_tile(x, y);
+  irrig_bonus = (get_food_tile(x, y)
+                + get_shields_tile(x, y)
+                + get_trade_tile(x, y)) - value;
+
+  ptile->terrain = old_terrain;
+  ptile->special = old_special;
+  map_set_special(x, y, S_ROAD);
+  map_mine_tile(x, y);
+  mine_bonus = (get_food_tile(x, y)
+                + get_shields_tile(x, y)
+                + get_trade_tile(x, y)) - value;
+
+  ptile->terrain = old_terrain;
+  ptile->special = old_special;
+
+  value += MAX(0, MAX(mine_bonus, irrig_bonus)) / 2;
+
+  return value;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7548) improvement & generalization of get_tile_value, Jason Short <=