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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory.Berkolaiko@xxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#6148) Building defensive improvements
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 12 Sep 2003 06:29:23 -0700
Reply-to: rt@xxxxxxxxxxxxxx

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.

> 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.

> =====================================================================
> 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.

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.

Question: When should we call assess_danger()? IIRC we now call it twice,
first before moving units then second before doing building stuff.
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...
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 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.

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

  - Per

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