Complete.Org: Mailing Lists: Archives: freeciv-ai: March 2003:
[freeciv-ai] (PR#3573)
Home

[freeciv-ai] (PR#3573)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [freeciv-ai] (PR#3573)
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Sat, 1 Mar 2003 15:48:49 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Function find_beachhead is returning and int but might as well return
bool, for clarity.  The return type istherefore changed, the function is
documented, an oddity is highlighted.

G.
? mmm.gz
? saves
? common/aicore/path_finding.c
? common/aicore/path_finding.h
? common/aicore/pf_tools.c
? common/aicore/pf_tools.h
Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.137
diff -u -r1.137 advmilitary.c
--- ai/advmilitary.c    2003/02/10 21:43:40     1.137
+++ ai/advmilitary.c    2003/03/01 22:39:09
@@ -327,7 +327,7 @@
   if (distance < SINGLE_MOVE) distance = SINGLE_MOVE;
 
   if (is_ground_unit(punit) && boatid != 0
-      && find_beachhead(punit, pcity->x, pcity->y, &x, &y) != 0) {
+      && find_beachhead(punit, pcity->x, pcity->y, &x, &y)) {
     /* Sea travellers. */
 
     y = WARMAP_SEACOST(punit->x, punit->y);
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.267
diff -u -r1.267 aiunit.c
--- ai/aiunit.c 2003/02/27 22:28:41     1.267
+++ ai/aiunit.c 2003/03/01 22:39:12
@@ -1225,9 +1225,12 @@
 }
 
 /*************************************************************************
-...
+  Tries to find a land tile adjacent to water and to our target 
+  (dest_x, dest_y).  Prefers tiles which are more defensible and/or
+  where we will have moves left.
+  FIXME: It checks if the ocean tile is in our Zone of Control?!
 **************************************************************************/
-int find_beachhead(struct unit *punit, int dest_x, int dest_y, int *x, int *y)
+bool find_beachhead(struct unit *punit, int dest_x, int dest_y, int *x, int *y)
 {
   int ok, best = 0;
   enum tile_terrain_type t;
@@ -1270,7 +1273,7 @@
     }
   } adjc_iterate_end;
 
-  return best;
+  return (best > 0);
 }
 
 /**************************************************************************
@@ -1374,7 +1377,7 @@
         ferryboat->ai.passenger = punit->id;
 /* the code that worked for settlers wasn't good for piles of cannons */
         if (find_beachhead(punit, dest_x, dest_y, &ferryboat->goto_dest_x,
-               &ferryboat->goto_dest_y) != 0) {
+               &ferryboat->goto_dest_y)) {
           punit->goto_dest_x = dest_x;
           punit->goto_dest_y = dest_y;
           handle_unit_activity_request(punit, ACTIVITY_SENTRY);
@@ -2120,7 +2123,7 @@
            * to the city and an available ocean tile */
           int xx, yy;
 
-          if (find_beachhead(punit, acity->x, acity->y, &xx, &yy) != 0) { 
+          if (find_beachhead(punit, acity->x, acity->y, &xx, &yy)) { 
             best = want;
             *x = acity->x;
             *y = acity->y;
@@ -2350,7 +2353,7 @@
         ai_military_gothere(pplayer, punit, pc->x, pc->y);
       } else {
         /* sometimes find_beachhead is not enough */
-        if (find_beachhead(punit, pc->x, pc->y, &fx, &fy) == 0) {
+        if (!find_beachhead(punit, pc->x, pc->y, &fx, &fy)) {
           find_city_beach(pc, punit, &fx, &fy);
           freelog(LOG_DEBUG, "Barbarian sailing to city");
           ai_military_gothere(pplayer, punit, fx, fy);
Index: ai/aiunit.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.h,v
retrieving revision 1.41
diff -u -r1.41 aiunit.h
--- ai/aiunit.h 2003/01/12 22:36:24     1.41
+++ ai/aiunit.h 2003/03/01 22:39:12
@@ -58,7 +58,8 @@
                         Unit_Type_id enemy_type);
 int find_something_to_kill(struct player *pplayer, struct unit *punit, 
                             int *x, int *y);
-int find_beachhead(struct unit *punit, int dest_x, int dest_y, int *x, int *y);
+bool find_beachhead(struct unit *punit, int dest_x, int dest_y, 
+                    int *x, int *y);
 
 int build_cost_balanced(Unit_Type_id type);
 int base_unit_belligerence_primitive(Unit_Type_id type, bool veteran,

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] (PR#3573), Gregory Berkolaiko <=