Complete.Org: Mailing Lists: Archives: freeciv-ai: January 2005:
[freeciv-ai] Re: [Freeciv-Dev] (PR#11777) Cleanup of AI tech code

[freeciv-ai] Re: [Freeciv-Dev] (PR#11777) Cleanup of AI tech code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [freeciv-ai] Re: [Freeciv-Dev] (PR#11777) Cleanup of AI tech code
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Mon, 3 Jan 2005 16:22:40 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: >

Ha, I wanted to do something to clen up tech code but you beat me to it.
I will tell you my plans though.

I wanted to hide most of tech-want bumping into aitech.c, providing
functions like

aitech_want_unit(struct city *, UnitTypeId, TechWantLevel, want)
aitech_want_unit_flag(struct city *, UnitFlag, TechWantLevel, want)

city is passed for debug printout and also to determine whether it's one
city which wants the unit or the whole nation (in which case the want is
multiplied by num_cities).

will bump by some preset want.  For example if enemy is sending diplomats
to attack us, TW_CRITICAL is called for.  For MapMaking, you would use
TW_CRITICAL if on a small island and TW_IMPORTANT otherwise.

want is used only if level is TW_USERDEFINED.

This incapsulation will make log messages more consistent, will enable us
to change tech-want in a more continuous fashion (using want from previous
turn, similar to what we do to love, for example).  In some cases it might
lead to duplicate code though so a good review of the places where tech
want is bumped is needed.  But you are now in a good position to do so! ;)

On Mon, 3 Jan 2005, Per I. Mathisen wrote:

> I was just looking to fix a bug, and got a bit carried away...
> This patch:
>  - Removes some essentially dead and useless, and probably buggy (with
> team research) AI tech code.
>  - Improves logging of AI tech want. Renamed PLAYER_LOG to DIPLO_LOG for
> consistency. New /debug command "/debug tech". Renamed "/debug player" to
> "/debug diplomacy".

this can be done in a separate patch (and committed without much review).

>  - Fixes diplomacy buglet that would use negative tech want to calculate
> want for tech in exchanges (if present).
>  - Fixes possible crash in aisettler.c if ruleset has no ferries and in
> aidiplomat.c if ruleset has no diplomats.
>  - Fixes increase of tech want when considering role units. Previously we
> bumped tech want for every role unit in the unit list when we don't find
> any to produce, now we just do it for cheapest to research of the next
> ones up the list from the one we can (or cannot) produce. Halve the want
> if we can produce any role unit of this kind. This helps reduce the
> explosive want for Explosives, for default ruleset.
>  - Fixes possible issue where tech want would be _reduced_ if there is a
> govt that is second best but less good than the one we already have. (Yes,
> this is bad, because the tech might be good for other reasons.)
>  - Ensure that the minimum tech want bump is 100, so that early game tech
> want (few cities) is forward-looking. Remove govt_hint system in favour of
> a built-in bump that is more intelligent. This may be derailed by
> excessive attack want in some cases, so definitely only cvs head material,
> but is arguably more correct and more flexible.
>  - Since tech want is never cleared (just keeps accumulating) we cannot
> use this in diplomacy code as is, so I made it divide the tech want by the
> number of game turns. This fix should be back-ported to 2.0. (The constant
> accumulation means that rapid flip-flops do not occur, which is good, as
> changing tech has a penalty. Perhaps we should do the same for buildings?)
>  - AI is no longer used to suggest new tech goals for human players. I saw
> no reason to keep this, and it was rather ugly and rather prone to failure
> to find anything in any case.
> Unsolved issues (not to be fixed in this patch):
>  - The attack and defense code bump want for _every_ useful unit, even
> units that are strictly inferior and are and will never actually be used.
>  - Several parts of the code do not bump tech want (hunter, ferry, air,
> explorer and diplomacy) and some do it without proper want (settler and
> diplomats).

Sometimes "proper want" is hard to calculate (especially since there is no
absolute scale), this is why I want these TW_ levels.

>  - Govt hints and nation ruleset hints are no longer used, with this
> patch, and should be removed.


> Questions:
>  - Why does Republic have Code of Laws as one prereq? It has Literacy as
> its other prereq, and Literacy requires Code of Laws...
>  - The algorithm for bumping defense units' tech want is really weird.
> See comments in patch. Why is it written like this?

I will read you patch and give you more feedback, but it might come

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