Freeciv-3.2
|
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "log.h"
#include "mem.h"
#include "support.h"
#include "timing.h"
#include "ai.h"
#include "city.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "movement.h"
#include "nation.h"
#include "packets.h"
#include "unitlist.h"
#include "citymap.h"
#include "path_finding.h"
#include "pf_tools.h"
#include "citytools.h"
#include "maphand.h"
#include "plrhand.h"
#include "srv_log.h"
#include "unithand.h"
#include "unittools.h"
#include "advbuilding.h"
#include "advdata.h"
#include "advgoto.h"
#include "advtools.h"
#include "infracache.h"
#include "handicaps.h"
#include "autosettlers.h"
Go to the source code of this file.
Data Structures | |
struct | settlermap |
Macros | |
#define | WORKER_FACTOR 1024 |
#define | MAX_DEP_ROADS 5 |
#define | LOG_SETTLER LOG_DEBUG |
Variables | |
action_id | as_actions_transform [MAX_NUM_ACTIONS] |
action_id | as_actions_extra [MAX_NUM_ACTIONS] |
action_id | as_actions_rmextra [MAX_NUM_ACTIONS] |
static struct timer * | as_timer = NULL |
Find some work for our settlers and/or workers.
Definition at line 921 of file autosettlers.c.
#define MAX_DEP_ROADS 5 |
#define WORKER_FACTOR 1024 |
Definition at line 70 of file autosettlers.c.
bool adv_settler_safe_tile | ( | const struct civ_map * | nmap, |
const struct player * | pplayer, | ||
struct unit * | punit, | ||
struct tile * | ptile | ||
) |
Do we consider tile safe for autosettler to work?
Definition at line 1143 of file autosettlers.c.
Referenced by auto_settlers_player(), dai_auto_settler_cont(), and settler_evaluate_improvements().
Free resources allocated for autosettlers system
Definition at line 86 of file autosettlers.c.
Referenced by server_quit().
adv_want adv_settlers_road_bonus | ( | const struct civ_map * | nmap, |
struct tile * | ptile, | ||
struct road_type * | proad | ||
) |
Calculate the attractiveness of building a road/rail at the given tile.
This calculates the overall benefit of connecting the civilization; this is independent from the local tile (trade) bonus granted by the road.
Definition at line 132 of file autosettlers.c.
Referenced by settler_evaluate_improvements(), and texai_tile_worker_task_select().
Change unit's advisor task.
Definition at line 1269 of file autosettlers.c.
Referenced by auto_settler_findwork(), dai_auto_settler_run(), dai_manage_settler(), handle_unit_change_activity_real(), handle_unit_orders(), player_restore_units(), server_remove_unit_full(), and unit_plans_clear().
void auto_settler_findwork | ( | const struct civ_map * | nmap, |
struct player * | pplayer, | ||
struct unit * | punit, | ||
struct settlermap * | state, | ||
int | recursion | ||
) |
Definition at line 922 of file autosettlers.c.
Referenced by auto_settler_setup_work(), and auto_settlers_player().
bool auto_settler_setup_work | ( | const struct civ_map * | nmap, |
struct player * | pplayer, | ||
struct unit * | punit, | ||
struct settlermap * | state, | ||
int | recursion, | ||
struct pf_path * | path, | ||
struct tile * | best_tile, | ||
enum unit_activity | best_act, | ||
struct extra_type ** | best_target, | ||
int | completion_time | ||
) |
Setup our settler to do the work it has found. Returns TRUE if started actual work.
Definition at line 1011 of file autosettlers.c.
Referenced by auto_settler_findwork(), and dai_auto_settler_run().
Run through all the players settlers and let those on ai.control work automagically.
Definition at line 1165 of file autosettlers.c.
Referenced by end_phase().
Initialize auto settlers based on the ruleset.
Definition at line 95 of file autosettlers.c.
Referenced by adv_units_ruleset_init().
bool auto_settlers_speculate_can_act_at | ( | const struct unit * | punit, |
enum unit_activity | activity, | ||
bool | omniscient_cheat, | ||
struct extra_type * | target, | ||
const struct tile * | ptile | ||
) |
Returns TRUE iff the unit can do the targeted activity at the given location.
Definition at line 1286 of file autosettlers.c.
Referenced by settler_evaluate_city_requests().
|
static |
Don't enter in enemy territories.
Definition at line 412 of file autosettlers.c.
Referenced by auto_settler_setup_work(), settler_evaluate_city_requests(), and settler_evaluate_improvements().
|
static |
Compares the best known tile improvement action with improving ptile with activity act. Calculates the value of improving the tile by discounting the total value by the time it would take to do the work and multiplying by some factor.
Definition at line 308 of file autosettlers.c.
Referenced by settler_evaluate_improvements().
struct city * settler_evaluate_city_requests | ( | struct unit * | punit, |
struct worker_task ** | best_task, | ||
struct pf_path ** | path, | ||
struct settlermap * | state | ||
) |
Return best city request to fulfill.
Definition at line 831 of file autosettlers.c.
Referenced by auto_settler_findwork(), and dai_auto_settler_run().
adv_want settler_evaluate_improvements | ( | const struct civ_map * | nmap, |
struct unit * | punit, | ||
enum unit_activity * | best_act, | ||
struct extra_type ** | best_target, | ||
struct tile ** | best_tile, | ||
struct pf_path ** | path, | ||
struct settlermap * | state | ||
) |
Finds tiles to improve, using punit.
The returned value is the goodness of the best tile and action found. If this return value is > 0, then best_tile indicates the tile chosen, bestact indicates the activity it wants to do, and path (if not NULL) indicates the path to follow for the unit. If 0 is returned then there are no worthwhile activities available.
completion_time is the time that would be taken by punit to travel to and complete work at best_tile
state contains, for each tile, the unit id of the worker en route, and the eta of this worker (if any). This information is used to possibly displace this previously assigned worker. if this array is NULL, workers are never displaced.
Definition at line 441 of file autosettlers.c.
Referenced by auto_settler_findwork(), contemplate_terrain_improvements(), and dai_auto_settler_run().
action_id as_actions_extra[MAX_NUM_ACTIONS] |
Definition at line 78 of file autosettlers.c.
Referenced by auto_settlers_ruleset_init().
action_id as_actions_rmextra[MAX_NUM_ACTIONS] |
Definition at line 79 of file autosettlers.c.
Referenced by auto_settlers_ruleset_init().
action_id as_actions_transform[MAX_NUM_ACTIONS] |
Definition at line 77 of file autosettlers.c.
Referenced by auto_settlers_ruleset_init().
Definition at line 81 of file autosettlers.c.
Referenced by adv_settlers_free(), and auto_settlers_player().