Complete.Org: Mailing Lists: Archives: freeciv-ai: August 2002:
[freeciv-ai] Re: ai_military_attack()

[freeciv-ai] Re: ai_military_attack()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: ai_military_attack()
From: Jordi Negrevernis i Font <jorneg@xxxxxxxxxxx>
Date: Tue, 27 Aug 2002 20:36:33 +0200

Per I. Mathisen wrote:

On Mon, 26 Aug 2002, Jordi Negrevernis i Font wrote:

+static struct unit *ai_military_rampage(struct unit *punit, int threshold)
+int x, y, id = punit->id;
+while (punit && punit->moves_left
+       && ai_military_findvictim(punit, &x, &y) >= threshold) {
+  ai_unit_attack(punit, x, y);
+  punit = find_unit_by_id(id);
+return punit;

 Be aware that this code does not check to see if the coordinates
returned by ai_military_findvictim are the same as the unit ones. You
shouldhave to check that they are diferent or i'll have an assert in

As far as I am aware, that should not happen. findvictim should only
return a positive value if it found something to attack _and_ has set
&x, &y to an adjacent tile... am I mistaken?

Sometimes ai_military_findvictim returns a high value and the dest_x & dest_y equal to punit->x & punit->y. I suppose that this is a bad behaviour of findvictim because it can lead to crashes all around the ai.

But i'm sure that it happens because I was getting asserts with the recovery_hp patch and was for this.


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