# A study of espionage mission

#### thefusilier

##### Chieftain
Does the AI actually use spies for sure?

#### TimBentley

##### Deity
They use propaganda and sabotage production, for sure.

#### AutomatedTeller

##### Frequent poster
I have caught spies in my capitol before.

#### stalin83

##### Chieftain
Nice article.Tho I was wondering if there were any counter-intel methods a republic could use to guard against commie spies?the old civ2 had spy-units guard freindly cities against enemy spies.

#### soujourner

##### Chieftain
Very useful information and well deserving of the star rating.

Being relatively new to this game, I fear that if my spy is unsuccessful and it caught by a rival that this will trigger a war that I am not prepared to fight.

Does anyone have any information regarding this?

#### Aabraxan

##### Mid-level Micromanager
Yes, if spying is unsuccessful, it can trigger a war.

#### woodandearth

##### Chieftain
This makes it easier to flip a city of size 4n, than a city of size 4n-1, and in some situation even 4n-2. If the chance of confusing 1 citizen is greater than 1/3, it will be easier to flip a city of size 4 than 2.

I have some question. Why a 4n-size city is easier to flip than a (4n-1)-size one? According to the "at least 3/4 citizens persuaded" condition, to flip both a 4n-size city and a (4n-1)-size city, we need to persuade at least n citizens. It is not easier, just the same.

I do not understand the last example that size 4 easier than size 2, either. For size 4, we need to persuade 3 citizens while for size 2 need 2. Isn't it more difficult to persuade 3 than to persuade 2?

#### CKS

##### Deity
To flip a city of size 4 you need to persuade 3 citizens. To flip a city of size 3 you also need to persuade 3 citizens. However, you have more tries at persuading citizens when the city is size 4. Suppose the chance of persuading a citizen was 25%. Then the chance of persuading all 3 citizens in a pop 3 city is .25^3 = 1.56%. To flip a size 4 city of citizens A,B,C, and D we need to persuade one of these combinations: ABC, ABD, ACD, BCD, or ABCD. The chances of each of the first 4 possibilities are .25^3 * .75 = 1.17% and the chance of the last is .25^4 = 0.39%, so the total chance is 3.9%.

For the pop 4 vs pop 2 case, assume the chance of persuading is 50% (it must be more than 1/3, as stated above, and 50% is easy). Then for two citizens the chance of a flip is .5^2 = 25%. For 4 citizens we have .5^4 = 6.25% for every possibility, and 5 possibilities, giving a 31.25% chance of flipping.

#### Spoonwood

##### Grand Philosopher
Yes, if spying is unsuccessful, it can trigger a war.

But when will they declare war if you fail at some espionage mission? What's the probability of them doing so?

#### Spoonwood

##### Grand Philosopher
What I think this article and the comments lack is when it makes sense to attempt an immediate steal, a careful steal, or a safe steal.

If you check out the cost of steals, you'll find that safe steal attempts cost exactly twice of an immediate steal attempt and careful steal attempts cost 1.5 the amount of immediate steal attempts. So, 2 immediate steals cost the same as one safe steal, and 3 immediate steals cost the same as 2 careful steals.

So, we might compare the probability of making the same number of steals for the same amount of cash. Of course, there's more to it, because you might want to steal right away to sell the tech/do an 2-fer or better. And you risk a war declaration. But, let's do that comparison supposing everything else the same.

With just an embassy the probability of at least one of two immediate steals succeeding is (1 - (.68 * .68)) = 53.76%. One safe steal has a probability of 52% of succeeding. So, with just an embassy, immediate steals work out better over the course of enough steals than a safe steal.

With just an embassy, the probability of at least one of three immediate steals succeeding is (1 - (.68 ^ 3)) = 68.56%. The probability of at least one of two careful steals succeeding is (1 - (.56 ^2)) = 68.64%. Thus, over enough steals, careful steals work out better.

With a regular spy, two immediate steals (1 - (.52 ^ 2)) = 72.96%. This is again better than a safe steal at 68%.

With a regular two, three immediate steals (1 - (.52 ^ 3)) = 85.94%. Two careful steals (1 - (.4 ^ 2)) = 84%. Thus, over enough steals, immediate steals work out as less costly.

With a veteran spy, two immediate steals (1 - (.44 ^ 2)) = 80.64 %. This again is better than a safe steal at 76%.

With a veteran spy, three immediate steals (1 - (.44 ^ 3)) = 91.48%. Two careful steals (1 - (.32 ^ 2)) = 89.76%. Thus, over enough steals with a veteran spy, immediate steals work out as less costly.

To summarize, careful steals with just an embassy work out as less costly. Immediate steals work out as less costly with a spy.

Though again, the above ignores the timing of the steal, angering other tribes if you fail at a steal (their attitude towards you gets worse if they catch your representative in the act of trying to steal), or them declaring war.

#### justanick

##### Emperor
Also losing a spy has some costs associated within. Planting a spy takes time and money. Due the failed spy plantation flag it can take many turns in which you will not have a spy. Having a spy however grants you some valuable information with no further costs attached to it. That might outweight the seemingly marginal savings from the cheaper attempt versions.

#### tmn

##### Chieftain
But when will they declare war if you fail at some espionage mission? What's the probability of them doing so?
I suspect it isn't random and works the same as asking their troops to leave.

Also losing a spy has some costs associated within. Planting a spy takes time and money. Due the failed spy plantation flag it can take many turns in which you will not have a spy. Having a spy however grants you some valuable information with no further costs attached to it. That might outweight the seemingly marginal savings from the cheaper attempt versions.
The savings aren't marginal.

An average cost of stealing a tech with probability p would be [price / p]. Here are the multipliers to immediate price:
Code:
Immediately  Carefully  Safely
Embassy      3.1          3.4        3.8
Regular spy  2.1          2.5        2.9
Veteran spy  1.8          2.2        2.6

Now lets account for the spy costs. Assuming you will try to plant a spy every turn, it'll have a success chance of q on the first turn and [q / 3] later. So you will pay once with probability q, twice with probability [(1 - q) * (q / 3)], 3 times with probability [(1 - q) * (1 - q / 3) * (q / 3)] and so on. The average cost will be [price * q + (1 - q) * (q / 3) * SUM[(1 - q / 3) ^ (n - 1) * (n + 1) * price]] = [price * (3 / q - 2)]. That's [4 * price] for regular spy and [3 * price] for veteran.

The probability of a spy not being caught is r = [p / 0.8]. You'll have to make [1 / p] steal attempts per tech on average, so you'll get caught [(1 - r) * (1 / p)] = [1 / p - 1.25] times and will have to replant a spy every time.

This results in the following additional costs per tech (multiplier to a price of one spy):
Code:
Immediately  Carefully  Safely
Embassy      0            0          0
Regular spy  3.3          1.7        0.9
Veteran spy  1.6          0.7        0.2

Here's an example for a veteran spy. Compared to a safe steal, immediate steal saves you 0.8 of an immediate price for 1.4 of a spy price. If a spy costs 70 gold and a steal — 1000 gold, then immediate stealing of a tech will cost you [(1.8 * 1000 + 1.6 * 70) / (2.6 * 1000 + 0.2 * 70)] ~ 73% of gold it would take safely.

The downside is that you are more likely to get caught. And when you do:
- AI might declare a war;
- you have to wait turns to replant the spy;
- catching a spy decreases attitude towards you.

None of those should be a big problem. Weak and peaceful civs won't declare a war even if they catch you. And you can continue espionage missions even if you are at war with that civ.

Because of the lower average cost and lower attempt prices, you get techs faster with immediate steals. Which in turn can get you more money.

Last edited:

#### Spoonwood

##### Grand Philosopher
I suspect it isn't random and works the same as asking their troops to leave.

I don't know why you say that, have you tested it? If it ends up based on reputation, which sounds plausible, this suggests to me that with least aggressive opponents, the probability of them declaring on you ends up the lowest. And with maximum aggressiveness the probability ends up the highest.

An average cost of stealing a tech with probability p would be [price / p].

Oh... duh! Nice. Thank you!

I ran a quick test, and maybe I missed it above, that you can't attempt a steal if you're a war with a tribe without a spy. But, if you have a spy planted, then you can attempt to steal tech during a war.

#### tmn

##### Chieftain
I don't know why you say that, have you tested it?
I haven't tested it, but from my limited experience if AI doesn't declare on eviction they don't declare on any spy fails either. And vice versa.

#### tmn

##### Chieftain
I've corrected my previous post to account for the failed attempts which do not result in spy being caught. That makes spy costs even lower (2.7 -> 1.8).

#### tmn

##### Chieftain
I've found and corrected a mistake in my spy cost calculations (4.5 -> 4 , 3.4 -> 3) and in the "additional costs" table (3.8 -> 3.3, 1.9 -> 1.7, 1.0 -> 0.9, 1.8 -> 1.6).

#### ThesaurusRex

##### Chieftain
spy + government + culture - 5 * units - improvment - capital + nationality
Having a bit of trouble with the math here.

My spy is a Regular, which in Rhye's gives this a value of 0. The government and culture modifiers are 5 and 30. Iroquois has a total of 70 units and the city I'm trying to flip only has 1 harbor, isn't the capital and has none of my nationals.

So I've ended up with 0 + 5 + 30 - 5 * 70 - 0 + 0

High school PEMDAS gives this a result of -315. But if the first 3 variables are meant to be separate from the rest, which feels like it would make sense because they all describe the other guy's stuff, I get 2,100. Same as if I did every operation individually, and that's clearly wrong. But neither of these are percentages, so what is the value supposed to represent?

If the standard order of operations is the right one though then that would mean HAVING a courthouse makes a city slightly easier to flip...? That doesn't seem right either, so this is pretty confusing.

#### justanick

##### Emperor
Iroquois has a total of 70 units
In said city? Only the amount of military units(those that can give a content face in despotism etc.) in the city counts, just like with a regular flip.

Say it is only 3 military units in that city. Than it is 0 + 5 + 30 - 5 * 3 - 0 + 0 = 20. So for each citizen there is a 20% chance to be persuaded. For each citizen a five-sided dice is trown.

The chance for flipping a town of size 2+ is lower than the chance of persuading one citizen, because you need to persuade at least 3/4 or them.

If the standard order of operations is the right one though then that would mean HAVING a courthouse makes a city slightly easier to flip...?
No, less means a lower chance of persuading. In practice propagada may cost about 20000 gold to induce a flip. It is not economical.

In your case countering the 5 + 30 would require either 7 units military police or 3 and a courthouse. In that case the chance of persuading would be zero.

Replies
50
Views
2K
Replies
15
Views
614
Replies
18
Views
888
Replies
6
Views
1K
Replies
178
Views
12K