Author: cazfi Date: Wed Jun 22 09:11:30 2016 New Revision: 32955 URL: http://svn.gna.org/viewcvs/freeciv?rev=32955&view=rev Log: Make AI to build buildings that are not crucial but merely useful
Reported by David Fernandez <bardo> See bug #24526 Modified: trunk/ai/default/aicity.c Modified: trunk/ai/default/aicity.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=32955&r1=32954&r2=32955&view=diff ============================================================================== --- trunk/ai/default/aicity.c (original) +++ trunk/ai/default/aicity.c Wed Jun 22 09:11:30 2016 @@ -888,23 +888,23 @@ constructed, side effect benefits may not be accurately calculated (see improvement.c for details). **************************************************************************/ -static bool building_unwanted(const struct player *plr, - struct impr_type *pimprove, - const struct city *pcity) +static bool building_crucial(const struct player *plr, + struct impr_type *pimprove, + const struct city *pcity) { #if 0 /* This check will become more complicated now. */ if (ai_wants_no_science(plr) && building_has_effect(pimprove, EFT_SCIENCE_BONUS)) { - return TRUE; + return FALSE; } #endif if (building_has_effect(pimprove, EFT_DEFEND_BONUS) /* selling city walls is really, really dumb -- Syela */ || is_improvement_productive(pcity, pimprove)) { - return FALSE; - } - - return TRUE; + return TRUE; + } + + return FALSE; } /************************************************************************** @@ -915,13 +915,13 @@ struct player *pplayer = city_owner(pcity); city_built_iterate(pcity, pimprove) { - if (can_city_sell_building(pcity, pimprove) - && building_unwanted(pplayer, pimprove, pcity)) { + if (can_city_sell_building(pcity, pimprove) + && !building_crucial(pplayer, pimprove, pcity)) { do_sell_building(pplayer, pcity, pimprove); notify_player(pplayer, pcity->tile, E_IMP_SOLD, ftc_server, - _("%s is selling %s (not needed) for %d."), + _("%s is selling %s (not needed) for %d."), city_link(pcity), - improvement_name_translation(pimprove), + improvement_name_translation(pimprove), impr_sell_gold(pimprove)); return; /* max 1 building each turn */ } @@ -1805,17 +1805,12 @@ /* Handle coinage specially because you can never complete coinage */ if (is_coinage - || can_player_build_improvement_later(pplayer, pimprove)) { + || can_player_build_improvement_later(pplayer, pimprove)) { city_list_iterate(pplayer->cities, pcity) { struct ai_city *city_data = def_ai_city_data(pcity, ait); if (pcity != wonder_city && is_wonder(pimprove)) { /* Only wonder city should build wonders! */ - pcity->server.adv->building_want[improvement_index(pimprove)] = 0; - } else if ((!is_coinage - && !can_city_build_improvement_later(pcity, pimprove)) - || building_unwanted(pplayer, pimprove, pcity)) { - /* Don't consider impossible or unwanted buildings */ pcity->server.adv->building_want[improvement_index(pimprove)] = 0; } else if (city_data->building_turn <= game.info.turn) { /* Building wants vary relatively slowly, so not worthwhile @@ -1824,7 +1819,7 @@ * we already have. */ const bool already = city_has_building(pcity, pimprove); - adjust_improvement_wants_by_effects(ait, pplayer, pcity, + adjust_improvement_wants_by_effects(ait, pplayer, pcity, pimprove, already); fc_assert(!(already @@ -1848,7 +1843,7 @@ } } improvement_iterate_end; -#ifdef DEBUG +#ifdef FREECIV_DEBUG /* This logging is relatively expensive, so activate only if necessary */ city_list_iterate(pplayer->cities, pcity) { improvement_iterate(pimprove) { @@ -1859,7 +1854,7 @@ } } improvement_iterate_end; } city_list_iterate_end; -#endif /* DEBUG */ +#endif /* FREECIV_DEBUG */ /* Reset recalc counter */ city_list_iterate(pplayer->cities, pcity) { _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits