Index: ai/aidata.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aidata.h,v retrieving revision 1.14 diff -u -r1.14 aidata.h --- ai/aidata.h 30 Jul 2004 20:40:49 -0000 1.14 +++ ai/aidata.h 16 Aug 2004 16:41:32 -0000 @@ -72,7 +72,7 @@ struct { bool invasions; /* check if we need to consider invasions */ bool *continent; /* non-allied cities on continent? */ - bool sea; /* check if exists non-allied offensive ships */ + bool *ocean; /* non-allied offensive ships in ocean? */ bool air; /* check for non-allied offensive aircraft */ bool missile; /* check for non-allied missiles */ int nuclear; /* nuke check: 0=no, 1=capability, 2=built */ @@ -80,6 +80,7 @@ /* Keeps track of which continents are fully explored already */ struct { + bool *ocean; /* are we done exploring this ocean? */ bool *continent; /* are we done exploring this continent? */ bool land_done; /* nothing more on land to explore anywhere */ bool sea_done; /* nothing more to explore at sea */ @@ -98,6 +99,7 @@ } stats; int num_continents; /* last time we updated our continent data */ + int num_oceans; /* last time we updated our continent data */ /* Dynamic weights used in addition to Syela's hardcoded weights */ int shield_priority; Index: ai/aidata.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aidata.c,v retrieving revision 1.31 diff -u -r1.31 aidata.c --- ai/aidata.c 13 Aug 2004 15:59:11 -0000 1.31 +++ ai/aidata.c 16 Aug 2004 16:41:32 -0000 @@ -60,21 +60,18 @@ struct ai_data *ai = &aidata[pplayer->player_no]; int i, nuke_units = num_role_units(F_NUCLEAR); bool danger_of_nukes = FALSE; - bool can_build_antisea = can_player_build_improvement(pplayer, B_COASTAL); - bool can_build_antiair = can_player_build_improvement(pplayer, B_SAM); - bool can_build_antinuke = can_player_build_improvement(pplayer, B_SDI); - bool can_build_antimissile = can_player_build_improvement(pplayer, B_SDI); int ally_strength = -1; struct player *ally_strongest = NULL; /*** Threats ***/ - ai->num_continents = map.num_continents; + ai->num_continents = map.num_continents; + ai->num_oceans = map.num_oceans; ai->threats.continent = fc_calloc(ai->num_continents + 1, sizeof(bool)); ai->threats.invasions = FALSE; ai->threats.air = FALSE; ai->threats.nuclear = 0; /* none */ - ai->threats.sea = FALSE; + ai->threats.ocean = fc_calloc(ai->num_oceans + 1, sizeof(bool)); players_iterate(aplayer) { if (!is_player_dangerous(pplayer, aplayer)) { @@ -94,44 +91,36 @@ if (is_sailing_unit(punit)) { /* If the enemy has not started sailing yet, or we have total * control over the seas, don't worry, keep attacking. */ - if (!ai->threats.invasions && is_ground_units_transport(punit)) { + if (is_ground_units_transport(punit)) { ai->threats.invasions = TRUE; } /* The idea is that while our enemies don't have any offensive * seaborne units, we don't have to worry. Go on the offensive! */ - if (can_build_antisea && unit_type(punit)->attack_strength > 1) { - ai->threats.sea = TRUE; + if (unit_type(punit)->attack_strength > 1) { + Continent_id continent = map_get_continent(punit->x, punit->y); + ai->threats.ocean[continent] = TRUE; } + continue; } /* The next idea is that if our enemies don't have any offensive * airborne units, we don't have to worry. Go on the offensive! */ - if (can_build_antiair && (is_air_unit(punit) || is_heli_unit(punit)) + if ((is_air_unit(punit) || is_heli_unit(punit)) && unit_type(punit)->attack_strength > 1) { ai->threats.air = TRUE; } /* If our enemy builds missiles, worry about missile defence. */ - if (can_build_antimissile && unit_flag(punit, F_MISSILE) + if (unit_flag(punit, F_MISSILE) && unit_type(punit)->attack_strength > 1) { ai->threats.missile = TRUE; } /* If he builds nukes, worry a lot. */ - if (can_build_antinuke && unit_flag(punit, F_NUCLEAR)) { + if (unit_flag(punit, F_NUCLEAR)) { danger_of_nukes = TRUE; } - - /* If all our darkest fears have come true, we're done here. It - * can't possibly get any worse! This shorts very long loops. */ - if ((ai->threats.air || !can_build_antiair) - && (ai->threats.missile || !can_build_antimissile) - && (danger_of_nukes || !can_build_antinuke) - && (ai->threats.sea || !can_build_antisea) - && ai->threats.invasions) { - break; - } } unit_list_iterate_end; /* Check for nuke capability */ @@ -151,6 +140,7 @@ ai->explore.land_done = TRUE; ai->explore.sea_done = TRUE; ai->explore.continent = fc_calloc(ai->num_continents + 1, sizeof(bool)); + ai->explore.ocean = fc_calloc(ai->num_oceans + 1, sizeof(bool)); whole_map_iterate(x, y) { struct tile *ptile = map_get_tile(x, y); Continent_id continent = map_get_continent(x, y); @@ -160,6 +150,7 @@ && !map_is_known(x, y, pplayer)) { /* We're not done there. */ ai->explore.sea_done = FALSE; + ai->explore.ocean[continent] = TRUE; } /* skip rest, which is land only */ continue; @@ -168,12 +159,9 @@ /* we don't need more explaining, we got the point */ continue; } - if ((map_has_special(x, y, S_HUT) - && (!ai_handicap(pplayer, H_HUTS) - || map_is_known(x, y, pplayer))) - || (ptile->city && unit_list_size(&ptile->units) == 0 - && pplayers_at_war(pplayer, city_owner(ptile->city)))) { - /* hut, empty city... what is the difference? :) */ + if (map_has_special(x, y, S_HUT) + && (!ai_handicap(pplayer, H_HUTS) + || map_is_known(x, y, pplayer))) { ai->explore.land_done = FALSE; ai->explore.continent[continent] = TRUE; continue; @@ -325,6 +313,7 @@ { struct ai_data *ai = &aidata[pplayer->player_no]; + free(ai->explore.ocean); ai->explore.ocean = NULL; free(ai->explore.continent); ai->explore.continent = NULL; free(ai->threats.continent); ai->threats.continent = NULL; free(ai->stats.workers); ai->stats.workers = NULL; @@ -338,7 +327,8 @@ { struct ai_data *ai = &aidata[pplayer->player_no]; - if (ai->num_continents != map.num_continents) { + if (ai->num_continents != map.num_continents + || ai->num_oceans != map.num_oceans) { /* we discovered more continents, recalculate! */ ai_data_turn_done(pplayer); ai_data_turn_init(pplayer); Index: ai/advdomestic.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v retrieving revision 1.115 diff -u -r1.115 advdomestic.c --- ai/advdomestic.c 13 Aug 2004 15:59:11 -0000 1.115 +++ ai/advdomestic.c 16 Aug 2004 16:41:32 -0000 @@ -86,7 +86,8 @@ } /* trump coinage, and wall, and sam */ - return ai->threats.sea ? TRADE_WEIGHTING + 3 : 1; + return ai->threats.ocean[map_get_continent(pcity->x, pcity->y)] + ? TRADE_WEIGHTING + 3 : 1; } /**************************************************************************