Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: flying AI (PR#1164)
Home

[Freeciv-Dev] Re: flying AI (PR#1164)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: flying AI (PR#1164)
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Fri, 28 Dec 2001 21:14:53 -0800 (PST)

There is a standard "want" pattern that has been in previous emails
but goes something like ...

Choice want is 
 < 0   an error, with a few hack-ceptions like (-199 == get_a_boat)
== 0   no want, nothing to do
<= 100 normal want
 > 100 critical want, used to requisition emergency needs
 > ??? probably an error (1024 is a reasonable upper bound)

This is sort of what I expect needs to be done with all the code you 
refer to below, but bombers is a start :-).

1) Setup an eval routine that returns a "choice" struct for build or 
any subsequent unit activity. 

2) Use the init_choice(), copy_if_better_choice() etc functions to 
collect and manage the operations you do with a choice struct in the
manage code that decides if this is preferable. The manage code is 
probably going to be buried in the current spaghetti mix as an if-clause
body after calling the eval function. 

Note: this is a crude attempt to make choices or requests an Object 
that is managed by a standard set of Object functions and not something 
you mutilate or hack at any way your private code feels like - someday, 
a manager or set of such has to understand or approve this request and 
do all the relative weighting between different requests, so asume the 
choice struct will change over time and thus don't ever create, update 
or peek at it in private code.

3) As a *last* step decide if the collected eval choices for this pass
have produced something that is *significantly* better than the currently
active choice for city building or whatever you are doing. This stops 
flipflops and gives some multi-turn memory to city and unit activities.

Note at some point, there might be a clean set of eval functions for 
all basic build or operational actions and a global way to loop over
them, i.e. build a data list of functions to call vs hardcode the
switch or trails of if-else logic that is currently the AI norm.

Also, note that there are manager and sub-manager code paths. There 
will be a global spot that calls all the domestic/military/tech/...
routines and specific ones that then do certain things with possible
sub-subs etc. It might be useful to start in server/cityturn.c at
something like advisor_choose_build() and walk the code paths down
a few trails to get a basic feel.

To pick the actual "weight" write your routine to do something sensible
to you and document it. As a last step put in a "fudge" factor that
allows you to rescale in the 0-100 or critical range.

Run games with -debug 4 turned on and look at the comparable weights
that the current activities generate. Decide whether your bombers are
more or less desired over some current action like "defend home city".
Adjust your fudge to something that seems to fit. Then rerun the test
games and see if the AI responds "appropriately". You may need to back
up and add an environmental effect to your original algorithm because
most of the time things are fine, but when <blort> is in the east and
<blooey> happens, it just does something incredibly stupid :-).

Note, the corecleanups have a lot of debug printout fixes to try and 
standardize/filter some of the worst noise so things are easier to
spot. Don't be afraid to add new ones, or do the same to existing ones
that help make the innards more systemmatically understandable.

Make sure your medical plan includes therapy.

Cheers,
RossW
=====

At 11:35 PM 01/12/28 +0000, Gregory Berkolaiko wrote:
>Hi,
>
>I am trying to make AI use bombers, but the real difficulty is to make it
>_build_ airunits.  The routines used in choosing attacking units to build
>are 
>
>kill_something_with, process_attacker_want: advmilitary.c
>find_something_to_kill : aiunit.c
>
>unfortunately these functions are among the most horrible to read and
>understand.  therefore I ask if anyone has any knowledge about the
>complicated weighting techniques to produce the choice.want etc...
>In particular, how do you think the want should be calculated for the
>bombers.
>
>Petr, Raahul, if you have any cleanup patches ready for the above
>functions, please submit them!
>
>G.
>__________________________________________________
>Do You Yahoo!?
>Everything you'll ever need on one web page
>from News and Sport to Email and Music Charts
>http://uk.my.yahoo.com





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: flying AI (PR#1164), Ross W. Wetmore <=