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: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Another application for kill_desire equation. (PR#1325)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Wed, 13 Mar 2002 16:03:44 +0100

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.

> +       }
>            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 ;).

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
"If you have acquired knowledge, what do you lack?
    If you lack knowledge, what have you acquired?"
Lev. R. 1:6
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


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