Enemy Diplomats

Hoover Dam

Chieftain
Joined
Sep 29, 2022
Messages
4
There are conflicting reports about them. Many players have never seen one in their life. Any definitive info about when and how the AIs build and use them? Supposedly the AIs can even sometimes use ordinary units for bribery.

There is some functionality present, but to see it in action without editing the save game files and granting the AIs Diplomats seems exceedingly rare. Even then the Diplomats seem to be used only much like the Caravans, which is to say instantly teleported to other cities and used exclusively on other AIs.

Is there some bug preventing Diplomats from being employed by the AIs the way they are in later editions of the game? Or is it one of these deleted functions that sometimes get enabled by glitches? Or are the conditions for AIs to decide to employ Diplomats just highly unlikely to arise in normal game play?
 
Last edited:
>used exclusively on other AIs

Actually, they are used exclusively on the human player.

AI rarely builds them and even when it finished one, it can disband him and it will get shields back, if conditions to use him is not ok.

To build diplomat, AI should be at war with you, you should be not Barbarians, there should be 0 diplomats in production by this civ, and the human player should have some cities on the same continent as AI and AI defense on this continent should be not 0,
then game called random block of 16 civ. advances (one of 5 possible blocks: 0..16,17..32 etc.) and if there are some advances in this block which you know and AI doesn't know, then AI sets its desire to build diplomat to: AI number of techs - your number of techs + 10, but not less than 5 and not more than 10. The less the better (AI selected produciton with smallest desire).

Then, there's some conditions to actually use a diplomat. Cannot say about them now, but you can find them in source code of darkpanda's JCivED, I think. I only can say that if conditions are not met, AI will disband a diplomat and will get shields for it back.

Play style is important, probably. I saw some bribing by non-diplomat units, but never saw an AI diplomat. Maybe I saw "AI build a first diplomat" message in replay, though.
 
Last edited:
Actually, they are used exclusively on the human player.
Are they? I may be misremembering things, or maybe editing the save game files or some glitch messed things up.
To build diplomat, AI should be at war with you, you should be not Barbarians, there should be 0 diplomats in production by this civ, and the human player should have some cities on the same continent as AI and AI defense on this continent should be not 0,
then game called random block of 16 civ. advances (one of 5 possible blocks: 0..16,17..32 etc.) and if there are some advances in this block which you know and AI doesn't know, then AI sets its desire to build diplomat to: AI number of techs - your number of techs + 10, but not less than 5 and not more than 10. The less the better (AI selected produciton with smallest desire).

Then, there's some conditions to actually use a diplomat. Cannot say about them now, but you can find them in source code of darkpanda's JCivED, I think. I only can say that if conditions are not met, AI will disband a diplomat and will give shields for it back.
I may be dense, but I will need plain English to understand any of this.
Play style is important, probably. I saw some bribing by non-diplomat units, but never saw an AI diplomat. Maybe I saw "AI build a first diplomat" message in replay, though.
So, in plain English, why most gamers never see any Diplomats doing anything or bribery by other units despite playing this game for years?
 
I do remember seeing some diplomat that in the AI turn comes out of nowhere, in fact, I remember that one appeared from a terrain with fog of war near my city.

It has also happened to me with some diplomat of the barbarians.
 
So, in plain English, why most gamers never see any Diplomats doing anything or bribery by other units despite playing this game for years?
Because the conditions for AI to create (and especially to actually use) a diplomat a very rarely met. Like, the similar story with barbarian chariot: if you play the game in typical style, you will see it very, very rarely. Or with "admired city" event. Only even rarer.

Or are the conditions for AIs to decide to employ Diplomats just highly unlikely to arise in normal game play?
This.

Man, my grammar sometimes is atrocious, but I think you can understand what I wrote. Like, in some pseudo code:
player NOT barbarians
AND diplomacy bit "peace" between you and AI is 0
AND "player is near" variable is 1 (it's set to 1 at the beginning of turn, if on some continent you have at least 2 cities and AI civ on this continent has non-zero defense power).
AND number of diplomats in production in all cities of AI civ is 0
AND in random chunk from civ. advances list (one of 5: 1..16, 17..32, 33..48, 49..64, 65..80) there are some civ. advances that you know but AI civ doesn't know
THEN set "desire to build" to:
number of techs (AI civ) - number of techs (your civ) + 10
if this number is less than 5, set it to 5
if this number is more than 10, set it to 10
if result desire is less than any other option, AI will select to build a diplomat.
For comparison: desire to build City Walls in the capital is 4. Desire to build Temple in a city with civil disorder is -3.

AI builds diplomats to steal civ. advances from the player, that's why conditions are this way. AI diplomat tries GoTo to closest city, if this city is near, or else it disbands. In normal game AI "teleports" its diplomat to outskirts of your city (if some conditions met). But if you had added diplomat in editor, it can GoTo to a city of other AI civ, if this city is closer. It there's no tech to steal, it will sabotage. It also can bribe units on its way.
 
Last edited:
I can confirm that in my almost 30 years of playing I have only seen an AI diplomat move around like a normal unit on the map once. It was a Chinese diplomat, very early in the game. A few times I have also seen diplomats sneak into my cities to steal and sabotage from adjacent squares containing other AI units of the same civ. As if the diplomat is being teleported from its home city to the unit's square and then moves into my city from there. I have even seen the AI do that through a loitering bomber. I haven't witnessed this in decades, however. Back then, I might have been playing version .01. Maybe something changed between versions?
 
from JCivED source code:
Java:
//seg007_17F8:
if(city.getCurrentProductionID() == 26) { // AI just produced a Diplomat
//TODO:
// find a player city, that didn't have tech stolen this turn,
// and which has a city or unit on the same continent (diplomat not on ocean, of course)

//seg007_1991:
//if city is more than 3 squares away, or player at peace with AI civ: reimburse the diplomat (cheating AI!)
//otherwise, create a Diplomat on the position of nearest city/unit and assign its GoTo to player city
}

I tested as Russians on Earth on difficulty 1 (warlord), version .05, dosbox. I never made peace with anybody and I built city walls in all cities because I did not attack enemy militias and phalanx near my cities. All the way until the end of XVIII century, I detected AI producing diplomat only twice (both times by French), and only once it was finished. So this is a very rare event. Replay:
1120 BC: French produce first Diplomat.
My closest city was 4 squares away from the closest French city and 8 squares away from Paris (which produced that diplomat).

Then I tried to force AI (with JCivED) to produce diplomats in its cities, but still no luck! Sometimes I can even see as AI disbands them (you can see diplomat in a city for just a blink). They are disbanded even when AI has some units near my cities. I should look closely what exactly conditions are for diplomat to not be disbanded and reimbursed.

EDIT:
I loaded my test save file in .01 and... AI spawn diplomats!! So there's some bug in .05 (and .03 and .04)! But I cannot find any error in the code...
 
Last edited:
But if you had added diplomat in editor, it can GoTo to a city of other AI civ, if this city is closer. It there's no tech to steal, it will sabotage. It also can bribe units on its way.
What are the limits of their power? Could they instigate revolts in cities, at least in theory, perhaps when some glitch happens, or is it totally impossible? There are some reports of them doing that.
I loaded my test save file in .01 and... AI spawn diplomats!! So there's some bug in .05 (and .03 and .04)! But I cannot find any error in the code...
So how often do they actually attack human player’s cities when this routine works properly? Probably still hardly ever? If somebody is going to patch this consider making them as ubiquitous as in Civilization II, at least as an option.
 
I think I found the cause of the bug. But dunno about how easy it will be to fix it.
You see, when the game spawns a produced unit, it specially checks that that unit is not a diplomat (because diplomat should be spawned later, at the same tile with some other AI units on outskirts of your city). BUT after that, game checks that spawned AI unit is not -1: for caravan trade cheat, for nuclear talks after 1st nuclear was produced, and also for diplomat spawn logic! (in this order: caravan, diplomat, nuke) But diplomat was not spawned before, so the spawned unit index is -1, so the program never goes into this branch.

Easiest fix will be to remove this condition, but then game will spawn 2 diplomats: one in a city itself and another - according to rules. Should check how it works in v01... But proper patch is to change places of logic for diplomat and nuclear, it will be 671 byte patch even if everything will be ok. I don't see any easier way (for now?)
EDIT: according to darpanda's code, in v01 game does NOT check that any unit was created (not -1) for: AI caravan, AI diplomat, AI nuke...

Another possible (easier, but ugly) solution:

you see, logic goes this way:
if (human_player OR not diplomat)
id = spawn_unit();
if (replay_entry is empty)
write_replay();
set "vet" flag if barracks;
then conditions for settlers (-1 population, disband city and kill civ if needed);

what we can do:
1) move replay logic up, before unit spawn - order is not really matter,
2) if condition "not diplomat" is not true, let's go right into logic of diplomat spawning!
We will skip conditions for settlers this way, but this is not really matter (diplomat is not settlers)
But we also will skip veteran flag condition, and that's not very ok, even though diplomat got nothing from vet status (its power 0 anyway).
All in all, this is a pretty ugly solution.

Well, possible final verdict: I think it's not really matter if nuke was actually produced to change diplomacy status timer. So, we can use -1 condition only for caravan. Especially that it was already this way for diplomat and nuke in v.01. It can be easy to fix, I think... New conditions in v03-05 are especially bad, because AI doesn't even change production in this case (if produced unit is -1), and because of that, when AI reaches the unit limit in versions 03,04,05, it will not change production in a city!
 
Last edited:
To fix the bug, go to this address in civ.exe:
v05 en: 0xe86a
v04 en: 0xe056
v03 en: 0xe050
(or, for any of these versions, you can search this one-time sequence: e9 55 03 b8 1c 00)

and change
09 55 03
to
09 b5 00

Patch for JCivED is on the way. When it will be ready, I'll create the new thread, so this info will not be lost.
 
Last edited:
Does the 'nuke' status for the AI somehow affect the player besides the message at the start of diplomacy ('Our words are backed with nuclear weapons')? If not, and if I understand your findings correctly, this patch shouldn't be a problem. But if the same logic is used for the opposite situation, 'player builds nuke, AI changes attitude', I think it might break parts of the diplomacy.
 
Game does not change nuke status here, it's just set "call player" timer to -1 (so AI king can tell you as soon as he can about how NUCLEAR he is).

Everything's ok, I patched this so now game checks "some unit was spawned" only for caravan. Civilized guys/civilized Sid fixed bug with creation of trade route by unit number -1 (i.e. last unit of previous civ), but all other stuff that happens here is plain wrong (diplomat, change production) or is just not important (first nuke rule). They should NOT add this check for diplomat and for "change production". Because it's definitely not ok when AI reached 127 unit limit and cannot change production in its cities. It could before, in v01.

The only problem left is "set diplomacy timer", but it was this way in v01 anyway, so no problem, and it's extremely rare for AI to reach the unit limit and then to complete a nuke (and to fail to add it because of the limit) and to have exactly 1 nuke after that. Well, AI will set diplomacy timer to -1 every time when this will happen, so what? Not a big deal.
 
Last edited:
So how often do they actually attack human player’s cities when this routine works properly? Probably still hardly ever? If somebody is going to patch this consider making them as ubiquitous as in Civilization II, at least as an option.
Well, in my current game with the patch the Zulus stole a tech and keep sending diplomats to try and sabotage the same city. So, compared to never seeing them in 20 years with version .05, this is actually pretty often.
 
In what difficulty?
Very interesting... This changes radically the gameplay of civilization.

Is diplomatic actions more frequent than in the .01 version?
 
Last edited:
Difficulty is Emperor, as for your second question, I can't really tell. As I said, I haven't played .01 in decades. But if it's the same function, frequency should also be the same.
 
@Mize
Thank you very much for the information.
Could you send that saved game to test it?
 
Last edited:
Relatedly, I remember seeing some rare condition where a barbarian diplomat may sabotage your city.

I think it might be if the only land square adjacent to the diplomat (including ones occupied by units) is your city.

Or it might have been more esoteric, like a two-tile island or a diplomat surrounded by 8 cities. Sorry I can't remember the details!
 
Relatedly, I remember seeing some rare condition where a barbarian diplomat may sabotage your city.

I think it might be if the only land square adjacent to the diplomat (including ones occupied by units) is your city.

Or it might have been more esoteric, like a two-tile island or a diplomat surrounded by 8 cities. Sorry I can't remember the details!

Your city has to be empty too. And there has to be another barbarian unit nearby, preferably on the other side of the city, opposite of the diplomat.
 
@Mize
Thank you very much for the information.
Could you send that saved game to test it?
Sorry, but that save is long gone. But I'm pretty sure the conditions could be reproduced. You just have to apply the hack, let a few AI players build close to you, be more developed than they are and go to war (they won't steal unless they are at war). I suspect this would be easier to achieve on lower difficulties.
 
Top Bottom