Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: Another application for kill_desire equation. (PR#1325
Home

[Freeciv-Dev] Re: Another application for kill_desire equation. (PR#1325

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Petr Baudis <pasky@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, <bugs@xxxxxxxxxxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Another application for kill_desire equation. (PR#1325)
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Wed, 13 Mar 2002 15:14:17 +0000 (GMT)

On Wed, 13 Mar 2002, Petr Baudis wrote:

> Dear diary, on Wed, Mar 13, 2002 at 01:45:24PM CET, I got a letter,
> where Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx> told me, that...
> > --- ai/aiunit.c     2002/03/13 11:49:19     1.187
> > +++ ai/aiunit.c     2002/03/13 12:24:45
> > @@ -1698,8 +1698,15 @@
> >            c = (n + m - 1) / m;
> >            if (!is_ground_unit(punit) && d == 0) b0 = 0;
> >            else if (c > THRESHOLD) b0 = 0;
> > -          else b0 = ((b * a - f * d) * SHIELD_WEIGHTING / (a + d)) - 
> > -            c * (unhap ? SHIELD_WEIGHTING + 2 * TRADE_WEIGHTING : 
> > SHIELD_WEIGHTING);
> > +          else {
> > +       b0 = kill_desire(b, a, f, d, 1);
> > +       /* Take into account maintainance of the unit */
> > +       /* FIXME: Depends on the government */
> > +       b0 -= c * SHIELD_WEIGHTING;
> > +       /* Take into account unhappiness 
> > +        * (costs 2 luxuries to compensate) */
> > +       b0 -= (unhap ? 2 * c * TRADE_WEIGHTING : 0);
> 
> We don't need to use ternary operator. I'm also dreaming (obviously in some
> other patch) about special function like assess_unhappiness(unhap, c), which
> would unify all those unhappy checks, as there's a lot of them around all the
> code.

Ternary operator (1) is in the original code and (2) I prefer it to 
the three line if construct:
if (unhap) {
  b0 -= 2 * c * TRADE;
}
which is just a waste of spce.

I agree with you completely on the assess_unhappiness(punit, c) function 
(note the different args).  unhap, as it is now, is broken, as it will not 
take into account the unhappiness created when the unit leaves the city it 
is in now...  But that's a different patch definitely.

> > +     }
> >            e = military_amortize(b0, MAX(1, c), fprime);
> >            if (e > best && ai_fuzzy(pplayer, TRUE)) {
> >  #ifdef DEBUG
> 
> It looks ok otherwise (aside the fact that you use tabs ;).

maybe I'll hack emacs C mode... :(



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