Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2002:
[freeciv-ai] Re: (PR#2633) ai_military_attack() bug#1
Home

[freeciv-ai] Re: (PR#2633) ai_military_attack() bug#1

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#2633) ai_military_attack() bug#1
From: "Gregory Berkolaiko via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 24 Dec 2002 15:19:23 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Quoting "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>:

> 
> On Tue, 24 Dec 2002, Gregory Berkolaiko via RT wrote:
> > The condition was fine!It was
> >     could_unit_move_to_tile(punit, dest_x, dest_y) == 0
> > which reads "could NOT move to tile".
> >
> > (Or maybe it could not move because there is enemy there?).
> >
> > Anyway, I committed it but then reverted it.This piece of code is very
> > confusing, so you really need to explain to me what is happening and what
> > should be happening.
> 
> Ugh. Yes. Sorry. I got it right the first time (when I wrote this code),
> and I definitely should have documented it better.

I looked at the code some more and came to the conclusion that this line doesn't
belong there at all.  At best it is redundant (for example we-are-on-the-ferry
case is detected by can_unit_attack_), but I think it's plain wrong.  If there
is an enemy there, could_unit_move will return 0.  But there should be an enemy
-- that's why fstk selected it!

And also the idea of repeating twice.  Well suppose we killed the enemy the
first time, then (if the code was right which it isn't) it would push us to
occupy the spot.  But this could be dangerous and also we could be doing
something useful instead.

Also, it wouldn't hurt to check for moves left before calling fstk.  Remeber,
fstk generates warmap.

I did not commit anything to the S1_14 because when I looked at it I realised we
are doing something wrong.  I guess it wouldn't hurt, but would be no use too. 
The only time ai_unit_attack is called is when there are no enemies left there
(or an empty city) so no danger of death.

G.

P.S. On a completely different issue.  
aidata.h line 40:
  static struct ai_data aidata[MAX_NUM_PLAYERS * MAX_NUM_BARBARIANS];
Should it not be "+" instead of "*"?




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