[Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_de
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
--- Petr Baudis <pasky@xxxxxxxxxxx> wrote:
> Dear diary, on Mon, Feb 25, 2002 at 01:41:39PM CET, I got a letter,
> where Raahul Kumar <raahul_da_man@xxxxxxxxx> told me, that...
> > > --- advmilitary.c 22 Feb 2002 19:32:40 -0000 1.1.1.9
> > > +++ advmilitary.c 24 Feb 2002 21:36:20 -0000 1.2
> > > @@ -620,7 +620,7 @@
> > > unit_types[i].move_type == HELI_MOVING) && acity &&
> > > acity->ai.invasion == 2) b0 = f * SHIELD_WEIGHTING;
> > > else {
> > > - b0 = (b * a - (f + (acity ? acity->ai.f : 0)) * d) * g *
> > > SHIELD_WEIGHTING / (a + g * d);
> > > + b0 = kill_desire(b, a, (f + (acity ? acity->ai.f : 0)), d, g);
> > > 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);
> >
> > Kill those a,b,c,d. I think you have better names for those.
>
> I do (basically it looks that same substitution as in findvictim applies) -
> however, as I said, it won't be in this patch.
Sounds good. I'm curious about the patches you intend to send in to Freeciv
dev. How are you going to split them up ? I want to be ahead of Raimar with
insightful comments. Never easy, he seems to be reading the patches and
responding first.
>
> > > --- aiunit.c 23 Feb 2002 21:03:31 -0000 1.1.1.10
> > > +++ aiunit.c 24 Feb 2002 21:36:20 -0000 1.45
> > > @@ -616,6 +616,30 @@
> > > }
> > >
> > >
> /**************************************************************************
> > > +Compute how much we want to kill certain victim we've chosen.
> > > +
> > > +Benefit is something like 'attractiveness' of the victim, how nice it
> would
> > > be
> > > +to destroy it. Larger value, worse loss for enemy.
> > > +
> > > +Attack is the total possible attack power we can throw on the victim.
> Note
> > > that
> > > +we will even square this.
> > > +
> > > +Loss is the possible loss when we would lose the unit we want to attack.
> > > +
> > > +Vuln is vulnerability of our unit when attacking the enemy.
> > >
> +**************************************************************************/
> >
> > Victim count is the only one missing. Victim count does not count stacked
> units
> > right as far as I know.
>
> Please elaborate.
>
> I'll add description of victim count, thanks.
>
> Improved patch attached (only this changes).
>
You seem to know more about victim count than I do. If you have a specific
question, ask.
> /**************************************************************************
> +Compute how much we want to kill certain victim we've chosen.
> +
> +Benefit is something like 'attractiveness' of the victim, how nice it would
> be
> +to destroy it. Larger value, worse loss for enemy.
> +
> +Attack is the total possible attack power we can throw on the victim. Note
> that
> +we will even square this.
> +
> +Loss is the possible loss when we would lose the unit we want to attack.
> +
> +Vuln is vulnerability of our unit when attacking the enemy.
> +
> +Victim count is number of victims stacked in the target tile. FIXME?: The
> +equation is not accurate as the other values can vary for other units on the
> +target tile (we take values from best defender), however I believe it's
> +accurate just enough now and lost speed isn't worth that.
I can't tell from this comment what happens when a fortress is the target tile.
> +**************************************************************************/
> +int kill_desire(int benefit, int attack, int loss, int vuln, int
> victim_count)
> +{
> + int desire;
> +
> + /* attractiveness danger */
> + desire = ((benefit * attack - loss * vuln) * victim_count *
> SHIELD_WEIGHTING
> + / (attack + vuln * victim_count));
> +
> + return desire;
> +}
> +
Excellent.
> +/**************************************************************************
> Military "want" estimates are amortized in this complicated way.
> COMMENTME: Why not use simple amortize? -- GB
> **************************************************************************/
> @@ -805,20 +834,10 @@
> unit_owner(pdef)->name, unit_type(pdef)->name);
>
> } else {
> + /* See description of kill_desire() about this variables. */
> int vuln = unit_vulnerability(punit, pdef);
> -
> - /* The total possible attack power we can throw on the victim. Note
> - * that we will even square this. */
> int attack = reinforcements_value(punit, pdef->x, pdef->y) + bellig;
> -
> - /* Something like 'attractiveness' of the victim, how nice it would
> be
> - * to destroy it. Larger value, worse loss for enemy. */
> int benefit = unit_type(pdef)->build_cost;
> -
> - /* We're only dealing with adjacent victims here. */
> - int move_cost = 0;
> -
> - /* The possible loss when we would lose the unit we want to attack.
> */
> int loss = unit_type(punit)->build_cost;
>
> attack *= attack;
> @@ -836,15 +855,10 @@
> /* If we have non-zero belligerence... */
> if (attack > 0 && is_my_turn(punit, pdef)) {
> int desire;
> -
> - /* TODO: This equation is simplified version of much worse ones in
> - * that long fat routines, but it's still a common pattern, so we
> - * will can this equation to one separate readable function. We'll
> - * also be able to remove move_cost and loss variables. */
> -
> - /* attractiveness danger */
> - desire = ((benefit * attack - loss * vuln) * SHIELD_WEIGHTING
> - / (attack + vuln) - move_cost * SHIELD_WEIGHTING);
> +
> + /* FIXME? Why we don't use stack_size as victim_count? --pasky */
> +
> + desire = kill_desire(benefit, attack, loss, vuln, 1);
>
> /* No need to amortize! We're doing it in one-turn horizon (?). */
>
> @@ -1520,7 +1534,7 @@
> else if ((is_ground_unit(punit) || is_heli_unit(punit)) &&
> acity->ai.invasion == 2) b0 = f * SHIELD_WEIGHTING;
> else {
> - b0 = (b * a - (f + acity->ai.f) * d) * g * SHIELD_WEIGHTING / (a
> + g * d);
> + b0 = kill_desire(b, a, (f + acity->ai.f), d, g);
> if (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);
> Index: aiunit.h
> ===================================================================
> RCS file: /home/cvs/aiciv/freeciv-a2/ai/aiunit.h,v
> retrieving revision 1.1.1.4
> retrieving revision 1.7
> diff -u -r1.1.1.4 -r1.7
> --- aiunit.h 19 Feb 2002 19:33:54 -0000 1.1.1.4
> +++ aiunit.h 24 Feb 2002 21:36:21 -0000 1.7
> @@ -37,6 +37,7 @@
> int unit_vulnerability_basic(struct unit *punit, struct unit *pdef);
> int unit_vulnerability_virtual(struct unit *punit);
> int unit_vulnerability(struct unit *punit, struct unit *pdef);
> +int kill_desire(int benefit, int attack, int loss, int vuln, int
> attack_count);
> int military_amortize(int value, int delay, int build_cost);
>
> bool is_on_unit_upgrade_path(Unit_Type_id test, Unit_Type_id base);
>
Seems good to me. I vote for inclusion, Tony, Greg, Ross?
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
- [Freeciv-Dev] [PATCH] [1.1] move some common AI equations to kill_desire() (PR#1279), Petr Baudis, 2002/02/24
- [Freeciv-Dev] Re: [PATCH] [1.1] move some common AI equations to kill_desire() (PR#1279), Raimar Falke, 2002/02/24
- [Freeciv-Dev] Re: [PATCH] [1.1] move some common AI equations to kill_desire() (PR#1279), Raahul Kumar, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Petr Baudis, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279),
Raahul Kumar <=
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Petr Baudis, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Raahul Kumar, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Petr Baudis, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Raahul Kumar, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Petr Baudis, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Raimar Falke, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Petr Baudis, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Raimar Falke, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Gregory Berkolaiko, 2002/02/25
- [Freeciv-Dev] Re: [PATCH] [1.2] move some common AI equations to kill_desire() (PR#1279), Raimar Falke, 2002/02/25
|
|