Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: flying AI (PR#1162)
Home

[Freeciv-Dev] Re: flying AI (PR#1162)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: flying AI (PR#1162)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Sat, 29 Dec 2001 10:50:32 +0100

Dear diary, on Sat, Dec 29, 2001 at 07:40:18AM CET, I got a letter,
where Raahul Kumar <raahul_da_man@xxxxxxxxx> told me, that...
> Some additional titbits for you. Hope this makes the function clearer.
> I strongly suspect you want me to explain the 
> 
> else b0 = ((b * a - f * d) * SHIELD_WEIGHTING / (a + d)) - 
> 1412 c * (unhap ? SHIELD_WEIGHTING + 2 * TRADE_WEIGHTING : SHIELD_WEIGHTING);
> 
> Sorry. I'm still trying to figure out the behaviour of amortise myself.
> Will send in  a patch sometime next century when I figure out what the
> hell Syela was thinking. Basic summary of amortise - we figure out what
> the effect of unhappiness will be from building this unit, affect on 
> trade(only
> matters for caravans/freights), the shield weighting( to prevent cities
> building
> one more unit that exhausts all shields). Unfortunately, the devil is in the
> details. 

I didn't find that line anywhere, however Syela use very similiar formulas
here. So let's have a look at a bit different version of this ;-).

First, original version, so that we can find similiarity with the above:

      else {
        b0 = (b * a - (f + (acity ? acity->ai.f : 0)) * d) * g * 
SHIELD_WEIGHTING / (a + g * d);
        if (acity && b * acity->ai.a * acity->ai.a > acity->ai.f * d)
          b0 -= (b * acity->ai.a * acity->ai.a - acity->ai.f * d) *
                           g * SHIELD_WEIGHTING / (acity->ai.a * acity->ai.a + 
g * d);
      }
      if (b0 > 0) {
        b0 -= l * SHIELD_WEIGHTING;
        b0 -= c * (unhap ? SHIELD_WEIGHTING + 2 * TRADE_WEIGHTING : 
SHIELD_WEIGHTING);
      }

and a bit more coder-friendly version:

      } else {
        desire = (value * attack - (build_cost + (acity ? acity->ai.f : 0)) * 
resist) * protect * SHIELD_WEIGHTING /
                 (attack + protect * resist);

        if (acity && value * acity->ai.a * acity->ai.a > acity->ai.f * resist)
          desire -= (value * acity->ai.a * acity->ai.a - acity->ai.f * resist) *
                    protect * SHIELD_WEIGHTING / (acity->ai.a * acity->ai.a + 
protect * resist);
      }

      if (desire > 0) {
        desire -= tech_cost * SHIELD_WEIGHTING;
        desire -= move_cost * (unhap ? SHIELD_WEIGHTING + 2 * TRADE_WEIGHTING : 
SHIELD_WEIGHTING);
      }

Sorry, but I've currently no time to explain this more, as I must go outdoors
now ;p. However you are welcome to have a look at CVS to see how are these
values initialized (so what they mean), send me some comments patches etc ;-).

-- 

                                Petr "Pasky" Baudis

UN*X programmer, UN*X administrator, hobbies = IPv6, IRC, FreeCiv, (e)links
.
Firewall in a way is like the doorkeeper of a local pub. If you don't have your
I.D. on you, or if for some reason you do not qualify to enter, the doorkeeper
will not permit you to enter. In some extreme cases these doorkeepers will not
let you out, or at least give you a hard time before they finally let you out.
.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/


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