From 107ee2c3792f686b3a31cad0ee0bef05f1dea815 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 2 Jun 2023 01:44:02 +0300 Subject: [PATCH 31/31] AI: Adjust max want domestic advisor might assign To match changed military emergency indicator value See osdn #47823 Signed-off-by: Marko Lindqvist --- ai/default/aitools.h | 7 ++++++- ai/default/daidomestic.c | 15 +++++++++------ ai/default/daimilitary.c | 2 +- ai/default/daimilitary.h | 3 --- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ai/default/aitools.h b/ai/default/aitools.h index 4a5d7ad2bc..0f0c176d41 100644 --- a/ai/default/aitools.h +++ b/ai/default/aitools.h @@ -28,6 +28,10 @@ struct pft_amphibious; struct adv_risk_cost; +#define DAI_WANT_BELOW_MIL_EMERGENCY (1000.0) +#define DAI_WANT_MILITARY_EMERGENCY (DAI_WANT_BELOW_MIL_EMERGENCY + 0.1) +#define DAI_WANT_DOMESTIC_MAX (DAI_WANT_MILITARY_EMERGENCY / 4 * 3) + const char *dai_unit_task_rule_name(const enum ai_unit_task task); const char *dai_choice_rule_name(const struct adv_choice *choice); @@ -36,7 +40,8 @@ adv_want military_amortize(struct player *pplayer, struct city *pcity, int stack_cost(struct unit *pattacker, struct unit *pdefender); void dai_unit_move_or_attack(struct ai_type *ait, struct unit *punit, - struct tile *ptile, struct pf_path *path, int step); + struct tile *ptile, struct pf_path *path, + int step); void dai_fill_unit_param(struct ai_type *ait, struct pf_parameter *parameter, diff --git a/ai/default/daidomestic.c b/ai/default/daidomestic.c index 6d220e22c1..31f72e9734 100644 --- a/ai/default/daidomestic.c +++ b/ai/default/daidomestic.c @@ -519,7 +519,8 @@ struct adv_choice *domestic_advisor_choose_build(struct ai_type *ait, && pcity->surplus[O_FOOD] > utype_upkeep_cost(worker_type, pplayer, O_FOOD)) { if (worker_want > 0) { - CITY_LOG(LOG_DEBUG, pcity, "desires terrain improvers with passion " ADV_WANT_PRINTF, + CITY_LOG(LOG_DEBUG, pcity, + "desires terrain improvers with passion " ADV_WANT_PRINTF, worker_want); dai_choose_role_unit(ait, pplayer, pcity, choice, CT_CIVILIAN, UTYF_SETTLERS, worker_want, FALSE); @@ -562,7 +563,8 @@ struct adv_choice *domestic_advisor_choose_build(struct ai_type *ait, pplayer, O_FOOD)) { if (founder_want > choice->want) { - CITY_LOG(LOG_DEBUG, pcity, "desires founders with passion " ADV_WANT_PRINTF, + CITY_LOG(LOG_DEBUG, pcity, + "desires founders with passion " ADV_WANT_PRINTF, founder_want); dai_choose_role_unit(ait, pplayer, pcity, choice, CT_CIVILIAN, action_id_get_role(ACTION_FOUND_CITY), @@ -576,14 +578,15 @@ struct adv_choice *domestic_advisor_choose_build(struct ai_type *ait, * if they are blockaded or in inland seas. */ struct ai_plr *ai = dai_plr_data_get(ait, pplayer, NULL); - CITY_LOG(LOG_DEBUG, pcity, "desires founders with passion " ADV_WANT_PRINTF + CITY_LOG(LOG_DEBUG, pcity, + "desires founders with passion " ADV_WANT_PRINTF " and asks for a new boat (%d of %d free)", -founder_want, ai->stats.available_boats, ai->stats.boats); /* First fill choice with founder information */ choice->want = 0 - founder_want; choice->type = CT_CIVILIAN; - choice->value.utype = founder_type; /* default */ + choice->value.utype = founder_type; /* Default */ choice->need_boat = TRUE; /* Then try to overwrite it with ferryboat information @@ -625,10 +628,10 @@ struct adv_choice *domestic_advisor_choose_build(struct ai_type *ait, choice = adv_better_choice_free(choice, cur); } - if (choice->want >= 200) { + if (choice->want > DAI_WANT_DOMESTIC_MAX) { /* If we don't do following, we buy caravans in city X when we should be * saving money to buy defenses for city Y. -- Syela */ - choice->want = 199; + choice->want = DAI_WANT_DOMESTIC_MAX; } return choice; diff --git a/ai/default/daimilitary.c b/ai/default/daimilitary.c index ef4cff672d..b4a123e44d 100644 --- a/ai/default/daimilitary.c +++ b/ai/default/daimilitary.c @@ -1919,7 +1919,7 @@ struct adv_choice *military_advisor_choose_build(struct ai_type *ait, && uchoice.value.utype->defense_strength == 1) { /* FIXME: check other reqs (unit class?) */ if (get_city_bonus(pcity, EFT_HP_REGEN) > 0) { - /* unlikely */ + /* Unlikely */ uchoice.want = MIN(49, danger); } else { uchoice.want = MIN(25, danger); diff --git a/ai/default/daimilitary.h b/ai/default/daimilitary.h index 433a058829..a64eef220c 100644 --- a/ai/default/daimilitary.h +++ b/ai/default/daimilitary.h @@ -31,9 +31,6 @@ struct civ_map; to finish them off. */ #define FINISH_HIM_CITY_COUNT 5 -#define DAI_WANT_BELOW_MIL_EMERGENCY (1000.0) -#define DAI_WANT_MILITARY_EMERGENCY (DAI_WANT_BELOW_MIL_EMERGENCY + 0.1) - typedef struct unit_list *(player_unit_list_getter)(struct player *pplayer); struct unit_type *dai_choose_defender_versus(struct city *pcity, -- 2.39.2