Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2002:
[freeciv-ai] Generalised improvements AI support

[freeciv-ai] Generalised improvements AI support

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv-ai <freeciv-ai@xxxxxxxxxxx>
Subject: [freeciv-ai] Generalised improvements AI support
From: Ben Webb <ben@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 May 2002 18:30:17 +0100

        After discussions with various Freeciv people, it seemed best to
give a quick "story so far" summary of generalised improvements for
you AI guys, as lack of support for the AI is the only major task remaining
for impr-gen. Hopefully this way we can coordinate our efforts somewhat.

        Anyhow, as I'm sure you're aware, the current Freeciv codebase
hard-codes all of the various building (or city improvement) types.
impr-gen aims to replace all of this with a general set of improvement
effects, so that the effects of buildings can be tweaked in the rulesets
without having to plough through the code, the evil "variant" field
in buildings.ruleset can be killed for good, and modpacks can be created
that use radically different sets of buildings. (For example, the code
was originally written with SMAC compatibility in mind.)

        The current impr-gen patches to Freeciv CVS can be obtained from They are currently split into 21
separate patches, for ease of code review, although a simple Perl script
is also available on the webpage to apply them in the correct order.
Also, one big patch is periodically made available, the most recent being

        Most of the existing building types now "work" with the impr-gen
code. However, I haven't touched the AI yet, so presumably it'll still
go merrily on its way with its own ideas of what each building does,
no matter how you configure your buildings.ruleset. I'm also told, however,
that a lot of the code is buggy, so I don't want to waste my time
trying to convert it to use impr-gen if it doesn't do anything useful
in the first place, or if you're planning to rewrite it soon.

More specifically:

- A lot of the functions from common/city.c seem to be duplicated in the
  AI code, e.g. pollution_benefit and ai_eval_buildings in ai/advdomestic.c.
  Is there any work underway to unify this code? impr-gen already contains
  replacements for the various functions in common/city.c, and I'd like
  to avoid perpetuating this code duplication if possible.

- I've heard that a lot of the danger code is a bit suspect. Is there
  any work ongoing in this area? For impr-gen I obviously want to get rid
  of any explicit checks for the B_CITY improvement. I want to replace
  these with checks for the Unit_Defend effect, but as this is rather more
  general (Unit_Defend encompasses City Walls, Great Wall, SDI, Coastal
  Defense) the code would require generalising at the same time.

- The current impr-gen code is largely concerned with the effects of
  improvements that exist now. With the AI, I'd imagine that a lot of
  the time you're wanting to look at the effects of improvements that
  don't exist yet (so that you can decide what to build, whether a
  unit will become vulnerable if you move to x,y, etc.). This can be
  rather CPU intensive, as you have to check for prerequisites of each
  effect. Can anybody point me towards specific chunks of AI code that
  require this kind of lookahead, so that I can look into optimising
  the impr-gen code for it? (I'm aware that the functions
  in ai/advdomestic.c don't completely duplicate common/city.c because
  they have to consider the effects of to-be-constructed buildings; I'm
  thinking of other instances, e.g. in the combat code.)

- What kinds of functions would be most useful to you? Ideally I'd like
  to keep the amount of impr-gen code in the AI to a minimum, so would
  be more interested in writing general-purpose utility functions for
  use by the AI. I guess there must be a need for functions to find
  repair facilities and/or good defensive cities for units, for a start.

- I was meaning to extract the impr-gen-AI stuff from Andi's patch, and
  update it to work with the more recent impr-gen patches, but wasn't
  very happy with some of the code in there. (In particular, it seems
  to strive too hard to reproduce the existing AI behaviour, rather
  than applying impr-gen effects "properly".) In the end, I didn't get
  round to doing this. If there's interest from the list, however,
  I should be able to produce something usable.

Comments and suggestions are appreciated...

"Jeeves shimmered out and came back with a telegram."
        - 'Jeeves Takes Charge', P. G. Wodehouse

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