Freeciv21
Develop your civilization from humble roots to a global empire
difficulty.cpp File Reference
#include <QBitArray>
#include "astring.h"
#include "fcintl.h"
#include "rand.h"
#include "player.h"
#include "handicaps.h"
#include "difficulty.h"
+ Include dependency graph for difficulty.cpp:

Go to the source code of this file.

Functions

static QBitArray * handicap_of_skill_level (enum ai_level level)
 Returns handicap bitvector for given AI skill level. More...
 
static int fuzzy_of_skill_level (enum ai_level level)
 Return the AI fuzziness (0 to 1000) corresponding to a given skill level (1 to 10). More...
 
static int science_cost_of_skill_level (enum ai_level level)
 Return the AI's science development cost; a science development cost of 100 means that the AI develops science at the same speed as a human; a science development cost of 200 means that the AI develops science at half the speed of a human, and a science development cost of 50 means that the AI develops science twice as fast as the human. More...
 
static int expansionism_of_skill_level (enum ai_level level)
 Return the AI expansion tendency, a percentage factor to value new cities, compared to defaults. More...
 
void set_ai_level_directer (struct player *pplayer, enum ai_level level)
 Set an AI level and related quantities, with no feedback. More...
 
char * ai_level_help (const char *cmdname)
 Helper function for skill level command help. More...
 
bool ai_fuzzy (const struct player *pplayer, bool normal_decision)
 Return the value normal_decision (a boolean), except if the AI is fuzzy, then sometimes flip the value. More...
 

Function Documentation

◆ ai_fuzzy()

bool ai_fuzzy ( const struct player pplayer,
bool  normal_decision 
)

Return the value normal_decision (a boolean), except if the AI is fuzzy, then sometimes flip the value.

The intention of this is that instead of if (condition) { action } you can use if (ai_fuzzy(pplayer, condition)) { action } to sometimes flip a decision, to simulate an AI with some confusion, indecisiveness, forgetfulness etc. In practice its often safer to use if (condition && ai_fuzzy(pplayer,1)) { action } for an action which only makes sense if condition holds, but which a fuzzy AI can safely "forget". Note that for a non-fuzzy AI, or for a human player being helped by the AI (eg, autosettlers), you can ignore the "ai_fuzzy(pplayer," part, and read the previous example as: if (condition && 1) { action } –dwp

Definition at line 318 of file difficulty.cpp.

Referenced by dai_spend_gold(), find_something_to_kill(), is_my_turn(), look_for_charge(), and military_advisor_choose_build().

◆ ai_level_help()

char* ai_level_help ( const char *  cmdname)

Helper function for skill level command help.

'cmdname' is a server command name. Caller must free returned string.

Definition at line 225 of file difficulty.cpp.

◆ expansionism_of_skill_level()

static int expansionism_of_skill_level ( enum ai_level  level)
static

Return the AI expansion tendency, a percentage factor to value new cities, compared to defaults.

0 means never build new cities, > 100 means to (over?)value them even more than the default (already expansionistic) AI.

Definition at line 194 of file difficulty.cpp.

Referenced by ai_level_help(), and set_ai_level_directer().

◆ fuzzy_of_skill_level()

static int fuzzy_of_skill_level ( enum ai_level  level)
static

Return the AI fuzziness (0 to 1000) corresponding to a given skill level (1 to 10).

See ai_fuzzy() in common/player.c

Definition at line 129 of file difficulty.cpp.

Referenced by ai_level_help(), and set_ai_level_directer().

◆ handicap_of_skill_level()

static QBitArray * handicap_of_skill_level ( enum ai_level  level)
static

Returns handicap bitvector for given AI skill level.

Definition at line 48 of file difficulty.cpp.

Referenced by ai_level_help(), and set_ai_level_directer().

◆ science_cost_of_skill_level()

static int science_cost_of_skill_level ( enum ai_level  level)
static

Return the AI's science development cost; a science development cost of 100 means that the AI develops science at the same speed as a human; a science development cost of 200 means that the AI develops science at half the speed of a human, and a science development cost of 50 means that the AI develops science twice as fast as the human.

Definition at line 163 of file difficulty.cpp.

Referenced by ai_level_help(), and set_ai_level_directer().

◆ set_ai_level_directer()

void set_ai_level_directer ( struct player pplayer,
enum ai_level  level 
)

Set an AI level and related quantities, with no feedback.

Definition at line 36 of file difficulty.cpp.

Referenced by aifill(), create_animals(), create_barbarian_player(), player_set_to_ai_mode(), set_ai_level(), set_ai_level_direct(), and sg_load_player_main().