![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <QHash>#include "support.h"#include "timing.h"#include "city.h"#include "game.h"#include "government.h"#include "map.h"#include "packets.h"#include "player.h"#include "workertask.h"#include "citymap.h"#include "pf_tools.h"#include "citytools.h"#include "maphand.h"#include "srv_log.h"#include "unithand.h"#include "unittools.h"#include "advdata.h"#include "advgoto.h"#include "advtools.h"#include "autosettlers.h"#include "infracache.h"#include "handicaps.h"#include "aidata.h"#include "aiferry.h"#include "ailog.h"#include "aiplayer.h"#include "aitools.h"#include "aiunit.h"#include "daicity.h"#include "aisettler.h"
Include dependency graph for aisettler.cpp:Go to the source code of this file.
Classes | |
| struct | tile_data_cache |
| struct | ai_settler |
| struct | cityresult |
Macros | |
| #define | RESULT_IS_ENOUGH 250 |
| #define | FERRY_TECH_WANT 500 |
| #define | GROWTH_PRIORITY 15 |
| #define | PERFECTION 3 |
| #define | GROWTH_POTENTIAL_DEEMPHASIS 8 |
| #define | NAVAL_EMPHASIS 20 |
| #define | DEFENSE_EMPHASIS 20 |
Functions | |
| struct tile_data_cache * | tile_data_cache_new () |
| Allocate tile data cache. More... | |
| struct tile_data_cache * | tile_data_cache_copy (const struct tile_data_cache *ptdc) |
| Make copy of tile data cache. More... | |
| static const struct tile_data_cache * | tdc_plr_get (struct ai_type *ait, struct player *plr, int tindex) |
| Return player's tile data cache. More... | |
| static void | tdc_plr_set (struct ai_type *ait, struct player *plr, int tindex, const struct tile_data_cache *ptdc) |
| Store player's tile data cache. More... | |
| static std::unique_ptr< cityresult > | cityresult_fill (struct ai_type *ait, struct player *pplayer, struct tile *center) |
| Fill cityresult struct with useful info about the city spot. More... | |
| static bool | food_starvation (const std::unique_ptr< cityresult > &result) |
| Check if a city on this location would starve. More... | |
| static bool | shield_starvation (const std::unique_ptr< cityresult > &result) |
| Check if a city on this location would lack shields. More... | |
| static int | result_defense_bonus (struct player *pplayer, const std::unique_ptr< cityresult > &result) |
| Calculate defense bonus, which is a % of total results equal to a given % of the defense bonus %. More... | |
| static int | naval_bonus (const std::unique_ptr< cityresult > &result) |
| Add bonus for coast. More... | |
| static void | print_cityresult (struct player *pplayer, const std::unique_ptr< cityresult > &cr) |
| For debugging, print the city result table. More... | |
| std::unique_ptr< cityresult > | city_desirability (struct ai_type *ait, struct player *pplayer, struct unit *punit, struct tile *ptile) |
| Calculates the desire for founding a new city at 'ptile'. More... | |
| static std::unique_ptr< cityresult > | settler_map_iterate (struct ai_type *ait, struct pf_parameter *parameter, struct unit *punit, int boat_cost) |
| Find nearest and best city placement in a PF iteration according to "parameter". More... | |
| static std::unique_ptr< cityresult > | find_best_city_placement (struct ai_type *ait, struct unit *punit, bool look_for_boat, bool use_virt_boat) |
| Find nearest and best city placement or (TODO) a city to immigrate to. More... | |
| static bool | dai_do_build_city (struct ai_type *ait, struct player *pplayer, struct unit *punit) |
| Build a city and initialize AI infrastructure cache. More... | |
| void | dai_auto_settler_init (struct ai_plr *ai) |
| Initialize ai settler engine. More... | |
| void | dai_auto_settler_run (struct ai_type *ait, struct player *pplayer, struct unit *punit, struct settlermap *state) |
| Auto settler that can also build cities. More... | |
| void | dai_auto_settler_cont (struct ai_type *ait, struct player *pplayer, struct unit *punit, struct settlermap *state) |
| Auto settler continuing its work. More... | |
| void | dai_auto_settler_reset (struct ai_type *ait, struct player *pplayer) |
| Reset ai settler engine. More... | |
| void | dai_auto_settler_free (struct ai_plr *ai) |
| Deinitialize ai settler engine. More... | |
| void | contemplate_new_city (struct ai_type *ait, struct city *pcity) |
| Return want for city settler. More... | |
| #define DEFENSE_EMPHASIS 20 |
Definition at line 107 of file aisettler.cpp.
| #define FERRY_TECH_WANT 500 |
Definition at line 87 of file aisettler.cpp.
| #define GROWTH_POTENTIAL_DEEMPHASIS 8 |
Definition at line 100 of file aisettler.cpp.
| #define GROWTH_PRIORITY 15 |
Definition at line 89 of file aisettler.cpp.
| #define NAVAL_EMPHASIS 20 |
Definition at line 103 of file aisettler.cpp.
| #define PERFECTION 3 |
Definition at line 95 of file aisettler.cpp.
| #define RESULT_IS_ENOUGH 250 |
Definition at line 85 of file aisettler.cpp.
| std::unique_ptr< cityresult > city_desirability | ( | struct ai_type * | ait, |
| struct player * | pplayer, | ||
| struct unit * | punit, | ||
| struct tile * | ptile | ||
| ) |
Calculates the desire for founding a new city at 'ptile'.
The citymap ensures that we do not build cities too close to each other. Returns nullptr if no place was found.
Definition at line 658 of file aisettler.cpp.
Referenced by settler_map_iterate().
|
static |
Fill cityresult struct with useful info about the city spot.
It must contain valid x, y coordinates and total should be zero.
We assume whatever best government we are aiming for.
We always return valid other_x and other_y if total > 0.
Definition at line 227 of file aisettler.cpp.
Referenced by city_desirability().
Return want for city settler.
Note that we rely here on the fact that ai_settler_init() has been run while doing autosettlers.
Definition at line 1228 of file aisettler.cpp.
Referenced by dai_manage_cities().
| void dai_auto_settler_cont | ( | struct ai_type * | ait, |
| struct player * | pplayer, | ||
| struct unit * | punit, | ||
| struct settlermap * | state | ||
| ) |
Auto settler continuing its work.
Definition at line 1113 of file aisettler.cpp.
Referenced by cai_auto_settler_cont(), texwai_auto_settler_cont(), and twai_auto_settler_cont().
| void dai_auto_settler_free | ( | struct ai_plr * | ai | ) |
Deinitialize ai settler engine.
Definition at line 1158 of file aisettler.cpp.
Referenced by dai_data_close().
| void dai_auto_settler_init | ( | struct ai_plr * | ai | ) |
Initialize ai settler engine.
Definition at line 945 of file aisettler.cpp.
Referenced by dai_data_init().
Reset ai settler engine.
Definition at line 1124 of file aisettler.cpp.
Referenced by cai_auto_settler_reset(), dai_manage_cities(), texwai_auto_settler_reset(), and twai_auto_settler_reset().
| void dai_auto_settler_run | ( | struct ai_type * | ait, |
| struct player * | pplayer, | ||
| struct unit * | punit, | ||
| struct settlermap * | state | ||
| ) |
Auto settler that can also build cities.
Definition at line 964 of file aisettler.cpp.
Referenced by cai_auto_settler_run(), texwai_auto_settler_run(), and twai_auto_settler_run().
|
static |
Build a city and initialize AI infrastructure cache.
Definition at line 1172 of file aisettler.cpp.
Referenced by dai_auto_settler_run().
|
static |
Find nearest and best city placement or (TODO) a city to immigrate to.
Option look_for_boat forces us to find a (real) boat before considering going overseas. Option use_virt_boat allows to use virtual boat but only if punit is in a coastal city right now (should only be used by virtual units). I guess it won't hurt to remove this condition, PF will just give no positions. If (!look_for_boat && !use_virt_boat), will not consider placements overseas.
Returns the better cityresult or nullptr if no result was found.
Definition at line 835 of file aisettler.cpp.
Referenced by contemplate_new_city(), and dai_auto_settler_run().
|
static |
Check if a city on this location would starve.
Definition at line 517 of file aisettler.cpp.
Referenced by city_desirability(), and print_cityresult().
|
static |
Add bonus for coast.
Definition at line 575 of file aisettler.cpp.
Referenced by city_desirability(), and print_cityresult().
|
static |
For debugging, print the city result table.
Definition at line 590 of file aisettler.cpp.
Referenced by dai_auto_settler_run().
|
static |
Calculate defense bonus, which is a % of total results equal to a given % of the defense bonus %.
Definition at line 544 of file aisettler.cpp.
Referenced by city_desirability(), and print_cityresult().
|
static |
Find nearest and best city placement in a PF iteration according to "parameter".
The value in "boat_cost" is both the penalty to pay for using a boat and an indicator (boat_cost != 0) if a boat was used at all. The result is returned in "best".
Return value is a 'struct cityresult' if found something better than what was originally in "best" was found; else nullptr.
TODO: Transparently check if we should add ourselves to an existing city.
Definition at line 740 of file aisettler.cpp.
Referenced by find_best_city_placement().
|
static |
Check if a city on this location would lack shields.
Definition at line 532 of file aisettler.cpp.
Referenced by city_desirability(), and print_cityresult().
|
static |
Return player's tile data cache.
Definition at line 461 of file aisettler.cpp.
Referenced by cityresult_fill().
|
static |
Store player's tile data cache.
Definition at line 494 of file aisettler.cpp.
Referenced by cityresult_fill().
| struct tile_data_cache * tile_data_cache_copy | ( | const struct tile_data_cache * | ptdc | ) |
Make copy of tile data cache.
Definition at line 439 of file aisettler.cpp.
Referenced by cityresult_fill().
| struct tile_data_cache * tile_data_cache_new | ( | ) |
Allocate tile data cache.
Definition at line 425 of file aisettler.cpp.
Referenced by cityresult_fill(), and tile_data_cache_copy().