Freeciv-3.3
|
#include <stdio.h>
#include <string.h>
#include "mem.h"
#include "log.h"
#include "support.h"
#include "timing.h"
#include "city.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "movement.h"
#include "packets.h"
#include "player.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 "autoworkers.h"
#include "infracache.h"
#include "handicaps.h"
#include "aiferry.h"
#include "daicity.h"
#include "daidata.h"
#include "dailog.h"
#include "daiplayer.h"
#include "daitools.h"
#include "daisettler.h"
#include "spechash.h"
Go to the source code of this file.
Data Structures | |
struct | tile_data_cache |
struct | ai_settler |
struct | cityresult |
Enumerations | |
enum | cb_error_level { CBE_OK , CBE_RECOVERABLE , CBE_FATAL } |
#define DEFENSE_EMPHASIS 20 |
Definition at line 116 of file daisettler.c.
#define FERRY_TECH_WANT 500 |
Definition at line 96 of file daisettler.c.
#define GROWTH_POTENTIAL_DEEMPHASIS 8 |
Definition at line 109 of file daisettler.c.
#define GROWTH_PRIORITY 15 |
Definition at line 98 of file daisettler.c.
#define NAVAL_EMPHASIS 20 |
Definition at line 112 of file daisettler.c.
#define PERFECTION 3 |
Definition at line 104 of file daisettler.c.
#define RESULT_IS_ENOUGH 250 |
Definition at line 94 of file daisettler.c.
#define SPECHASH_IDATA_FREE tile_data_cache_destroy |
Definition at line 140 of file daisettler.c.
#define SPECHASH_IDATA_TYPE struct tile_data_cache * |
Definition at line 139 of file daisettler.c.
#define SPECHASH_INT_KEY_TYPE |
Definition at line 138 of file daisettler.c.
#define SPECHASH_TAG tile_data_cache |
Definition at line 137 of file daisettler.c.
Enumerator | |
---|---|
CBE_OK | |
CBE_RECOVERABLE | |
CBE_FATAL |
Definition at line 185 of file daisettler.c.
struct 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 NULL if no place was found.
Definition at line 713 of file daisettler.c.
Referenced by settler_map_iterate().
|
static |
Destroy a city result.
Definition at line 257 of file daisettler.c.
Referenced by city_desirability(), contemplate_new_city(), dai_auto_settler_run(), find_best_city_placement(), and 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 275 of file daisettler.c.
Referenced by city_desirability().
|
static |
Allocated a city result.
Definition at line 224 of file daisettler.c.
Referenced by cityresult_fill().
Return want for city settler. Note that we rely here on the fact that citymap_turn_init() has been run while doing autoworkers.
Definition at line 1327 of file daisettler.c.
Referenced by dai_manage_cities().
void dai_auto_settler_cont | ( | struct ai_type * | ait, |
const struct civ_map * | nmap, | ||
struct player * | pplayer, | ||
struct unit * | punit, | ||
struct workermap * | state | ||
) |
Auto settler continuing its work.
Definition at line 1206 of file daisettler.c.
Referenced by cai_auto_settler_cont(), and texwai_auto_settler_cont().
Deinitialize ai settler engine.
Definition at line 1250 of file daisettler.c.
Referenced by dai_data_close().
Initialize ai settler engine.
Definition at line 1013 of file daisettler.c.
Referenced by dai_data_init().
Reset ai settler engine.
Definition at line 1219 of file daisettler.c.
Referenced by cai_auto_settler_reset(), dai_manage_cities(), and texwai_auto_settler_reset().
void dai_auto_settler_run | ( | struct ai_type * | ait, |
const struct civ_map * | nmap, | ||
struct player * | pplayer, | ||
struct unit * | punit, | ||
struct workermap * | state | ||
) |
Auto settler that can also build cities.
Definition at line 1032 of file daisettler.c.
Referenced by cai_auto_settler_run(), dai_auto_settler_run(), and texwai_auto_settler_run().
|
static |
Build a city and initialize AI infrastructure cache.
Definition at line 1266 of file daisettler.c.
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 NULL if no result was found.
Definition at line 896 of file daisettler.c.
Referenced by contemplate_new_city(), and dai_auto_settler_run().
|
static |
Check if a city on this location would starve.
Definition at line 569 of file daisettler.c.
Referenced by city_desirability(), and print_cityresult().
|
static |
Add bonus for coast.
Definition at line 625 of file daisettler.c.
Referenced by city_desirability(), and print_cityresult().
For debugging, print the city result table.
Definition at line 641 of file daisettler.c.
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 596 of file daisettler.c.
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 NULL.
TODO: Transparently check if we should add ourselves to an existing city.
Definition at line 790 of file daisettler.c.
Referenced by find_best_city_placement().
|
static |
Check if a city on this location would lack shields.
Definition at line 584 of file daisettler.c.
Referenced by city_desirability(), and print_cityresult().
|
static |
Return player's tile data cache
Definition at line 514 of file daisettler.c.
Referenced by cityresult_fill().
|
static |
Store player's tile data cache
Definition at line 549 of file daisettler.c.
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 484 of file daisettler.c.
Referenced by cityresult_fill().
|
static |
Free resources allocated for tile data cache
Definition at line 504 of file daisettler.c.
struct tile_data_cache * tile_data_cache_new | ( | void | ) |
Allocate tile data cache
Definition at line 470 of file daisettler.c.
Referenced by cityresult_fill(), and tile_data_cache_copy().