Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: RFC: Fixing movement code

[Freeciv-Dev] Re: RFC: Fixing movement code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Petr Baudis <pasky@xxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: RFC: Fixing movement code
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Fri, 23 Nov 2001 05:54:32 -0800 (PST)

--- Petr Baudis <pasky@xxxxxxxxxxx> wrote:

> > What bonus? Where does this come from? What exactly is this bonus, what
> effects
> > it etc? All I can see is that if an enemy unit is in a city this bonus
> applies.
> > Bizarre. What the hell does build-cost have to do with bonuses?
> Basic bonus is 'price' of the victim (build_cost), how valuable it is. In the
> city, we increase the bonus by 40, and modified by the health of our unit
> (* punit->hp / unit_type(punit)->hp). I don't get why it is corrected by the
> health of our unit only in the city, that looks very misterious.. I would
> think
> it would be more correct to do this everytime, i think i will try that and
> run
> some tests..

I agree. In fact, would it not be a smarter thing to use the function(I forget
the name) that calculates the odds of winning a battle instead of all these
complex hard to figure out calcs.
> In the coeficient, bonus is used in the numerator, multiplied by agressivity,
> so it looks it is something as 'appetency' of the victim, how nice it would
> be
> to destroy. Larger price, enemy will have worse loss. If it is in the city,
> loss will be even worse. And as I think about it now... it looks that we
> correct
> it with our health because there may be more units in the city stacked, and
> we
> won't destroy them all, so in the next turn they may attack us. So we
> shouldn't
> do this with injured units. Obviously, to be more precise, we should check
> for
> that everytime, however that would be too expensive.

You sure? I'm not convinced it would be too expensive.
> >  
> > > c is zero everytime, no other assigment, so we can safely remove it imho.
> > >
> > 
> > Maybe, maybe not. c is used in other ai functions.
> Removed c and the assigment and it compiles fine for me. It really looks this
> function was originally just copy of an older one, who knows.. However 'c'
> looks like purely historical thing.

c is used in numerous ai funcs. I just like to be absolutely sure of the ai
code. Make one small change and it snowballs into an avalanche.
> > > a is most misterious. however, after some study of code, it seems to me
> it
> > > is kinda 'aggressivity'. in the mind comes that we can pre-compute
> > > something before, so it will speed things a bit.
> > >
> > 
> > Can you define aggressivity? We need some comments.
> It is like the contrary to vulnerability, that is clear after look at coef.
> It is computed from belligerence (which is real vulnerability contrary), and
> we add value of possibly reinforcements which may come to it. And at last
> we make a square of it. So it is the ability of destroying the enemy, the
> morale of soldiers there ;-).

I'll make the above into a comment.
> Looking at the formula more carefully...
>             coef = ((bonus * agress - unit_type(punit)->build_cost * vuln) *
>                     (agress + vuln) * SHIELD_WEIGHTING);
> This looks to me as it is broken:
>         (appetency - danger) * S_W
> coef = ---------------------------- * S_W
>               agress + vuln                    <- i don't get that too :-)
> that means, we do SHIELD_WEIGHTING^2 in practice. Not sure, if that is
> correct,
> as I have not very clear idea, how exactly S_W is used, however if it is
> correct,
> we should make the formula more clear anyway, like:
>             coef = ((bonus * agress - unit_type(punit)->build_cost * vuln) /
>                     (agress + vuln) * SHIELD_WEIGHTING * SHIELD_WEIGHTING);

I like the first way.
> or, if it is meant in another way, like:
>             coef = ((bonus * agress - unit_type(punit)->build_cost * vuln) *
>                     (SHIELD_WEIGHTING / (agress + vuln)) * SHIELD_WEIGHTING);
> note that this three formulas are mathematically equivalent.
> >                                                     You seem to understand
> > this code suspiciously well. Are you one of the original ai writers?
> Nope, i just have read the code. well, the first code in freeciv i'm looking
> in
> more carefully at all ;-).
> ..snip..
> > >           /* arguable that I should use reinforcement_cost here?? --
> Syela */
> > >           if (a && is_my_turn(punit, pdef)) {
>            if (agress && is_my_turn(punit, pdef)) {
> sorry :)
> > Petr Baudis Email pasky@xxxxxxxxxxx
> > 
> > Changed  ai_military_find_victim
> yup, only rather pasky@xxxxx, please, thanks.. :)- 

Ok. Do you want to write the blurb for your changes? 

Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

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