[Freeciv-Dev] Re: patch 3: ai passive diplomacy + alliances fixes (PR#12
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Tue, 26 Feb 2002, Per I. Mathisen wrote:
> Major changes:
> -> AI now looks at nearby allied units as potential reinforcements
This won't work. I think it will make AI behave even more stupid that it does.
It will count on the reinforcements but they will never arrive.
> -> Allied players protect each other using SDI
> -> Allied players see each others' missiles and subs
> -> Autosettlers now happily ignore allied units
> -> Allied cities are regarded as safe havens for GOTO
That's good.
> Please review and comment on the patch.
I looked at it, detected a couple of mistakes and stopped...
Will do some more careful reading later.
Sorry, I cannot persuade pine to put ">" in the attachment lines...
Best,
G.
==========================================================
[....]
diff -u4NrX freeciv/diff_ignore freeciv/ai/aiunit.c freeciv-ai/ai/aiunit.c
--- freeciv/ai/aiunit.c Tue Feb 26 15:27:06 2002
+++ freeciv-ai/ai/aiunit.c Tue Feb 26 21:57:27 2002
@@ -643,9 +643,9 @@
square_iterate(x, y, radius, x1, y1) {
struct city *pcity = map_get_city(x1, y1);
- if (pcity && pcity->owner != punit->owner
+ if (pcity && !pplayers_at_war(city_owner(pcity), unit_owner(punit))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
reversal of the original meaning??
[...]
@@ -902,12 +909,9 @@
/* No defender... */
/* ...and free foreign city waiting for us. Who would resist! */
- /* TODO: When diplomacy is implemented, don't capture enemy cities so
- * enthusiastically. -- mike, pasky */
- if (pcity && pcity->owner != pplayer->player_no
- && is_non_allied_city_tile(map_get_tile(x1, y1), pplayer)
+ if (pcity && !pplayers_at_war(pplayer, city_owner(pcity))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
reversal of the original meaning
&& is_ground_unit(punit)
&& map_get_terrain(punit->x, punit->y) != T_OCEAN) {
SET_BEST(99999);
[...]
+/*************************************************************************
+ Find safe harbour (with B_PORT). An allied player's city is just as
^^^^^^^^^^^^^
preferably with PORT
or
we are willling to go further for a PORT
+ good as one of our own, since both replenish our hitpoints and reduce
+ unhappiness.
+**************************************************************************/
static bool find_nearest_friendly_port(struct unit *punit)
{
struct player *pplayer = unit_owner(punit);
int best = 6 * THRESHOLD + 1, cur;
generate_warmap(map_get_city(punit->x, punit->y), punit);
- city_list_iterate(pplayer->cities, pcity)
- cur = warmap.seacost[pcity->x][pcity->y];
- if (city_got_building(pcity, B_PORT)) cur /= 3;
- if (cur < best) {
- punit->goto_dest_x = pcity->x;
- punit->goto_dest_y = pcity->y;
- best = cur;
+ players_iterate(aplayer) {
+ if (pplayers_allied(pplayer,aplayer)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
personally, I prefer
if (!allied) continue;
but other people disagree...
[...]
diff -u4NrX freeciv/diff_ignore freeciv/common/combat.c
freeciv-ai/common/combat.c
--- freeciv/common/combat.c Sat Feb 16 17:05:05 2002
+++ freeciv-ai/common/combat.c Tue Feb 26 19:29:29 2002
@@ -227,9 +227,9 @@
struct city *sdi_defense_close(struct player *owner, int x, int y)
{
square_iterate(x, y, 2, x1, y1) {
struct city *pcity = map_get_city(x1, y1);
- if (pcity && (city_owner(pcity) != owner)
+ if (pcity && (pplayers_allied(city_owner(pcity), owner))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
so was it a bug befroe?
&& city_got_building(pcity, B_SDI)) return pcity;
} square_iterate_end;
return NULL;
|
|