Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2004:
[freeciv-ai] Re: (PR#6567) AI has too many boats.
Home

[freeciv-ai] Re: (PR#6567) AI has too many boats.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#6567) AI has too many boats.
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 May 2004 16:25:12 -0700
Reply-to: rt@xxxxxxxxxxx

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

It looks like there's nothing to stop us from looking into cities we 
don't own.  Maybe the PF takes care of this, but can you at least add an 
assertion?

jason


Gregory Berkolaiko wrote:

> +  /* We want to consider the place we are currently in too, hence the 
> +   * do-while loop */
> +  do {
> +    struct pf_position pos;
> +    struct city *pcity;
> +
> +    pf_next_get_position(map, &pos);
> +
> +    pcity = map_get_city(pos.x, pos.y);
> +    
> +    if (pcity 
> +        && (pcity->ai.choice.need_boat 
> +            || (pcity->is_building_unit
> +             && unit_has_role(pcity->currently_building, L_FERRYBOAT)))) {
> +      bool really_needed = TRUE;
> +
> +      UNIT_LOG(LOGLEVEL_FERRY, pferry, "%s (%d, %d) looks promising, "
> +               "checking if it has other ferries already", 
> +               pcity->name, pcity->x, pcity->y);
> +      unit_list_iterate(map_get_tile(pos.x, pos.y)->units, aunit) {
> +     if (aunit != pferry && unit_owner(aunit) == unit_owner(pferry)
> +            && unit_has_role(aunit->id, L_FERRYBOAT)) {
> +
> +          UNIT_LOG(LOGLEVEL_FERRY, pferry, "%s (%d, %d) doesn't "
> +               "really want us", pcity->name, pcity->x, pcity->y);
> +       really_needed = FALSE;
> +       break;
> +     }
> +      } unit_list_iterate_end;
> +
> +      if (really_needed) {
> +        set_goto_dest(pferry, pos.x, pos.y);
> +        pf_destroy_map(map);
> +        return TRUE;
> +      }
> +    }
> +  } while (pf_next(map));
> +
> +  UNIT_LOG(LOGLEVEL_FERRY, pferry, "Ferry didn't find an interested city");
> +  pf_destroy_map(map);
> +  return FALSE;
> +}




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