[freeciv-ai] Re: AI Diplomacy v13 (PR#2413)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Fri, 1 Aug 2003, Per I. Mathisen wrote:
> A new version. I intend to commit this one, unless problems or objections.
Here are few last comments, after you implement/decline them, feel free to
commit:
1. aisupport.c:67, I propose this comment for the function
Calculate average distance to the target player.
For each their city we find the closest our city and average resulting
distances.
2. Same function (player_distance_to_player), the comment on line 84
appears malformatted.
3. advdiplomacy.c:203, unnecessary brackets.
4. line 668:
adip->love += (adip->love > 0) ? -1 : 1;
is obfuscating things: the previous line ensures that love gravitates
towards 0.
5. Finally, for greed function I propose the following code
#define NUM_BANDS 6
int band_incr[NUM_BANDS] = {5, 5, 10, 20, 30};
int band_rate[NUM_BANDS+1] = {10, 25, 50, 100, 250, 500};
int greed = 0;
int i = 0;
int n_love = -missing_love;
while(i < NUM_BANDS && n_love > 0) {
int band_love = MIN(band_incr[i], n_love);
greed += band_love * band_rate[i];
n_love -= band_incr[i];
i++;
}
if (n_love > 0) {
greed += n_love * band_rate[NUM_BANDS];
}
return (-greed);
#undef NUM_BANDS
G.
|
|