Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2004:
[freeciv-ai] Re: (PR#8777) Find ferry
Home

[freeciv-ai] Re: (PR#8777) Find ferry

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#8777) Find ferry
From: "berko@xxxxxxxxxxxxx" <berko@xxxxxxxxxxxxx>
Date: Thu, 27 May 2004 07:04:47 -0700
Reply-to: rt@xxxxxxxxxxx

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

Quoting Guest <rt-guest@xxxxxxxxxxx>:

> >+    int radius = (is_ocean(map_get_tile(pos.x, pos.y)->terrain) ? 1 : 0);
> 
> It looks like only ocean tiles are searched. Do we want to look in
> cities as well?

Unless there is a mistake in my logic, we search cities too.  Since the 
PF-search will only give us sea tiles or tiles of our continent, a special 
effort has to be taken to find ferris in cities of other continents.  The 
special effort is the square_iterate below.

> >+    if (pos.turn + pos.total_EC/PF_TURN_FACTOR > best_turns) {
> >+      /* Won't find anything better */
> >+      /* FIXME: This condition is somewhat dodgy */
> >+      break;
> >+    }
> >+    
> >+    square_iterate(pos.x, pos.y, radius, x, y) {
> >+      struct tile *ptile = map_get_tile(x, y);
> >+      
> >+      unit_list_iterate(ptile->units, aunit) {
> >+        if (is_ground_units_transport(aunit)
> >+            && (aunit->ai.passenger == FERRY_AVAILABLE
> >+                || aunit->ai.passenger == punit->id)) {
> >+          /* Turns for the unit to get to rendezvous pnt */
> >+          int u_turns = pos.turn;
> >+          /* Turns for the boat to get to the rendezvous pnt */
> >+          int f_turns = ((pos.total_EC / PF_TURN_FACTOR * 16 
> >+                          - aunit->moves_left) 
> >+                         / unit_type(aunit)->move_rate);
> >+          int turns = MAX(u_turns, f_turns);
> >+          
> >+          if (turns < best_turns) {
> >+            UNIT_LOG(LOGLEVEL_FINDFERRY, punit, 
> >+                     "Found a potential boat %s[%d](%d,%d)",
> >+                     unit_type(aunit)->name, aunit->id, aunit->x,
> aunit->y);
> >+     if (path) {
> >+       *path = pf_next_get_path(search_map);
> >+     }
> >+            best_turns = turns;
> >+            best_id = aunit->id;
> >+          }
> >+        }
> >+      } unit_list_iterate_end;
> >+    } square_iterate_end;
> >+  } pf_iterator_end;
> >+  pf_destroy_map(search_map);
> >+
> >+  return best_id;
> >+}
> 
> David Stewart
> 
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/




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