[freeciv-ai] Re: active ai diplomats
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, 2 Sep 2002, Per I. Mathisen wrote:
> On Sun, 1 Sep 2002, Gregory Berkolaiko wrote:
> > > This is a possibility, and better since it evaluates military benefits,
> > > which is what really should be doing, but it sounds rather complex. Can
> > > you show me in pseudocode how youwould accomplish this?
> > unit_type_id att = find_best_attacker_for(acity);
> > int loss = estimate_casualties_when_sieging(acity, att);
> > loss *= 2 * unit_types[att].build_cost;
> > incite_desire = loss * SHIELD_WEIGHTING - incite_cost * TRADE_WEIGHTING;
> Not bad, not bad. I like that.
> However, I am planning to commit the active diplomat patch very soon
> nevertheless, with my much simpler calculation, since having too many big
> open AI patches slows down the cleanup work too much.
You are right. I've had a nightmare of a time updating flying AI patch
because some of my own cleanup patches were conflicting badly with the
As for the incite_gain, please write a good explanatory comment for it (or
just say "it combines all relevant factors and seems to work so what the
hell"). In my experience these are the places where future maintainers
can get stuck, thinking "what the hell did they mean by it" whereas in
reality noone meant anything...
My main grudge against it is that it multiplies all
income by corresponding *_WEIGHTING but does not multiply
incite_revolt_cost by TRADE_WEIGHTING. Also the extra multiplication
gain_incite *= SHIELD_WEIGHTING; /* cost to take city otherwise */
seems a little misplaced.
I still think
+ /* City's contribution to our economy in one turn */
+ gain_incite = acity->food_prod * FOOD_WEIGHTING
+ + acity->shield_prod * SHIELD_WEIGHTING
+ + (acity->luxury_total
+ + acity->tax_total
+ + acity->science_total) * TRADE_WEIGHTING;
+ /* Total future contribution */
+ gain_incite *= MORT;
+ /* Minus what we fork out now */
+ gain_incite -= acity->incite_revolt_cost * TRADE_WEIGHTING;
will produce largely the same results and is sligtly more justifyable.
> Can you make a patch implementing the above against cvs after I have
> committed it?
We will see...