Freeciv21
Develop your civilization from humble roots to a global empire
autoexplorer.cpp File Reference
#include <cmath>
#include "log.h"
#include "ai.h"
#include "map.h"
#include "movement.h"
#include "player.h"
#include "unit.h"
#include "path_finding.h"
#include "pf_tools.h"
#include "maphand.h"
#include "srv_log.h"
#include "advgoto.h"
#include "handicaps.h"
#include "autoexplorer.h"
+ Include dependency graph for autoexplorer.cpp:

Go to the source code of this file.

Macros

#define SAME_TER_SCORE   21
 Return a value indicating how desirable it is to explore the given tile. More...
 
#define DIFF_TER_SCORE   81
 
#define KNOWN_SAME_TER_SCORE   0
 
#define KNOWN_DIFF_TER_SCORE   51
 
#define MAX_NEW_TILES   5
 
#define VISION_TILES   9
 
#define BEST_NORMAL_TILE
 
#define OWN_CITY_SCORE   (BEST_NORMAL_TILE + 1)
 
#define HUT_SCORE   (OWN_CITY_SCORE + 1)
 
#define BEST_POSSIBLE_SCORE   (HUT_SCORE + BEST_NORMAL_TILE)
 
#define DIST_FACTOR   0.6
 

Functions

static int likely_native (struct tile *ptile, struct player *pplayer, struct unit_class *pclass)
 Determine if a tile is likely to be native, given information that the player actually has. More...
 
static bool player_may_explore (const struct tile *ptile, const struct player *pplayer, const struct unit_type *punittype)
 Returns TRUE if a unit owned by the given player can safely "explore" the given tile. More...
 
static enum tile_behavior explorer_tb (const struct tile *ptile, enum known_type k, const struct pf_parameter *param)
 TB function used by explorer_goto(). More...
 
static bool explorer_goto (struct unit *punit, struct tile *ptile)
 Constrained goto using player_may_explore(). More...
 
static int explorer_desirable (struct tile *ptile, struct player *pplayer, struct unit *punit)
 
enum unit_move_result manage_auto_explorer (struct unit *punit)
 Handle eXplore mode of a unit (explorers are always in eXplore mode for AI) - explores unknown territory, finds huts. More...
 

Macro Definition Documentation

◆ BEST_NORMAL_TILE

#define BEST_NORMAL_TILE
Value:
#define DIFF_TER_SCORE
#define VISION_TILES
#define KNOWN_DIFF_TER_SCORE
#define MAX_NEW_TILES

Definition at line 182 of file autoexplorer.cpp.

◆ BEST_POSSIBLE_SCORE

#define BEST_POSSIBLE_SCORE   (HUT_SCORE + BEST_NORMAL_TILE)

Definition at line 195 of file autoexplorer.cpp.

◆ DIFF_TER_SCORE

#define DIFF_TER_SCORE   81

Definition at line 162 of file autoexplorer.cpp.

◆ DIST_FACTOR

#define DIST_FACTOR   0.6

◆ HUT_SCORE

#define HUT_SCORE   (OWN_CITY_SCORE + 1)

Definition at line 193 of file autoexplorer.cpp.

◆ KNOWN_DIFF_TER_SCORE

#define KNOWN_DIFF_TER_SCORE   51

Definition at line 164 of file autoexplorer.cpp.

◆ KNOWN_SAME_TER_SCORE

#define KNOWN_SAME_TER_SCORE   0

Definition at line 163 of file autoexplorer.cpp.

◆ MAX_NEW_TILES

#define MAX_NEW_TILES   5

Definition at line 171 of file autoexplorer.cpp.

◆ OWN_CITY_SCORE

#define OWN_CITY_SCORE   (BEST_NORMAL_TILE + 1)

Definition at line 188 of file autoexplorer.cpp.

◆ SAME_TER_SCORE

#define SAME_TER_SCORE   21

Return a value indicating how desirable it is to explore the given tile.

In general, we want to discover unknown terrain of the opposite kind to our natural terrain, i.e. pedestrians like ocean and boats like land. Even if terrain is known, but of opposite kind, we still want it – so that we follow the shoreline. We also would like discovering tiles which can be harvested by our cities – because that improves citizen placement. We do not currently do this, see comment below.

Definition at line 161 of file autoexplorer.cpp.

◆ VISION_TILES

#define VISION_TILES   9

Definition at line 177 of file autoexplorer.cpp.

Function Documentation

◆ explorer_desirable()

static int explorer_desirable ( struct tile ptile,
struct player pplayer,
struct unit punit 
)
static

Definition at line 197 of file autoexplorer.cpp.

◆ explorer_goto()

static bool explorer_goto ( struct unit punit,
struct tile ptile 
)
static

Constrained goto using player_may_explore().

Definition at line 119 of file autoexplorer.cpp.

◆ explorer_tb()

static enum tile_behavior explorer_tb ( const struct tile ptile,
enum known_type  k,
const struct pf_parameter param 
)
static

TB function used by explorer_goto().

Definition at line 79 of file autoexplorer.cpp.

Referenced by explorer_goto().

◆ likely_native()

static int likely_native ( struct tile ptile,
struct player pplayer,
struct unit_class pclass 
)
static

Determine if a tile is likely to be native, given information that the player actually has.

Return the % certainty that it's native (100 = certain, 50 = no idea, 0 = certainly not).

Definition at line 45 of file autoexplorer.cpp.

Referenced by explorer_desirable().

◆ manage_auto_explorer()

enum unit_move_result manage_auto_explorer ( struct unit punit)

Handle eXplore mode of a unit (explorers are always in eXplore mode for AI) - explores unknown territory, finds huts.

MR_OK: there is more territory to be explored. MR_DEATH: unit died. MR_PAUSE: unit cannot explore further now. Other results: unit cannot explore further.

Definition at line 197 of file autoexplorer.cpp.

Referenced by dai_manage_military(), dai_manage_unit(), dai_military_attack(), and do_explore().

◆ player_may_explore()

static bool player_may_explore ( const struct tile ptile,
const struct player pplayer,
const struct unit_type punittype 
)
static

Returns TRUE if a unit owned by the given player can safely "explore" the given tile.

This mainly takes care that military units do not try to move into another player's territory in violation of a treaty.

Definition at line 79 of file autoexplorer.cpp.

Referenced by explorer_desirable().