Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] Re: (PR#11601) likely_ocean() cheats
Home

[Freeciv-Dev] Re: (PR#11601) likely_ocean() cheats

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#11601) likely_ocean() cheats
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Tue, 22 Mar 2005 14:03:09 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11601 >


  Untested patch, corrects some hex bugs too.


  - ML

diff -Nurd -X.diff_ignore freeciv/ai/aiexplorer.c freeciv/ai/aiexplorer.c
--- freeciv/ai/aiexplorer.c     2005-03-22 22:26:59.953125000 +0200
+++ freeciv/ai/aiexplorer.c     2005-03-22 23:02:14.828125000 +0200
@@ -38,40 +38,28 @@
 **************************************************************************/
 static int likely_ocean(struct tile *ptile, struct player *pplayer)
 {
-  int sum;
+  int ocean = 0;
+  int land = 0;
 
+  /* We do not check H_MAP here, it should be done by map_is_known() */
   if (map_is_known(ptile, pplayer)) {
     /* we've seen the tile already. */
     return (is_ocean(map_get_terrain(ptile)) ? 100 : 0);
   }
-  
-  /* Now we're going to do two things at once. We're going to see if
-   * we know any cardinally adjacent tiles, since knowing one will
-   * give a guaranteed value for the centre tile. Also, we're going
-   * to count the non-cardinal (diagonal) tiles, and see how many
-   * of them are ocean, which gives a guess for the ocean-ness of 
-   * the centre tile. */
-  sum = 50;
+
+  /* The central tile is likely to be the same as the
+   * nearby tiles. */
   adjc_dir_iterate(ptile, ptile1, dir) {
     if (map_is_known(ptile1, pplayer)) {
-      if (is_cardinal_dir(dir)) {
-       /* If a tile is cardinally adjacent, we can tell if the 
-        * central tile is ocean or not by the appearance of
-        * the adjacent tile. So, given that we can tell, 
-        * it's fair to look at the actual tile. */
-        return (is_ocean(map_get_terrain(ptile)) ? 100 : 0);
+      if(is_ocean(map_get_terrain(ptile1))) {
+        ocean++;
       } else {
-       /* We're diagonal to the tile in question. So we can't
-        * be sure what the central tile is, but the central
-        * tile is likely to be the same as the nearby tiles. 
-        * If all 4 are water, return 90; if all 4 are land, 
-        * return 10. */
-        sum += (is_ocean(map_get_terrain(ptile1)) ? 10 : -10);
+        land++;
       }
     }
   } adjc_dir_iterate_end;
 
-  return sum;
+  return 50 + (50 / map.num_valid_dirs * (ocean - land));
 }
 
 /***************************************************************
@@ -91,7 +79,7 @@
      * ie are unlikely to be ocean, the tile is likely to be coastline, so
      * likely will approach 100. If all approach 100, likely will 
      * approach zero. */
-    likely += (50 - t) / 8;
+    likely += (50 - t) / map.num_valid_dirs;
     
   } adjc_iterate_end;
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#11601) likely_ocean() cheats, Marko Lindqvist <=