Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)
Home

[Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Cache win_chance in get_defender(attacker) (PR#1269)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 22 Feb 2002 23:00:45 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Feb 22, 2002 at 09:22:45PM +0000, Gregory Berkolaiko wrote:
>  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> > On Fri, Feb 22, 2002 at 08:33:18PM +0000, Gregory Berkolaiko wrote:
> > >  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> > > 
> [...]
> > > you asked whether win_chance can be used in findvictim
> > > the answer is yes and it should be used but you can call win_chance or
> > > get it from get_attacker or get_defender which would've computed it by
> > now.
> > 
> > I just want that we thing about a good interface before we add some
> > non-straightforward way to get an intermediate result for speed.
> > 
> > What about a function 
> >   double win_chance_against_stack_at_tile(punit, target_x, target_y)
> > ? This function would built on top of win_chance. This is IMHO also
> > what we try here to approximate: unit against stack.
> 
> well, this would either repeat most of get_defender
> or indeed call get_defender and then call win_chance which is precisely what I
> am trying to avoid.

No it would be the "real thing" ;) Even in the server the attacking of
a tile isn't encapsulated in a single function but spread in
handle_unit_attack_request and handle_unit_move_request (which call
them recursive). I would want that this function really simulates
unit-vs-stack. There could a flag which only considers the first unit
from a stack.

To be honest I'm looking into the future and consider how to implement
agents which perform military actions. And what I see in the current
AI code doesn't make me happy. There are similar functions which are
"simple", "total", "virtual" and which return "power" or a
"rating". If I will do a miliary agent I'm sure to try to avoid very
hard.

Based on my current knowledge I would say there are at least the
following cases:
 - real unit vs a real tile (a unit considers attacking a tile, the
 tile don't need to be adjacent)
 - virtual unit vs real tile (a city considers building/buying a unit
 and want to know how good this will be against the current enemy
 units in sight)
 - real tile with a virtual unit vs the surrounding area (the agents
 searches the savest place for a unit)

There may be other cases. The function for each case have to answer:
 - how are my chances of success
 - what happens if I win (which units gets destroys, city captured)
 - what happens if I loose (which units gets destroys, city captured)

IMHO the best and most flexible solution would be to design a
combat_unit struct which holds the necessary information of a unit for
the combat and use two lists of such pseudo units for simulation. So I
would design something like:
 result_list = simulate(struct combat_unit *attacker_list,
                        int attacker_x, int attacker_y,
                        struct combat_unit *defender_list,
                        int defender_x, int defender_y);

and result_list would contain entries like:
 chance=0.90, destroyed_attackers=[], destroyed_defenders=[combat_unit_1]
 chance=0.12, destroyed_attackers=[combat_unit_2], 
destroyed_defenders=[combat_unit_1]

Such detailed analyses is needed IMHO because it may happen that
value(combat_unit_2) >> value(combat_unit_1). So that a chance of 12%
for destroying a mech. inf. (combat_unit_2) with your archer
(combat_unit_1) is very good.

> So sorry, I still think my version is most flexible and short.

For the case of ai_military_findvictim. But there are others.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Only one human captain has ever survived battle with the Minbari
  fleet. He is behind me. You are in front of me. If you value your 
  lives, be somewhere else."
    -- Ambassador Delenn, "Severed Dreams," Babylon 5


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