Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2002:
[freeciv-ai] Re: settlers.c question
Home

[freeciv-ai] Re: settlers.c question

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: settlers.c question
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 9 Dec 2002 21:59:37 +0000 (GMT)

On Wed, 4 Dec 2002, Ross W. Wetmore wrote:
> This is what I worked out once upon a time for the corecleanups.
...
> Certainly is_non_allied_unit_tile() doesn't capture all the subtleties
> this code has built into it. I also think you have only begun to scratch
> the surface and need to scratch a little harder to work things out in
> their full glory.

I don't think so. I see no glory, I see only one big unholy mess.

> /* Settlers can help current operation, treat as unassigned */
> if (same_pos(myunit->x, myunit->y, x, y)) {
>   if (unit_flag(myunit, F_SETTLERS))
>     return FALSE;
> }

Fair enough. Easy little check that might be added. But _only for terrain
improvements_ and not also for city creation, as you have it.

I've added this to my patch, see new one attached. (Not tested.)

> else
> if (myunit->activity == ACTIVITY_GOTO
>   && same_pos(myunit->goto_dest_x, myunit->goto_dest_y, x, y)) {
>   bool is_military = is_military_unit(myunit);
>   bool is_settlers = unit_flag(myunit, F_SETTLERS);
>   unit_list_iterate(map_get_tile(x, y)->units, punit)
>     /* non-military assignments are off if currently enemy occupied
>      *   or being actively worked by an allied settler */
>     if (!is_military)
>       if (!pplayers_allied(unit_owner(punit), pplayer)
>         || (is_settlers && unit_flag(punit, F_SETTLERS)) )
>         return TRUE;

What is this talk about military assignments? Aren't we evaluating settler
assignments here?

Without the military check, which makes no sense, this achieves the same
as a call to is_non_allied_unit_tile(), only with a lot more code, and we
don't check for the case where we contemplate building a settler to
improve this position (why contemplate improving a position held by the
enemy?).

In short, is_non_allied_unit_tile() is better.

  - Per

Attachment: settlersc4.diff
Description: Text document


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