Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2000:
[Freeciv-Dev] how to improve the AI's attack (was: old/bad code in autoa
Home

[Freeciv-Dev] how to improve the AI's attack (was: old/bad code in autoa

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx (Freeciv developers)
Subject: [Freeciv-Dev] how to improve the AI's attack (was: old/bad code in autoattack.c (PR#351))
From: Reinier Post <rp@xxxxxxxxxx>
Date: Tue, 2 May 2000 23:47:41 +0200

Tony Stuckey wrote:

>       The autotattack deficiencies were noted before the 1.10.0 release,
> but none of JJM, DWP, or myself have done anything about it.  (Who I think
> were the participants in the conversation)

I regret to say that I never use the city options.  Even if I knew
exactly what autoattack did I probably wouldn't want to rely on it.
The AI's attacking behaviour is *stupid*.

> > I don't know how AI selects the city to attack. I suggest
> >  
> >     - (1) Try to destroy enemy capitals.
> >     - (2) Try to take usefull wonder. ( A republic without JC cathedral is 
> >     less powerfull )

Plus, defend your own capital and wonder cities!  The AI doesn't realise
they are special, even when they are on the coast with with an enemy island
only a few tiles away.

> >     - (4) Try to build easy to defend zone. It's better to take five
> > cities on one island than one city on five islands.
 
>       AI does consider this.

Not really.  Try continuing a game with a clear winner in all-AI mode,
with the AI set to 'hard'.  You'll see that the AI will never actually
make a concerted attempt to conquer a city.  Instead, each unit will
decide by itself where to go, and whether to attack or defend.  As a
result, many different cities will be surrounded, and a constant stream
of unit attacks will happen.  Some of the obvious 'bugs', mostly
resulting from this (although I haven't actually looked at the code):

  + cities can almost always recover from attacks

When 10 AI Alpine Troops surround an enemy city, you can be sure that

  - eventually they will all attack the city
  - they will spread out the attacks over > 10 turns
  - 30 more will be behind them, defending cities the enemy can never reach

As a result, cities get the chance to recuperate, and the main damage
they suffer is occasional population loss.  It's a war of the trenches,
and much weaker enemies can often survive.  Remedy: don't make
units attack by themselves, instead run a simple planner that selects
spots/areas to attack and collects units to carry them out.

  + no bodyguards at sea

Before 1.7.2, cannons were happy to go on suicide missions to cities.
This was solved by the introduction of a 'bodyguard' notion, which
makes units with stronger defense protect units with weak defense.
But it only seems to work on land units!  The AI doesn't protect
transports at all.  The remedy: apply the bodyguard code to ships.

  + units don't recuperate in cities, but fight themselves to death

Watch the AI waste its damaged ironclads and cruisers, instead of
withdrawing them to a nearby city.  It also fortifies heavily damaged
land units right next to enemy cities, when they could just withdraw.
If the AI would learn not to waste its units, its effective attacking
force would increase by a factor 3 at least.  Remedy: consider
recuperation in cities and remaining hitpoints when deciding on a move.

  + even *empty* enemy cities are left alone

This happens all the time: when the steady drizzle of unit attacks
finally manages to empty a city, other units are often standing by,
able to capture the city, and *they stay where they are*!  The enemy
city is spared, buys a defender, eventually gets attacked again, loses
1 more population, ad nauseam.  The AI could probably do with 1/3 or
1/4 of the amount of units to capture a city, if they would all attack
in the same turn.  Remedy, I sassume: upon emptying an enemy city,
recheck units already considered to see if they can move in.

  + the AI doesn't think of buying cities of size 1 even when empty

They are destroyed instead.  This effectively wastes a free city
plus the chance to gain a free tech.  (AIs don't steal techs, either.)

  + the AI cannot conquer empires, it can only wipe them out

When an AI overpowers a big enemy civilization, the result is barren
country.  Only cities with city walls survive; the other cities are
gradually reduced to size 1, and then destroyed.  I've seen empires
of 20 cities and over, average size > 6, that after AI 'conquest'
were reduced to 2 or 3 cities of size 1 or 2.

Every city weighs in the economic scale, so destroying cities that
could be captured and secured is a serious waste.  It also deprives
units of home bases near the front line.

Against many enemies, destroying cities of a particular enemy is almost
a complete waste of effort, because the only way to justify attacks is
by making them pay for themselves in techs/cities gained.  Campaigns
to collect enemy cities can be very rewarding, especially against
underdeveloped enemies.  The AI doesn't seem to consider this,
and certainly doesn't manage to use it.

Remedy: always keep a diplomat, bodyguarded, near a small enemy city
that is likely to fall.

  + the AI doesn't buy enough attacking units

The large majority of AI military units are defenders: phalanx,
musketeers, alpines, mech infs.  It's common to see an end game with
one big AI superpower end in stalemate because it has 500 mech infs
sitting in cities and < 10 attacking units.  Remedy: a side effect
of the implementation of coordinated attacks (which will value
attacking units more).

  + the AI has no sense of 2D space

When AI cities defend, *all* cities defend equally well, even those
that are 20 tiles from the enemy borderline.  In assessing the need
for defense, a flood fill algorithm should be used to determine the
proximity of enemies, under the assumption that it will be sufficient
to defend the borders.  In assessing the direction of expansion or
conquest, the same algorithm can be used to determine defensible
borders.  And (rail)road building should be used to improve this,
rather than as a way to increase trade for cities.

If the AI stops distributing its defenders evenly across its empire,
for larger empires, its effective production power can easily double.
(Unless it learns how to use Communism, which has free military units.)

Remedy: reverse the algorithm for allocating work to units: units
shouldn't be looking for tiles to operate on, but tiles should be
competing for units to satisfy their needs.  (E.g. enemy cities,
whose 'need' it is to be attacked; mountain tops, which 'need' to
be occupied for defensive purposes; etc.)  Competition can be fairly
local, comparing the requirements of a tile to those of nearby tiles.

Most of these problems weigh as factors in its effectiveness, and some
of them multiply, so when they are remedied, I expect the AI will be
something like 10-20 times as effective in attack and conquest.  This
should satisfy anybody's need for a stronger AI.

-- 
Ramblin' Reinier



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