Author: cazfi Date: Wed Aug 10 15:47:35 2016 New Revision: 33540 URL: http://svn.gna.org/viewcvs/freeciv?rev=33540&view=rev Log: If city already has caravans it has been unable to use for any reason, reduce want for building more.
See patch #7570 Modified: trunk/ai/default/daidomestic.c Modified: trunk/ai/default/daidomestic.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daidomestic.c?rev=33540&r1=33539&r2=33540&view=diff ============================================================================== --- trunk/ai/default/daidomestic.c (original) +++ trunk/ai/default/daidomestic.c Wed Aug 10 15:47:35 2016 @@ -134,7 +134,7 @@ "Non existence of wonder helper unit not caught"); /* Check if wonder needs a little help. */ - if (build_points_left(wonder_city) + if (build_points_left(wonder_city) > utype_build_shield_cost(unit_type) * caravans) { struct impr_type *wonder = wonder_city->production.value.building; adv_want want = wonder_city->server.adv->building_want[improvement_index(wonder)]; @@ -181,6 +181,8 @@ adv_want want; int income, bonus; int trade_routes; + int caravan_units; + int unassigned_caravans; int max_routes; Continent_id continent = tile_continent(pcity->tile); bool dest_city_found = FALSE; @@ -283,8 +285,7 @@ unit_type = best_role_unit(pcity, action_get_role(ACTION_TRADE_ROUTE)); if (!unit_type) { - /* Can't establish trade route yet. What about entering a market - * place? */ + /* Can't establish trade route yet. What about entering a marketplace? */ /* TODO: Should a future unit capable of establishing trade routes be * prioritized above a present unit capable of entering a market place? * In that case this should be below the check for a future unit @@ -300,7 +301,7 @@ if (!unit_type) { /* We'll never be able to establish a trade route. Consider a unit that - * can enter the market place in stead to stimulate science. */ + * can enter the marketplace in stead to stimulate science. */ unit_type = get_role_unit(action_get_role(ACTION_MARKETPLACE), 0); } @@ -309,13 +310,16 @@ trade_routes = city_num_trade_routes(pcity); /* Count also caravans enroute to establish traderoutes */ + caravan_units = 0; unit_list_iterate(pcity->units_supported, punit) { if (unit_can_do_action(punit, ACTION_TRADE_ROUTE)) { - trade_routes++; + caravan_units++; } } unit_list_iterate_end; max_routes = max_trade_routes(pcity); + unassigned_caravans = caravan_units - (max_routes - trade_routes); + trade_routes += caravan_units; /* We consider only initial benefit from establishing trade route. * We may actually get only initial benefit if both cities already @@ -391,7 +395,7 @@ if (pplayer->economic.science < 50 && trade_routes < max_routes && utype_can_do_action(unit_type, ACTION_TRADE_ROUTE)) { want *= - (6 - pplayer->economic.science/10) * (6 - pplayer->economic.science/10); + (6 - pplayer->economic.science / 10) * (6 - pplayer->economic.science / 10); } if (trade_routes == 0 && max_routes > 0 @@ -405,6 +409,13 @@ } want -= utype_build_shield_cost(unit_type) * SHIELD_WEIGHTING / 150; + + /* Don't pile too many of them */ + if (unassigned_caravans * 10 > want && want > 0.0) { + want = 0.1; + } else { + want -= unassigned_caravans * 10; /* Don't pile too many of them */ + } CITY_LOG(LOG_DEBUG, pcity, "want for trade route unit is " ADV_WANT_PRINTF " (expected initial income %d)", _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits