Complete.Org: Mailing Lists: Archives: freeciv-ai: February 2003:
[freeciv-ai] Re: Patch Army

[freeciv-ai] Re: Patch Army

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv ai <freeciv-ai@xxxxxxxxxxx>
Subject: [freeciv-ai] Re: Patch Army
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Sun, 16 Feb 2003 14:38:54 +0000

Quoting Jordi Negrevernis i Font <jorneg@xxxxxxxxxxx>:

>     This is an evolutioned version of the patch :-)
>     It does:
>     - coordinate naval and ground attacks.
>     - army_advisor_choose_build works. wow!!! May be the logic should be 
> improved.

I read it.  I am impressed by quantity, but not really impressed by quality.

Design could be much better.  Cycling through all army units every time you need
to know the number of units in the army is, to put it mildly, wasteful.  And the
patch is full of it.

I tested it too, in a couple of games.  When it works, it is nice. :) Most of
the time it didn't :(  There were two main problems:

1.  There was no path to the selected target, so the army would march out of
it's base and then march back in, ad infinitum.  This can be fixed rather 
by clever use of path-finding.

2.  There were not enough units willing to join the army.  However, there were
many units on the continent doing brave solitary attacks.  Also the units who
did join the armies, were split between two armies with the same target, base
and everything.

The second is the more fundamental problem.  I thought about how I would
structure the armies implementation and this would be my plan:

1. Each turn for each military unit not assigned to a task:
a) we evaluate need for defence / preventative defence in nearby cities.
b) we evaluate immediate kill opportunities (not further than one move away).
c1) we look around for armies to join and if none are there,
c2) we toy with the idea of forming a new army.
d) fallbacks (exploring, disbanding, going for a drink)

Each army has these values:
    City_Id target_id;
    int target_want;
    int target_strength;

2. Each turn for each army:
a) we recalculate our current strength and if it has exceeded the
target_strength or if target_strength has not been reevaluated for too long,
b) we search for the best target and evaluate target_strength/want
c) if even after reevaluation of target_strength our army is stronger, we set 

3. Each turn for each city
a) we ask defence_advisor (evaluates walls, defenders and prevent. defenders)
b) we ask attack_advisor (evaluates attackers/bodyguards for armies to join or
to form, if there are none)
c) we ask other advisors and choose the best option depending on our national

Hopefully this will increase modularity of the AI.  Please comment on this
general design and on how it could be split into "projects".  Then we can put
tenders on the projects ;)

Personally, I would first clean up and sort the code responsible for calling
different advisors and merging their opinions.


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