48 #define LOGLEVEL_PARATROOPER LOG_DEBUG
58 struct tile *best_tile =
nullptr;
72 && unit_list_size(ptile->units) == 0) {
82 if (best_tile !=
nullptr) {
85 "Choose to jump in order to protect allied city %s (%d %d). "
96 && (unit_list_size(ptile->units) == 0)) {
112 if (best_tile !=
nullptr) {
115 "Choose to jump into enemy city %s (%d %d). Benefit: %d",
134 if (!acity && unit_list_size(ptile->units) > 0) {
140 if (unit_list_size(target->units) == 0
154 val += victim->hp * 100;
163 val -= punit->
hp * 100;
174 if (best_tile !=
nullptr) {
176 "Choose to jump at (%d, %d) to attack "
177 "adjacent units. Benefit: %d",
191 struct tile *ptile_dest =
nullptr;
193 int sanity = punit->
id;
223 tile_index(ptile_dest), 0,
"", ACTION_PARADROP,
237 struct city *acity =
nullptr;
242 "waiting in a city for next turn.");
258 "didn't find city to go and recover.");
269 struct tile *ptile_city)
275 int total, total_cities;
310 if (unit_list_size(ptile->units) > 2) {
327 total_cities = city_list_size(pplayer->
cities);
329 if (total > total_cities) {
330 profit = profit * total_cities / total;
341 bool allow_gold_upkeep)
347 int num_requirements = 0;
359 struct unit *virtual_unit;
364 if (
A_NEVER == u_type->require_advance) {
368 if (!allow_gold_upkeep
382 for (i = 0; i < num_requirements; i++) {
387 if (i == num_requirements) {
388 requirements[num_requirements++] =
tech_req;
399 pplayer, pcity, u_type,
405 if (profit > choice->
want) {
407 choice->
want = profit;
420 for (i = 0; i < num_requirements; i++) {
424 "Raising tech want in city %s for %s "
#define adv_choice_set_use(_choice, _use)
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Return a pointer to our data.
void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer, struct unit *punit)
This function does manage the paratrooper units of the AI.
void dai_choose_paratrooper(struct ai_type *ait, struct player *pplayer, struct city *pcity, struct adv_choice *choice, bool allow_gold_upkeep)
Chooses to build a paratroopers if necessary.
#define LOGLEVEL_PARATROOPER
static struct tile * find_best_tile_to_paradrop_to(struct ai_type *ait, struct unit *punit)
Find best tile the paratrooper should jump to.
static int calculate_want_for_paratrooper(struct unit *punit, struct tile *ptile_city)
Evaluate value of the unit.
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
static struct ai_city * def_ai_city_data(const struct city *pcity, struct ai_type *deftype)
void dai_manage_military(struct ai_type *ait, struct player *pplayer, struct unit *punit)
Decide what to do with a military unit.
struct city * find_nearest_safe_city(struct unit *punit)
Find safe city to recover in.
bool dai_military_rampage(struct unit *punit, int thresh_adj, int thresh_move)
Find and kill anything reachable within this turn and worth more than the relevant of the given thres...
#define RAMPAGE_FREE_CITY_OR_BETTER
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
int city_production_unit_veteran_level(struct city *pcity, const struct unit_type *punittype)
How many veteran levels will created unit of this type get?
const char * city_name_get(const struct city *pcity)
Return the name of the city.
citizens city_size_get(const struct city *pcity)
Get the city size.
bool can_city_build_unit_now(const struct city *pcity, const struct unit_type *punittype)
Return whether given city can build given unit; returns FALSE if unit is obsolete.
struct unit * get_defender(const struct unit *attacker, const struct tile *ptile)
Finds the best defender on the tile, given an attacker.
enum unit_attack_result unit_attack_unit_at_tile_result(const struct unit *punit, const struct unit *pdefender, const struct tile *dest_tile)
Checks if a unit can physically attack pdefender at the tile (assuming it is adjacent and at war).
bool is_stack_vulnerable(const struct tile *ptile)
Is it a city/fortress/air base or will the whole stack die in an attack.
double unit_win_chance(const struct unit *attacker, const struct unit *defender)
Returns a double in the range [0;1] indicating the attackers chance of winning.
bool can_unit_attack_tile(const struct unit *punit, const struct tile *dest_tile)
Is unit (1) diplomatically allowed to attack and (2) physically able to do so?
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
AI players may have handicaps - allowing them to cheat or preventing them from using certain algorith...
#define log_base(level, message,...)
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
#define square_iterate(nmap, center_tile, radius, tile_itr)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define square_iterate_end
int get_continent_size(Continent_id id)
Return size in tiles of the given continent (not ocean)
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Checks if a unit can be seen by pplayer at its current location.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
Returns if the given tech has to be researched to reach the goal.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
#define UNIT_LOG(_, punit, msg,...)
struct adv_data::@87 stats
struct adv_data::@87::@90 units
adv_want tech_want[A_LAST+1]
struct city_list * cities
const char * advance_rule_name(const struct advance *padvance)
Return the (untranslated) rule name of the advance/technology.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
Tech_type_id advance_index(const struct advance *padvance)
Return the advance index.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
#define is_ocean(pterrain)
#define is_ocean_tile(ptile)
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_terrain(_tile)
#define tile_continent(_tile)
const struct unit_type * utype
bool can_unit_paradrop(const struct unit *punit)
Return whether the unit can be paradropped - that is, if the unit is in a friendly city or on an airb...
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
struct unit * unit_virtual_create(struct player *pplayer, struct city *pcity, const struct unit_type *punittype, int veteran_level)
Create a virtual unit skeleton.
bool unit_perform_action(struct player *pplayer, const int actor_id, const int target_id, const int sub_tgt_id_incoming, const char *name, const action_id action_type, const enum action_requester requester)
Execute a request to perform an action and let the caller know if it was performed or not.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer, Output_type_id otype)
Returns the upkeep of a unit of this type under the given government.
const char * utype_rule_name(const struct unit_type *punittype)
Return the (untranslated) rule name of the unit type.
bool utype_is_consumed_by_action_result(enum action_result result, const struct unit_type *utype)
Returns TRUE iff performing an action with the specified action result will consume an actor unit of ...
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
#define utype_fuel(ptype)
#define unit_type_iterate(_p)
#define unit_type_iterate_end