General  CivBE  Civ5  CivRev  Civ4Col  Civ4  Civ3  Civ2  Civ1  Misc  Market 

Oct 17, 2007, 07:25 PM  #1 
Emperor
Join Date: Nov 2005
Posts: 1,457

Spy detection
This is (hopefully!) a complete summary of how spy detection and interception works. All numbers are assuming an unmodified version of the game. For the sake of consistency, this example will assume that "we" or "us" are the ones spying, and "they" or "them" are the ones defending.
There are a number of variables to take into consideration. The first is the intercept modifer. If we have an Open Borders treaty with them, we have "ESPIONAGE_SPY_NO_INTRUDE_INTERCEPT_MOD", or ESNIIM = 10 (it's stored as 90, but the actual value is used as "100 + ESNIIM"). If not, we have "ESPIONAGE_SPY_INTERCEPT_MOD", or ESIM = 25 (or 75). The next variable is the ratio of total espionage points between us and them. That is the complete total amount of espionage points ever put in, not merely the points we have put into them or vice versa. Let's call our total points as OME, and theirs as TME, and the ratio as REP. The formula for the ratio is: TME / (TME + OME). This number is multiplied by a variable called "ESPIONAGE_INTERCEPT_SPENDING_MAX", or EISM, which is defined as 25. Next is counterspying. Counterspying can be accomplished in two ways  by them having a spy on the square we are on, or by them having built the Security Bureau in the city we are in. If that's the case, that triggers the "ESPIONAGE_INTERCEPT_COUNTERSPY" or EIC, value of 15. Next, is the possibility that they have ran the counterintelligence mission against us. If that's the case, they triggered "ESPIONAGE_INTERCEPT_COUNTERESPIONAGE_MISSION" , or EICM which is defined as 20. And finally, if our spy just moved onto the square, or if we already have a spy on that square, we trigger "ESPIONAGE_INTERCEPT_RECENT_MISSION", or EIRM, value of 15. So to recap: ESNIIM = 10 ESIM = 25 REP = TME / (TME + OME) EISM = 25 EIC = 15 EICM = 20 EIRM = 15 The complete formulas, assuming all values are relevant is: ((EISM * REP) + EIC + EICM + EIRM) * ESNIIM (Open Borders) ((EISM * REP) + EIC + EICM + EIRM) * ESIM (No Open Borders) Note that the: ((EISM * REP) + EIC + EICM + EIRM) part of the formula is capped at a range of 0..100. Once the formula is used to get a number, the game generates a random number from 0..9999. If the random number is greater or equal to the number generated by the formula, then the spy is not discovered. If the random number is less than the number from the formula, the spy is caught. A couple examples to give some concrete numbers: Our spy moves on to their tile where they have a spy. We don't have an open borders treaty with them. They have not run a counterintelligence mission on us. We have generated a total EPs of 1000 over the game, they have generated 3000. REP = TME / (TME + OME) REP = 3000 / (3000 + 1000) REP = 0.75 = ((EISM * REP) + EIC + EICM + EIRM) * ESIM = ((25 * 0.75) + 15 + 0 + 15) * 25 = 1218.75 = 1218 (rounded down) So percentagewise, they have a 12.2% chance of detecting our spy. Another example. Our spy has been sitting on a square for 2 turns, they have no spy on the square, they have not run a counterintelligence mission, and we have an Open Borders treaty with them. Let's reverse the EPs from above (so we have generated 3000, they have generated 1000). REP = TME / (TME + OME) REP = 1000 / (1000 + 3000) REP = 0.25 = ((EISM * REP) + EIC + EICM + EIRM) * ESNIIM = ((25 * 0.25) + 0 + 0 + 0) * 10 = 62.5 = 62 (rounded down) So percentagewise, they have a 0.6% chance of detecting our spy. Bh Last edited by Bhruic; Oct 17, 2007 at 10:20 PM. 
Oct 17, 2007, 07:59 PM  #2 
King
Join Date: Dec 2005
Location: NJ, USA
Posts: 976

Excellent! Finally! Thanks again Bhruic for this writeup. You are the true hero of BTS in my book.
I find it very interesting that the ratio of between you and them is not relevant (the ratio you get when you mouseover other civs' leaderheads). It's rather related to the ratio of the total amount of you've generated against all opponents in the game compared to other civs. Seems counter intuitive to me. Although it allows protection from everyone in case your concentrating all your against one opponent. I'll consider doing that now. I also find it interesting how spies only defend the tile they're sitting on. I thought there would have been some kind of adjacent tile protection as well. So, to increase the chance of finding spies in your territory one should: 1. Close borders 2. Station spies on important tiles. Only one spy helps, anymore are irrelevant. Once a security bureau is present in a city, there's no need for a spy there anymore. 3. Run counterespionage missions Only other question that comes to mind is what influences the % of success when performing an active mission? Do the same rules you've outlined apply? 
Oct 17, 2007, 08:03 PM  #3 
giggling permanoob

thank you! so basically i got really ultra lucky catching a spy near a city where i was spyless for miles.
so the active spy mission "Perform Counterespionage" not only increases the cost of their missions like the pedia says, but also increases my chance of catching them, correct? EIC is always 0 or 15? so once i have a security bureau in a city, a spy standing there is wasting her time? so, my dear friend , when are you pretty please going to write a summary on how to get the best value for your espionage points? the pedia mentions "religions present" as a factor but i didn't find out until yesterday or the day before that you get a bonus for picking a target city with your SR, and get an extra bonus discount for owning the holy city. knowing that i was able to steal two techs from zara, if i hadn't realized it i probably wouldn't have been able to afford the second. and i heard a rumor that the cost is affected (i think it goes down) the more you've spent on active missions? i dunno. anyway, if you (or anybody else who understands the factors) get bored in your copious free time, that would be lovely!
__________________
no those privateers aren't mine. that GG i just got while i'm not at war with anybody? popped him from a hut. 
Oct 17, 2007, 09:00 PM  #4  
Deity
Join Date: Nov 2006
Location: california
Posts: 2,287

Question. You mention this formula...
Quote:
Quote:
Using the bottom formula it seems that that highest probability of detection would be ((25 * 1.0) + 15 + 20 + 15) * 25 = 1875, or 18.8% Although a more realistic number (with equal espionage) might be ((25 * 0.5) + 15 + 20 + 15) * 25 = 1562.5, or 15.6% It's funny cause it feels like I detect alot of enemy spies about one turn into my borders. I'm surprised to see it so low Quote:


Oct 17, 2007, 09:11 PM  #5 
Deity
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,292

Great article. Very useful.
Okay, now to get some intuition for the strength of the various terms in the formula: The basic chance that your spy is caught is a value between 0% and 2.5% when you have open borders and a value between 0% and 6.25% when you have closed borders. This chance is dependent on the total amount of espionage points produced by you and your target civilisation. An enemy spy or the security bureau present in the tile of your spy increases the chance of being caught by 1.5% when you have open borders and 3.75% when you have closed borders. A counterespionage mission performed against you increases the chance of being caught by 2% when you have open borders and 5% when you have closed borders. When one of your spies has just moved or is on the same tile as another one of your spies, then it has a 1.5% increased chance of being caught with open borders and a 3.75% increased chance of being caught with closed borders. These chances are summed up meaning that with open borders, the chance of being caught is a value between 0% and 7.5% and with closed borders, the chance of being caught is a value between 0% and 18.75%.
__________________
If in other sciences we should arrive at certainty without doubt and truth without error, it behooves us to place the foundations of knowledge in mathematics. Last edited by Roland Johansen; Oct 18, 2007 at 04:03 AM. Reason: Clarification of a term in the original post. 
Oct 17, 2007, 10:20 PM  #6 
Emperor
Join Date: Nov 2005
Posts: 1,457

Sorry, the second EISM in that one formula was a typo. I'll correct the original post.
Bh 
Oct 17, 2007, 10:23 PM  #7 
Emperor
Join Date: Nov 2005
Posts: 1,457


Oct 18, 2007, 04:18 AM  #8  
Deity
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,292

Quote:
By the way, if I understand the article correctly, then the term ((EISM * REP) + EIC + EICM + EIRM) would have a value between 0 and 75 and so with the standard values of the variables the capping at a value between 0 and 100 has no effect. Did I understand that correctly? Rince did some tests with the effects of adding multiple defending spies to a tile and there seemed to be a relation between the number of defending spies and the chance to capture a spy. Could it be that the variable EIC is added multiple times for each defending spy? That would explain his results very well and you also notice the effect of capping the mentioned term at a value of 100. Here is the post that I'm referring to: table of spying results. By the way, does movement inside a ship count as movement for the spy? Does movement inside a ship increase the chance of being caught or not?
__________________
If in other sciences we should arrive at certainty without doubt and truth without error, it behooves us to place the foundations of knowledge in mathematics. Last edited by Roland Johansen; Oct 18, 2007 at 04:22 AM. 

Oct 18, 2007, 04:31 AM  #9 
the Hopeless
Join Date: Oct 2007
Location: Queensland.
Posts: 71

Can a spy be caught if it's occupying an enemy tile that also contains your military units? I ask because I've been toying with the idea of including multiple spies in my SoDs to replace accuracy seige weapons, I don't think I would take the chance though if they could all be lost while en route.
__________________
Yes, I do know what my name is spelled backwards. 
Oct 18, 2007, 04:34 AM  #10  
Deity
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,292

Quote:
Some people think that spies are an effective fast way to lower the city defences. The chance of being caught is not that high and can be countered by using multiple spies (although that increases the chance of capturing one of them).
__________________
If in other sciences we should arrive at certainty without doubt and truth without error, it behooves us to place the foundations of knowledge in mathematics. 

Oct 18, 2007, 05:09 AM  #11  
Emperor
Join Date: Nov 2005
Posts: 1,457

Quote:
Quote:
Quote:
Bh 

Oct 18, 2007, 05:18 AM  #12  
Emperor
Join Date: Nov 2005
Posts: 1,457

Quote:
If you recall in my first post, I list "ESPIONAGE_SPY_NO_INTRUDE_INTERCEPT_MOD" and "ESPIONAGE_SPY_INTERCEPT_MOD" as being 10 and 25, respectively? But the actual values in GlobalDefines.xml is 90 and 75, I just handled the fact it does 100 + X (where X is the 90 or 75) by short cutting it. So the formula is identical, just replace the 90 or 75 with the difficulty modifier (DM) for that particular mission. The percentage chance of being detected while performing a mission is: (((EISM * REP) + EIC + EICM + EIRM) * (100 + DM)) / 100 The dividing by 100 is just to get it into percentage form. The chance of being successful, therefore, is: 100  ((((EISM * REP) + EIC + EICM + EIRM) * (100 + DM)) / 100) Bh Last edited by Bhruic; Oct 18, 2007 at 05:24 AM. 

Oct 18, 2007, 05:37 AM  #13  
Deity
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,292

Quote:
Yes, I remember now. It was in the changelog.
__________________
If in other sciences we should arrive at certainty without doubt and truth without error, it behooves us to place the foundations of knowledge in mathematics. 

Oct 18, 2007, 05:54 AM  #14 
Chieftain
Join Date: Oct 2007
Posts: 2

Bhruic, thanks for this information, and the other posters as well.
A spy has no range of detecting other spies, is this correct? The check runs only for the present occupied tile? Since the Security Bureau is in the city, it only checks for enemy spies currently on the city tile, not also the city's cultural borders? I wonder if it would break game balance to have a decreasing effect range for the Security Bureau  limited to the FC perhaps. 
Oct 18, 2007, 06:37 AM  #15 
Chieftain
Join Date: Nov 2006
Posts: 39


Oct 18, 2007, 06:56 AM  #16 
Deity
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,292

A spy can create a 1 turn revolt in a city and then the city loses the defensive culture bonus for that turn. I don't use it, but if you're not so good with siege units or want to do quick attacks with mounted units, then it can be useful.
__________________
If in other sciences we should arrive at certainty without doubt and truth without error, it behooves us to place the foundations of knowledge in mathematics. 
Oct 18, 2007, 08:17 AM  #17 
the Hopeless
Join Date: Oct 2007
Location: Queensland.
Posts: 71

I find lately it can be quite difficult to get XP for seige units, and I rarely have more then 4 accuracy cats, so if I were want a second SoD I'd have to either use more seige units on bombarding, or take extra turns to get to 0%. The spy can do it in one turn, and has the added advantage of preventing whipping and drafting for that turn. Also I have used spies lately to pillage stategic resources that would be too hard to reach with my pillage stack in a timely fashion.
It is a shame that spies can be caught while in the same tile as a SoD, doesn't really make sense to me that they would be able to extract the spy from within an army. EDIT: Oh yeah and the reason I'd have moer than one in the SoD is because they might fail, and even if they succeed they get moved back to my capital afterwards. So yeah probably not going to work for intercontinental combat.
__________________
Yes, I do know what my name is spelled backwards. 
Oct 18, 2007, 08:47 AM  #18  
Deity
Join Date: Jun 2006
Location: London
Posts: 2,221

Quote:
A spy costing 40 hammers and with a 75% chance is a lot better bet than building 8 catapults (costing 50 hammers each plus extra maintenance) and waiting several turns while the defence is reinforced and your stack is counterattacked increasing the WW. The EP points are not even lost if your spy fails so just send 2 or 3 spies into the castle and each has a 75% chance. In my mind it should be lot harder to break down the defences of a Castle and Walls than just the cultural defence of an open city yet as far as I know they're the same. /Rant over Great article. Thank you so much Bhruic for delving into the innermost workings and publishing this in such a concise way. Now I understand what to do... basically make lots of EPs as they help both espionage attack and defence and it doesn't matter too much where you target them. The Espionage system just got a lot easier to manage, as you only need worry about the passive effects and then investing enough against a particular civ if you want to use active missions, defence takes care of itself. If you see a civ spending a lot on espionage you better make some effort to match it or his spies will run riot. The only trouble I have is the total spending number seems to be hidden from the players if the civ is using EPs on missions. What we can see from the glance screen is the ratio of current EPs versus our EPs. If either side has spent a lot of EPs on missions then it is hard to tell what chances of detection will be.
__________________
It's the economy, stupid 1992 Clinton campaign 

Oct 18, 2007, 10:17 AM  #19 
Emperor
Join Date: Dec 2005
Posts: 1,212

it would be nice if someone could write a spy summary in English

Oct 18, 2007, 11:17 AM  #20 
Immortal
Join Date: Apr 2004
Posts: 10,335

What Tag makes the Security Bureau "spy like"?
Is it the fact that it give Espionage Defense? Did a little checking, that is it... if the city has an Espionage defense >0 it acts like a counter spy
__________________
BE second expansion proposals BE Sociopolitical Mechanic (Rebels, Unifying empires and Affinity hatred) Alien upgrades:BE expansion sponsors:Affinity Virtues:Global Terraforming Last edited by KrikkitTwo; Oct 18, 2007 at 11:24 AM. 