Freeciv-3.2
Loading...
Searching...
No Matches
Functions
difficulty.c File Reference
#include "astring.h"
#include "bitvector.h"
#include "rand.h"
#include "player.h"
#include "handicaps.h"
#include "difficulty.h"

Go to the source code of this file.

Functions

static bv_handicap handicap_of_skill_level (enum ai_level level)
 
static int fuzzy_of_skill_level (enum ai_level level)
 
static int science_cost_of_skill_level (enum ai_level level)
 
static int expansionism_of_skill_level (enum ai_level level)
 
void set_ai_level_directer (struct player *pplayer, enum ai_level level)
 
charai_level_help (const char *cmdname)
 
bool ai_fuzzy (const struct player *pplayer, bool normal_decision)
 

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, TRUE)) { 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 && TRUE) { action } –dwp

Definition at line 339 of file difficulty.c.

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 239 of file difficulty.c.

◆ 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 208 of file difficulty.c.

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()

Definition at line 143 of file difficulty.c.

Referenced by ai_level_help(), and set_ai_level_directer().

◆ handicap_of_skill_level()

static bv_handicap handicap_of_skill_level ( enum ai_level  level)
static

Returns handicap bitvector for given AI skill level

Definition at line 51 of file difficulty.c.

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 177 of file difficulty.c.

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 
)