Advertisement
Civilization Fanatics' Center  

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Strategy & Tips

Reply
 
Thread Tools
Old Oct 17, 2007, 07:25 PM   #1
Bhruic
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 counter-spying. Counter-spying 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 counter-intelligence 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 counter-intelligence 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 percentage-wise, 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 counter-intelligence 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 percentage-wise, they have a 0.6% chance of detecting our spy.

Bh

Last edited by Bhruic; Oct 17, 2007 at 10:20 PM.
Bhruic is offline   Reply With Quote
Old Oct 17, 2007, 07:59 PM   #2
_alphaBeta_
King
 
_alphaBeta_'s Avatar
 
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 mouse-over 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 counter-espionage 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?
_alphaBeta_ is offline   Reply With Quote
Old Oct 17, 2007, 08:03 PM   #3
KMadCandy
giggling permanoob
 
KMadCandy's Avatar
 
Join Date: Oct 2005
Location: Peepsville
Posts: 3,991
thank you! so basically i got really ultra lucky catching a spy near a city where i was spy-less 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.
KMadCandy is offline   Reply With Quote
Old Oct 17, 2007, 09:00 PM   #4
slaze
Deity
 
Join Date: Nov 2006
Location: california
Posts: 2,287
Question. You mention this formula...
Quote:
Originally Posted by Bhruic View Post
Note that the:
((EISM * REP) + EISM + EIC + EICM + EIRM)
part of the formula is capped at a range of 0..100.
...but then you use this formula...
Quote:
= ((EISM * REP) + EIC + EICM + EIRM) * ESIM
...What is the top formula used for? Or is it just the bottom?


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:
Originally Posted by _alphaBeta_ View Post
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.
Quote:
Originally Posted by KMadCandy View Post
so once i have a security bureau in a city, a spy standing there is wasting her time?
It seems so. No more multiple spies per city anymore. Whoops
slaze is offline   Reply With Quote
Old Oct 17, 2007, 09:11 PM   #5
Roland Johansen
Deity
 
Roland Johansen's Avatar
 
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,281
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.
Roland Johansen is offline   Reply With Quote
Old Oct 17, 2007, 10:20 PM   #6
Bhruic
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
Bhruic is offline   Reply With Quote
Old Oct 17, 2007, 10:23 PM   #7
Bhruic
Emperor
 
Join Date: Nov 2005
Posts: 1,457
Quote:
Originally Posted by KMadCandy View Post
EIC is always 0 or 15?
EIC is always 15 - if it's used. The "0" I used in that one example was to indicate that EIC wasn't used for that particular example, so wasn't factored into the equation.

Bh
Bhruic is offline   Reply With Quote
Old Oct 18, 2007, 04:18 AM   #8
Roland Johansen
Deity
 
Roland Johansen's Avatar
 
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,281
Quote:
Originally Posted by Bhruic View Post
Sorry, the second EISM in that one formula was a typo. I'll correct the original post.

Bh
Ok, with so many variables, that is bound to happen.

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.
Roland Johansen is offline   Reply With Quote
Old Oct 18, 2007, 04:31 AM   #9
reknaw
the Hopeless
 
reknaw's Avatar
 
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.
reknaw is offline   Reply With Quote
Old Oct 18, 2007, 04:34 AM   #10
Roland Johansen
Deity
 
Roland Johansen's Avatar
 
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,281
Quote:
Originally Posted by reknaw View Post
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.
I've read a report of this happening and there is nothing in the article that indicates that the stack protects the spy.

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.
Roland Johansen is offline   Reply With Quote
Old Oct 18, 2007, 05:09 AM   #11
Bhruic
Emperor
 
Join Date: Nov 2005
Posts: 1,457
Quote:
Originally Posted by Roland Johansen View Post
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?
I think so, yes. I just mention the "capping" effect because it's in the code... You're right that standard values will never exceed the range.

Quote:
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.
No, there's no evidence that multiple spies have any effect on things. Perhaps he simply didn't run enough tests for the randomness of it to truly factor in?

Quote:
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?
No, they changed it in 3.13 so that spies can't be caught if they are in a ship.

Bh
Bhruic is offline   Reply With Quote
Old Oct 18, 2007, 05:18 AM   #12
Bhruic
Emperor
 
Join Date: Nov 2005
Posts: 1,457
Quote:
Originally Posted by _alphaBeta_ View Post
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?
The chance of success for a spy mission is an almost identical formula. In fact, it is an identical formula, although it's for the chance to be detected, not the chance to be successful.

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.
Bhruic is offline   Reply With Quote
Old Oct 18, 2007, 05:37 AM   #13
Roland Johansen
Deity
 
Roland Johansen's Avatar
 
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,281
Quote:
Originally Posted by Bhruic View Post
No, there's no evidence that multiple spies have any effect on things. Perhaps he simply didn't run enough tests for the randomness of it to truly factor in?
Maybe, but seeing those numbers, it is very unlikely (although spearman can win against tanks ). Maybe it was changed in 3.13 and the tests are from an older version.

Quote:
Originally Posted by Bhruic View Post
No, they changed it in 3.13 so that spies can't be caught if they are in a ship.
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.
Roland Johansen is offline   Reply With Quote
Old Oct 18, 2007, 05:54 AM   #14
watarimono
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.
watarimono is offline   Reply With Quote
Old Oct 18, 2007, 06:37 AM   #15
pumpkin
Chieftain
 
pumpkin's Avatar
 
Join Date: Nov 2006
Posts: 39
Quote:
Originally Posted by reknaw View Post
I've been toying with the idea of including multiple spies in my SoDs to replace accuracy seige weapons...
I don't understand, what would you use the spies for in the above case?
pumpkin is offline   Reply With Quote
Old Oct 18, 2007, 06:56 AM   #16
Roland Johansen
Deity
 
Roland Johansen's Avatar
 
Join Date: Apr 2003
Location: the Netherlands
Posts: 4,281
Quote:
Originally Posted by pumpkin View Post
I don't understand, what would you use the spies for in the above case?
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.
Roland Johansen is offline   Reply With Quote
Old Oct 18, 2007, 08:17 AM   #17
reknaw
the Hopeless
 
reknaw's Avatar
 
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.
reknaw is offline   Reply With Quote
Old Oct 18, 2007, 08:47 AM   #18
UncleJJ
Deity
 
UncleJJ's Avatar
 
Join Date: Jun 2006
Location: London
Posts: 2,221
Quote:
Originally Posted by Roland Johansen View Post
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.
This is the most overpowered use of a spy and EPs in my opinion. It is particularly bad in the late middle ages when a Castle and Walls giving 100% protection can be reduced to nought for a turn for just a few EPs. The alternative use of catapults to bombard the defence will only reduce the defence by 2% per turn per catpult or 4% with accuracy, so that's a long wait or a lot of catapults.

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
UncleJJ is offline   Reply With Quote
Old Oct 18, 2007, 10:17 AM   #19
LlamaCat
Emperor
 
LlamaCat's Avatar
 
Join Date: Dec 2005
Posts: 1,212
it would be nice if someone could write a spy summary in English
LlamaCat is offline   Reply With Quote
Old Oct 18, 2007, 11:17 AM   #20
Krikkitone
Deity
 
Join Date: Apr 2004
Posts: 6,891
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
__________________
Improvement Ideas
City States:http://forums.civfanatics.com/showth...5#post11296685
Miscelaneous Ideas:http://forums.civfanatics.com/showpo...&postcount=403

Last edited by Krikkitone; Oct 18, 2007 at 11:24 AM.
Krikkitone is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Strategy & Tips > Spy detection

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stealth = No Submarine Detection???? SickCycle Civ4 - General Discussions 4 Aug 23, 2007 07:54 AM
% of spy detection MaxRiga Civ4 - Creation & Customization 0 Jun 25, 2006 03:10 PM
Flu Detection Chip Eastern Knight Off-Topic 1 Oct 05, 2003 03:10 AM
Virus Detection King of Camelot Off-Topic 11 Jun 04, 2002 06:32 AM


Advertisement

All times are GMT -6. The time now is 05:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR