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
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