Freeciv-3.3
|
#include <stdarg.h>
#include <string.h>
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "rand.h"
#include "shared.h"
#include "support.h"
#include "aisupport.h"
#include "city.h"
#include "diptreaty.h"
#include "events.h"
#include "game.h"
#include "packets.h"
#include "player.h"
#include "nation.h"
#include "research.h"
#include "spaceship.h"
#include "tech.h"
#include "unitlist.h"
#include "citytools.h"
#include "diplhand.h"
#include "maphand.h"
#include "notify.h"
#include "srv_log.h"
#include "advdata.h"
#include "advtools.h"
#include "aitraits.h"
#include "handicaps.h"
#include "daicity.h"
#include "daidata.h"
#include "dailog.h"
#include "daimilitary.h"
#include "daiplayer.h"
#include "daiunit.h"
#include "daidiplomacy.h"
Go to the source code of this file.
Macros | |
#define | LOG_DIPL LOG_DEBUG |
#define | LOG_DIPL2 LOG_DEBUG |
#define | BIG_NUMBER 100000 |
#define | TURNS_BEFORE_TARGET 15 |
Variables | |
static bool | diplomacy_verbose = TRUE |
#define BIG_NUMBER 100000 |
Definition at line 73 of file daidiplomacy.c.
Definition at line 68 of file daidiplomacy.c.
Definition at line 69 of file daidiplomacy.c.
#define TURNS_BEFORE_TARGET 15 |
Definition at line 79 of file daidiplomacy.c.
Clear old clauses from the treaty between players
Definition at line 1232 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions(), dai_diplomacy_first_contact(), and dai_share().
|
static |
Calculate a price of a tech. Note that both AI players always evaluate the tech worth symmetrically This eases tech exchange. is_dangerous returns ig the giver is afraid of giving that tech (the taker should evaluate it normally, but giver should never give that)
Definition at line 223 of file daidiplomacy.c.
Referenced by dai_goldequiv_clause(), and suggest_tech_exchange().
|
static |
AI to declare war.
ait | AI type of the player declaring war |
pplayer | Player declaring war |
target | Player to declare war to |
Definition at line 1313 of file daidiplomacy.c.
Referenced by dai_go_to_war(), and dai_revolution_start().
Send a diplomatic message. Use this instead of notify directly because we may want to highligh/present these messages differently in the future.
Definition at line 103 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions(), dai_diplomacy_first_contact(), dai_go_to_war(), dai_goldequiv_clause(), dai_incident_war(), dai_treaty_evaluate(), dai_treaty_react(), and war_countdown().
Do diplomatic actions. Must be called only after calculate function above has been run for all AI players.
Only ever called for AI players.
Definition at line 1596 of file daidiplomacy.c.
Referenced by cai_diplomacy_actions(), and texwai_diplomacy_actions().
Calculate our diplomatic predispositions here. Don't do anything.
Only ever called for AI players and never for barbarians.
This is called at the start of a new AI phase. It's not called when a game is loaded. So everything calculated here should be put into the savegame.
Definition at line 1018 of file daidiplomacy.c.
Referenced by dai_data_phase_begin().
void dai_diplomacy_first_contact | ( | struct ai_type * | ait, |
struct player * | pplayer, | ||
struct player * | aplayer | ||
) |
What to do when we first meet. pplayer is the AI player.
Definition at line 964 of file daidiplomacy.c.
Referenced by cai_diplomacy_first_contact(), and texwai_diplomacy_first_contact().
|
static |
Suggest a treaty. pplayer is the (AI) player suggesting the treaty. If to_pplayer, then aplayer is giver in the clause, else pplayer is.
Definition at line 942 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions(), dai_diplomacy_first_contact(), dai_share(), and suggest_tech_exchange().
|
static |
Go to war. Explain to target why we did it, and set countdown to some negative value to make us a bit stubborn to avoid immediate reversal to ceasefire.
Definition at line 1346 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions().
|
static |
Evaluate gold worth of a single clause in a treaty. Note that it sometimes matter a great deal who is giving what to whom, and sometimes (such as with treaties) it does not matter at all. ds_after means a pact offered in the same treaty or current diplomatic state
Definition at line 297 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions(), dai_diplomacy_first_contact(), dai_treaty_accepted(), and dai_treaty_evaluate().
|
static |
How much is a tech worth to player measured in gold
Definition at line 157 of file daidiplomacy.c.
Referenced by compute_tech_sell_price().
void dai_incident | ( | struct ai_type * | ait, |
enum incident_type | type, | ||
enum casus_belli_range | scope, | ||
const struct action * | paction, | ||
struct player * | receiver, | ||
struct player * | violator, | ||
struct player * | victim | ||
) |
Handle incident caused by violator
Definition at line 1986 of file daidiplomacy.c.
Referenced by cai_incident(), and texwai_incident().
|
static |
Nuclear strike against victim.
Definition at line 2135 of file daidiplomacy.c.
Referenced by dai_incident().
|
static |
Nuclear strike against someone else.
Definition at line 2151 of file daidiplomacy.c.
Referenced by dai_incident().
|
static |
Somebody else than victim did nuclear strike against self.
Definition at line 2163 of file daidiplomacy.c.
Referenced by dai_incident().
|
static |
Called when someone caused an incident to make the receiver lose AI love. Make the victim angry at the violator. Twice as angry if this was bad enough to cause International Outrage. Make the rest of the world a bit angry if the violator did this to themself. Twice as angry if the violator did it to someone else.
receiver | the player that receives information about the incident |
violator | the player that caused the incident |
victim | the victim of the incident |
scope | the range of the Casus Belli that caused this |
how_bad | a badness score for the incident |
Definition at line 2185 of file daidiplomacy.c.
Referenced by dai_incident().
War declared against a player. We apply a penalty because this means they are seen as untrustworthy, especially if past relations with the victim have been cordial (betrayal).
Reasons for war and other mitigating circumstances are checked in calling code.
Definition at line 2214 of file daidiplomacy.c.
Referenced by dai_incident().
Are we going to be declaring war in a few turns time? If so, go on a war footing, and try to buy out as many units as possible.
Definition at line 1971 of file daidiplomacy.c.
Referenced by dai_city_choose_build(), dai_manage_cities(), dai_manage_taxes(), and dai_spend_gold().
|
static |
Checks if player1 can agree on ceasefire with player2 This function should only be used for ai players
Definition at line 208 of file daidiplomacy.c.
Referenced by dai_goldequiv_clause().
Revolution start callback for default AI.
ait | AI type of the player revolting |
pplayer | Player revolting |
Definition at line 1445 of file daidiplomacy.c.
Referenced by cai_revolution_start(), and texwai_revolution_start().
|
static |
Offer techs and stuff to other player and ask for techs we need.
Definition at line 1253 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions().
void dai_treaty_accepted | ( | struct ai_type * | ait, |
struct player * | pplayer, | ||
struct player * | aplayer, | ||
struct treaty * | ptreaty | ||
) |
This function is called when a treaty has been concluded, to deal with followup issues like comments and relationship (love) changes.
pplayer is AI player, aplayer is the other player involved, ptreaty is the treaty accepted.
Definition at line 744 of file daidiplomacy.c.
Referenced by cai_treaty_accepted(), and texwai_treaty_accepted().
void dai_treaty_evaluate | ( | struct ai_type * | ait, |
struct player * | pplayer, | ||
struct player * | aplayer, | ||
struct treaty * | ptreaty | ||
) |
pplayer is AI player, aplayer is the other player involved, treaty is the treaty being considered. It is all a question about money :-)
Definition at line 624 of file daidiplomacy.c.
Referenced by cai_treaty_evaluate(), and texwai_treaty_evaluate().
|
static |
Comments to player from AI on clauses being agreed on. Does not alter any state.
Definition at line 701 of file daidiplomacy.c.
Referenced by dai_treaty_accepted().
|
static |
Calculate our desire to go to war against aplayer. We want to attack a player that is easy to beat and will yield a nice profit.
This function is full of hardcoded constants by necessity. They are not macros since they are not used anywhere else.
Definition at line 803 of file daidiplomacy.c.
Referenced by dai_diplomacy_begin_new_phase().
|
static |
Returns an enemy player to 'us' allied with 'them' if there is one.
Definition at line 276 of file daidiplomacy.c.
Referenced by dai_goldequiv_clause().
This is your typical human reaction. Convert lack of love into lust for gold.
Definition at line 124 of file daidiplomacy.c.
Referenced by dai_goldequiv_clause().
|
static |
Convert clause into diplomatic state
Definition at line 139 of file daidiplomacy.c.
Referenced by dai_treaty_accepted(), and dai_treaty_evaluate().
Avoid giving pplayer's vision to non-allied player through aplayer (shared vision is transitive).
Definition at line 183 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions(), dai_goldequiv_clause(), and dai_share().
|
static |
Find two techs that can be exchanged and suggest that
Definition at line 1159 of file daidiplomacy.c.
Referenced by dai_share().
|
static |
Do diplomatic actions. Must be called only after calculate function above has been run for all AI players.
Only ever called for AI players and never for barbarians.
When the adip->coundown variable is set to a positive value, it counts down to a declaration of war. When it is set to a value smaller than -1, it is a countup towards a "neutral" stance of -1, in which time the AI will refuse to make treaties. This is to make the AI more stubborn.
Definition at line 1472 of file daidiplomacy.c.
Referenced by dai_diplomacy_actions().
Definition at line 76 of file daidiplomacy.c.
Referenced by dai_diplo_notify(), and dai_goldequiv_clause().