![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "distribute.h"#include "log.h"#include "shared.h"#include "timing.h"#include "city.h"#include "game.h"#include "government.h"#include "nation.h"#include "packets.h"#include "player.h"#include "research.h"#include "unit.h"#include "victory.h"#include "cm.h"#include "cityturn.h"#include "plrhand.h"#include "sernet.h"#include "spacerace.h"#include "srv_log.h"#include "advdata.h"#include "advspace.h"#include "handicaps.h"#include "aidata.h"#include "ailog.h"#include "aiplayer.h"#include "aitech.h"#include "aitools.h"#include "aiunit.h"#include "daicity.h"#include "daidiplomacy.h"#include "daimilitary.h"#include "aihand.h"
Include dependency graph for aihand.cpp:Go to the source code of this file.
Macros | |
| #define | LOGLEVEL_TAX LOG_DEBUG |
| A man builds a city With banks and cathedrals A man melts the sand so he can See the world outside A man makes a car And builds a road to run them on A man dreams of leaving but he always stays behind And these are the days when our work has come assunder And these are the days when we look for something other /U2 Lemon. More... | |
| #define | AI_GOLD_RESERVE_MIN_TURNS 10 |
| #define | AI_BULBS_RESERVE_MIN_TURNS 10 |
| #define | PCT_DELTA_TAX 50 |
| #define | PCT_DELTA_SCI 10 |
| #define | RATE_NOT_SET -1 |
| #define | RATE_VALID(_rate) (_rate != RATE_NOT_SET) |
| #define | RATE_REMAINS(_rates) |
Enumerations | |
| enum | { AI_RATE_SCI = 0 , AI_RATE_TAX , AI_RATE_LUX , AI_RATE_COUNT } |
| Additional data needed for the AI rates calculation. More... | |
| enum | celebration { AI_CELEBRATION_UNCHECKED , AI_CELEBRATION_NO , AI_CELEBRATION_YES } |
Functions | |
| static void | dai_manage_spaceship (struct player *pplayer) |
| Handle spaceship related stuff. More... | |
| void | dai_calc_data (const struct player *pplayer, int *trade, int *expenses, int *income) |
| Returns the total amount of trade generated (trade) and total amount of gold needed as upkeep (expenses). More... | |
| static void | dai_manage_taxes (struct ai_type *ait, struct player *pplayer) |
| Set tax/science/luxury rates. More... | |
| static void | dai_manage_government (struct ai_type *ait, struct player *pplayer) |
| Change the government form, if it can and there is a good reason. More... | |
| void | dai_do_first_activities (struct ai_type *ait, struct player *pplayer) |
| Activities to be done by AI before human turn. More... | |
| void | dai_do_last_activities (struct ai_type *ait, struct player *pplayer) |
| Activities to be done by AI after human turn. More... | |
| #define AI_BULBS_RESERVE_MIN_TURNS 10 |
Definition at line 81 of file aihand.cpp.
| #define AI_GOLD_RESERVE_MIN_TURNS 10 |
Definition at line 80 of file aihand.cpp.
| #define LOGLEVEL_TAX LOG_DEBUG |
A man builds a city With banks and cathedrals A man melts the sand so he can See the world outside A man makes a car And builds a road to run them on A man dreams of leaving but he always stays behind And these are the days when our work has come assunder And these are the days when we look for something other /U2 Lemon.
Definition at line 75 of file aihand.cpp.
| #define PCT_DELTA_SCI 10 |
Definition at line 86 of file aihand.cpp.
| #define PCT_DELTA_TAX 50 |
Definition at line 85 of file aihand.cpp.
| #define RATE_NOT_SET -1 |
Definition at line 163 of file aihand.cpp.
| #define RATE_REMAINS | ( | _rates | ) |
Definition at line 165 of file aihand.cpp.
| #define RATE_VALID | ( | _rate | ) | (_rate != RATE_NOT_SET) |
Definition at line 164 of file aihand.cpp.
| anonymous enum |
Additional data needed for the AI rates calculation.
| Enumerator | |
|---|---|
| AI_RATE_SCI | |
| AI_RATE_TAX | |
| AI_RATE_LUX | |
| AI_RATE_COUNT | |
Definition at line 155 of file aihand.cpp.
| enum celebration |
| Enumerator | |
|---|---|
| AI_CELEBRATION_UNCHECKED | |
| AI_CELEBRATION_NO | |
| AI_CELEBRATION_YES | |
Definition at line 157 of file aihand.cpp.
| void dai_calc_data | ( | const struct player * | pplayer, |
| int * | trade, | ||
| int * | expenses, | ||
| int * | income | ||
| ) |
Returns the total amount of trade generated (trade) and total amount of gold needed as upkeep (expenses).
Definition at line 111 of file aihand.cpp.
Referenced by dai_action_value_unit_vs_city(), dai_choose_diplomat_offensive(), dai_diplomat_bribe_nearby(), dai_manage_taxes(), dai_spend_gold(), dai_upgrade_units(), and find_city_to_diplomat().
Activities to be done by AI before human turn.
Here we just move the units intelligently.
Definition at line 731 of file aihand.cpp.
Referenced by cai_do_first_activities(), texwai_first_activities(), and twai_first_activities().
Activities to be done by AI after human turn.
Here we respond to dangers created by human and AI opposition by ordering defenders in cities and setting taxes accordingly. We also do other duties.
We do not move units here, otherwise humans complain that AI moves twice.
Definition at line 757 of file aihand.cpp.
Referenced by cai_do_last_activities(), texwai_last_activities(), and twai_last_activities().
Change the government form, if it can and there is a good reason.
Definition at line 689 of file aihand.cpp.
Referenced by dai_do_last_activities().
|
static |
Handle spaceship related stuff.
Definition at line 91 of file aihand.cpp.
Referenced by dai_do_last_activities().
Set tax/science/luxury rates.
TODO: Add general support for luxuries: select the luxury rate at which all cities are content and the trade output (minus what is consumed by luxuries) is maximal. For this we need some more information from the city management code.
TODO: Audit the use of pplayer->ai.maxbuycost in the code elsewhere, then add support for it here.
This function first determins the minimum tax rate (rate_tax_min) and a tax rate for a balanced treasury (rate_tax_balance). Similarily, the science rates are determiend (rate_sci_min and rate_sci_balance). Considering the minimum rates for tax and science the chance for celebrations is checked. If celebration is possible for more than half of the cities, the needed luxury rate is saved as rate_lux_min_celebrate. For celebration some reserves are defined (see turns_for_rapture).
At the end the results are compared and the rates are selected as:
At the end the remaining is divided on science/gold/luxury depending on the AI settings.
Definition at line 198 of file aihand.cpp.
Referenced by dai_do_last_activities().