Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2004:
[freeciv-ai] Re: Inprovements in settler.c

[freeciv-ai] Re: Inprovements in settler.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jordi Negrevernis i Font <jorneg@xxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: Inprovements in settler.c
From: Per Inge Mathisen <per@xxxxxxxxxxx>
Date: Thu, 12 Aug 2004 17:21:47 +0000 (GMT)

On Thu, 12 Aug 2004, Jordi Negrevernis i Font wrote:
>   Hi, i'm trying to improve the settler code by using the bodyguards
> with settlers, etc...


>   This the first attempt, and can be greatly improved.

Yes. I am not sure if I understand it. You use enemies_at() to figure out
if there are enemies at the place we are going to (or where we are), and
then request bodyguards. So far, so good. However, then you have another
check using enemies_at(), and if we found enemies now, we don't go. So why
did we acquire a bodyguard, if we aren't going anyway?

>   While looking at the code i see that you use code like this:
> if (punit->ai.charge != BODYGUARD_NONE) { /* I am a bodyguard */
>   Why you don't check to see if its equal to BODYGUARD_WANTED, or just
> check for a value > 0.

Checks that see if we are a bodyguard should check punit->ai.charge >

+  /* If we carried a bodyguard just use it!.
+   *  Its the new defender of the city */
+  if (bodyguard > 0) {
+    if (pbody) {
+      if (ai_unit_make_homecity(pbody, pcity)) {
+       ai_unit_new_role(pbody, AIUNIT_ESCORT, -1, -1);
+      }
+    }
+  }

The first check is unnecessary. Also, you might want to check if the city
has enough shield surplus at this point to upkeep the unit.

  - Per

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