Complete.Org: Mailing Lists: Archives: freeciv-ai: September 2003:
[freeciv-ai] Re: (PR#6148) Building defensive improvements
Home

[freeciv-ai] Re: (PR#6148) Building defensive improvements

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [freeciv-ai] Re: (PR#6148) Building defensive improvements
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Fri, 12 Sep 2003 09:41:21 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, 12 Sep 2003, Per I. Mathisen wrote:

> On Fri, 12 Sep 2003, Gregory Berkolaiko wrote:
> > First of all, building defensive improvement (DI) should be decided in
> > one place. Preferably in the same place which will decide on building
> > of defensive units. This will bring transperency.
> >
> > Secondly, we need a good algorithm and not a set of WAG triggers.
> 
> The problem is that we really have two different cases here:
>   - The preventive case: We want to build defences _in case_ attackers
> come our way.
>   - The emergency case: We want to build defences to protect against
> specific attackers.
> 
> In the first case, we have data collected in aidata.c to use, in the
> latter we have assess_danger()'s data. The considerdefense patch should
> give the first case more useful data to consider.
> 
> We can consider both cases in the same place, though. But the below are
> really only for the second case.

I agree.

> > This is what I concocted overnight.
> >
> > =====================================================================
> > Qualitative approach:
> > Input: Best enemy attacker (BA), best present defender (BD)
> >
> >
> > If the BD is inadequate (will lose to the BA),
> > 1. cycle through all defender types available and select those which
> > will win against the BA
> > 2. cycle through all DI available and select those, which will make the
> > BD win against the BA
> > 3. choose the cheapest among the above
> > 4. if none wereselected in 1 and 2, choose the best among them
> > 5(optional). set the tech want for the better/cheaper of yet unavailable
> > units / DIs.
> 
> This approach will make the AI worse against coordinated attacks, which is
> really bad. For single attackers, the AI should be building and using
> counterattacking units instead of defense.

On the other hand, if someone attacking with a battleship and AI is using 
quantity, it might be led to build lots of riflemen, instead of a Coastal.
The riflemen will die, although the the city will not fall.

I really think that using both is a good balance.  If there is a
coordinated attack, then first thing the AI will build a strong defender
and then it will build up numbers.  A problem might arise with the
"cheapest" in 3 (a defender will be just good enough to withstand one 
cavalry, but there are 3 outside the city).  Then we can just pass the 
shortlist from 3 to the quantity part.

Yes, I think it's a good idea.

> > =====================================================================
> >
> > Quantitative approach:
> > Input: Total strength of enemies threatening us (subdivided into
> > classes), total strength of present defenders, urgency.
> >
> > If total strength of defenders is less than the total strength of the
> > attackers:
> > 1. cycle through all defender types available and calculate thedefence
> > increase incr_d they will bring; also calculate the cost (cost_d).
> > 2. cycle through all DI available and calculate the defense increase
> > incr_i and the cost cost_i.
> > 3. Select all of the above which have their incr bigger than a given
> > threshold.
> > 4. Among the selected in 3, choose the one with the best incr/cost ratio.
> > 5. If none were selected in 3, choose the one with the biggest incr.
> > 6(optional). Set the tech wants.
> 
> We have ground units, IgWall units including helicopters, air units and
> sea units. These must be treated differently.

We also have Horse units (this I am willing to ignore though).  Why do you 
put helis together with IgWall land and not air?  Are they not affected by 
SAM?

> For preventive defense building, we need to consider these enemy unit type
> in a long range. For emergency building, we can use less range.
> 
> Also, for short-term, who is an attacker? assess_danger() merely sums up
> enemy units within a certain range. We could use the tracking code I wrote
> for the AI hunting patch to figure out if a given enemy unit is coming our
> way, in addition to summing up enemies close by.

I think summing enemies within certain range is good enough, at least for 
the start.

> Question: When should we call assess_danger()? IIRC we now call it twice,
> first before moving units then second before doing building stuff.

Not unless my patch is already in.

> However, we could just call it before building stuff and then reuse the
> data after the turn done for moving units, since the AI moves first...

I would instead shorten the range of assess_danger called before 
move_units phase, to maybe just one move.

> provided we are willing to sacrifice some AI-vs-AI intelligence (danger
> assessment of another AIs units will not be updated sometimes for the last
> turn's moves). assess_danger() is already quite CPU-heavy, and will be
> worse with new pf.

I believe proper intelligence is quite essential.  I am sure we can do 
some optimization, and the range can be quite short, about 3 moves 
(maybe more for hard).

> > ======================================================================
> >
> > I think the best would be to combine the two approaches, using
> > qualitative first and if the BD is adequate or if it gets to step 4,
> > then using the quntitative.I don't think the defense should set
> > "want", it should be overriding everything else, perhaps depending on
> > the urgency.If both BD is adequate and our total strength is better,
> > then we have no need for the defenders.
> 
> Preventive defenses should be want. We should consider building
> counterattackers instead of defenses when we are not in an emergency.

I agree.

> Also the clever human player should not be able to panic an AI into stop
> attacking by moving some units around.

If done properly, the moving-around units would be killed before too much 
is spent on the defense.

Also, if the danger is not immediate AI should consider building attackers 
instead, as you mentioned above.

G.




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