01The shape of it
Espionage is per-relationship and one-directional. Defence is not.
A SpyNetwork exists per directed EmpireView — one for
"my spies against the Darloks", a completely separate one for "the Darlok spies against me". They are
funded separately, staffed separately, and given separate orders. Everything offensive in the system
is scoped this way.
Internal security is the exception. There is one empire-wide security slider, and it defends against every empire at once. That asymmetry is the central economic tension of the system: attacking costs you per target, defending costs you once.
What a network buys you, in rough order of value:
- Passive intelligence — refreshed views of their colonies, their fleet composition, and their tech tree. This comes from having spies, regardless of what you order them to do.
- Stolen technology — at most one tech per turn per target.
- Sabotage — destroyed factories, destroyed missile bases, or incited rebellion.
02The pieces
Four small objects. The spy itself is the smallest.
SpyNetwork
The per-view container. The fields that matter:
| Field | Meaning |
|---|---|
activeSpies | The live spies. Fungible — see below. |
maxSpies | Target headcount. Spending stops dead once reached. |
allocation | 0–20 slider ticks; each tick is 0.5% of empire production. |
allocationBC | Banked BC carried between turns toward the next spy. |
mission | HIDE / ESPIONAGE / SABOTAGE. |
tech | A shadow copy of what you know of their tech tree. |
possibleTechs | Tech IDs currently stealable, recomputed each turn. |
shipViews, fleetView | Known enemy designs and ship counts by hull size. |
lastSpyDate | Year of the last successful report; drives reportAge(). |
threatened | Whether they have demanded you stop. |
Spy
A spy is three integers and nothing else — no name, no age, no experience, no level. And all three are re-rolled from scratch every turn, so spies carry no history whatsoever:
private int fate; // CLEARED | STOPPED private int mission; // UNATTEMPTED | FAILED | SUCCEEDS private int identity; // CAN_FRAME | UNDISCOVERED | WILL_BE_CAUGHT | CAUGHT | CONFESSES
A spy's only persistent property is that it exists. Losing one costs you the BC you paid, not an accumulated asset — which is why the system tolerates a 30% per-turn casualty rate without feeling punitive.
SpyReport
A per-turn, per-view scoreboard, cleared at the start of every turn: spies lost, spies captured, confessed mission, stolen tech, framed empire, sabotage type and count, techs learned. It is what the intelligence report screen renders.
EspionageMission & SabotageMission
Short-lived objects representing one attempt. EspionageMission carries the target system,
one pre-drawn candidate tech per category, and up to two empires available to frame.
SabotageMission carries the type and the resulting damage.
03Paying for it
Spy and security spending are off-the-top taxes on colony production, not colony build categories.
Both come out of each colony's production before anything else is allocated. You never see them in the colony spending sliders; they are levied empire-wide and felt everywhere.
Per-target allocation
allocationPct() = allocation / 20 // slider ticks rawAllocationCostPct() = allocationPct() * 0.10 // max 10% of production allocationCostPct() { if (numActiveSpies() >= maxSpies) return 0; // auto-stop at headcount if (!view.inEconomicRange()) return 0; // no reach, no spending return rawAllocationCostPct(); }
One tick = 0.5% of total planetary production. The sum across all targets is capped at
50%; past that, every network is scaled down proportionally by a spySpendingModifier rather
than any one being cut off.
Cost of a spy
baseSpyCost() = (25 + computerTechLevel * 2) * spyCostMod // race modifier costForNextSpy() { float cost = baseSpyCost(); for (int i = 1; i < activeSpies.size(); i++) cost *= 2; // doubling ladder return cost; }
Two things fall out of this. First, spies get more expensive as your own computer tech grows —
the cost tracks your sophistication, not theirs. Second, because the loop starts at i = 1,
the first and second spy against a given empire cost exactly the same; doubling only
begins with the third. Since two spies is widely the practical optimum, that is a meaningful discount,
and the UI's own projection disagrees with it.
Race modifiers
Three numbers per race: spy cost, internal security, and infiltration. Almost every race is neutral.
| Race | Cost | Security | Infiltration |
|---|---|---|---|
| Darlok | ×0.50 | +0.20 | +0.20 |
| All other stock races | ×1.00 | 0 | 0 |
That single row is the entire Darlok identity, and it is enormous: half-price spies, double the base mission success rate, and free maximum-grade counter-intelligence. Section 06 shows what those numbers do to the dice.
04The three missions
One order per network per turn. The passive intelligence arrives either way.
| Mission | What it does | Risk |
|---|---|---|
| HIDE | Nothing offensive. Spies still infiltrate, and you still receive the full passive intel package. | −0.30 to the detection roll. Against an undefended empire this makes your spies literally uncatchable. |
| ESPIONAGE | Steal at most one technology per turn, chosen by the best successful spy. Optionally frame a third empire for it. | Normal detection. A caught espionage mission breaks an alliance. |
| SABOTAGE | One act per turn: destroy factories, destroy missile bases, or incite rebellion. Requires that you have scouted at least one of their systems. | Normal detection, and the harshest diplomatic penalties. A caught sabotage mission breaks a pact. |
A hidden network still refreshes your view of their colonies (including revealing one previously unknown colony per active spy), still updates their fleet composition, and still updates their tech tree. Against a low-security neighbour, one or two spies parked on HIDE forever is close to a free reconnaissance satellite — which makes it the dominant peacetime play.
Treaty status can override the choice entirely. Under alliance, views and techs refresh
for free and the network persists. Under unity, everything refreshes for free and the
network is force-disbanded: allocation zeroed, spies cleared, maxSpies set to 0.
05The turn cycle
Order matters — notably, spies are recruited before they act.
- Bail out entirely if the target is not in economic range. Nothing happens at all.
- Handle the treaty shortcuts — unity disbands the network, alliance grants free intel.
- Refresh system views (also granted by an active trade route, even with zero spies).
- Spend BC and recruit. A spy bought this turn immediately risks capture on the next step.
- Update the fleet view, stamp
lastSpyDate, refresh the stealable-tech list. - Infiltration roll for every spy — the detection dice. Casualties are removed here.
- File any confession incidents, and check whether the confession breaks a treaty.
- Stop here if anyone confessed, if all spies died, or if the mission is HIDE.
- Mission roll for every surviving spy — the success dice.
- Resolve one espionage or one sabotage attempt from the single best successful spy.
Steps 6 and 9 are two independent rolls against two different modifiers, and conflating them is the easiest way to misunderstand the system. Getting in undetected and succeeding at the job are separate questions, decided by separate numbers.
06The two rolls
Detection is a five-band table. Success is a single threshold.
Roll one — infiltration
Every spy rolls r = random() + securityAdj, where securityAdj is the
target's defensive total. Lower is better for the spy. The table is lifted from the Master of
Orion strategy guide:
At zero enemy security, 30% of your spies die every turn. At +0.30 security that is 60%. At +1.00 every spy confesses every turn. The "exposed" band means the spy survives but will be caught if the mission goes loud — which is why HIDE is safe: the mission never happens.
Roll two — the mission
r = random() + spyInfiltrationAdj(); // the OWNER's offensive total
mission = r <= 0.85 ? FAILED : SUCCEEDS;
Base mission success is 15% per surviving spy per turn. A Darlok, at +0.20, is on 35%. A twenty-level computer-tech lead adds another 0.20. This is the number that makes espionage feel either pointless or oppressive, and it is almost entirely a race-and-tech story.
The tech differential is applied as a penalty to detection only when you are behind, and as a bonus to mission success only when you are ahead. A computer lead never makes your spies harder to catch, and a computer deficit never makes their missions fail more often. Whether that is design or oversight, it means computer tech is purely an offensive espionage stat.
07Counter-intelligence
One slider, four contributors, three separate effects.
overallSecurityAdj() {
adj = totalInternalSecurityPct(); // your spending
if (totalTradeTreaties() == 0)
adj += 0.10; // isolationist bonus
adj += internalSecurityAdj(); // your race
if (spyTechAdvantage() < 0)
adj -= spyTechAdvantage(); // their computer deficit
if (missionIsHide || nothingToSteal)
adj -= 0.30;
return adj;
}
Internal security is bought in ticks, and it is expensive relative to what it buys:
totalInternalSecurityPct() = 2 * securityAllocation / 100 internalSecurityCostPct() = totalInternalSecurityPct() / 2
So each tick costs 1% of empire production and buys +0.02 security — two percentage points onto every enemy spy's detection roll. The default cap is 10 ticks: 10% of your production for +0.20. Cost drops to zero when no empire is in range of you.
- Shifts the detection table against every enemy spy.
- Shrinks the pool of techs they can even see, via
maxTech *= 1 - securityAdj. - Scales down the winning steal roll by the same factor.
The second and third stack multiplicatively with the first, so security is considerably stronger against espionage than the detection numbers alone suggest. Against sabotage it only does the first — sabotage magnitude ignores enemy security entirely.
A maximally defended Darlok with no trade treaties reaches 0.20 + 0.10 + 0.20 = 0.50: half of every enemy spy dies each turn, the clean-infiltration band disappears completely, and the stealable tech ceiling is halved. The no-trade +0.10 is a deliberate counterweight to trade routes — opening your economy opens your borders.
08Stealing technology
Best-of-successes, gated by your own tech level and their security.
- Techs you recently traded away are removed from the candidate pool — you cannot re-steal what you just gave out.
- Each successful spy draws
random() * maxTechLevel, wheremaxTechLevelis your own highest category level. The best draw wins; the rest do nothing. - That winning number is scaled by
1 - theirSecurity. - Every stealable tech at or below that level becomes a candidate.
- The AI picks via its scientist's
mostDesirableTech. The human picks a category, and a random candidate within that category was already drawn for them.
The design consequence is that a technologically advanced thief reaches deeper. Espionage is not a catch-up mechanic; it rewards the leader. A backward empire can only steal shallow techs, and only when the victim is careless.
Framing
A successful thief with a clean identity can pin the theft on a third empire. Candidates must be in contact with the victim, within the victim's economic range, and not allied to them; exactly two are drawn, and both must exist for framing to be possible. When it works, the incident is filed against the framed empire instead of you — the victim's relations drop toward an innocent party.
The "can frame" identity requires either a negative security total (which essentially only happens on missions that never go loud) or a mission roll above 1.0, which needs a positive infiltration bonus. In practice that means a race bonus or a computer-tech lead. A vanilla empire at tech parity can almost never frame anyone; a Darlok does it routinely.
09Sabotage
Three types, all scaled off weapons tech, all guaranteed at least one point of damage.
| Type | Roll | Effect |
|---|---|---|
| Factories | ceil(weaponLevel / 10) coin flips, each hit destroying 1–5 factories |
Expected ~1.5 factories per chance. Floored at 1, capped at the colony's actual factories. |
| Missile bases | ceil(weaponLevel / 10) coin flips, each hit destroying 1 base |
At low weapon tech this reliably kills exactly one base per success. |
| Rebellion | roll(2,10) percent of population converted to rebels |
Cannot target a capital. Rebels accumulate across turns; at half the population the colony revolts and its income collapses. |
Note that sabotage magnitude depends on weapons tech, not computers — the spy gets you in the door, but what you can blow up is a function of what explosives you know how to make. It is the one place in the system where a military empire's tech investment feeds espionage directly.
Rebellion is the strategically distinct option. Factories and bases are attrition; rebellion is a compounding attack that, sustained over several turns, takes a colony out of the enemy economy entirely without a single shot fired. Both the interface default and the aggressive AI treat it as the premium target.
- The winning spy's sabotage roll is computed and then never used — it only picks which spy acts. Unlike espionage, the roll's magnitude changes nothing.
- Target selection draws from the union of all three target lists while the mission type was chosen
separately, so it is possible to run
destroyMissileBasesagainst a system that has no bases. Combined with the "at least 1 damage" floor, the count can go negative.
10How spying feeds diplomacy
The part that makes espionage a strategic decision rather than an economic one.
Getting caught does not just cost you a spy. It writes a diplomatic incident onto the victim's embassy, and incidents are the entire substance of the relations scalar — recomputed every turn as race baseline plus treaty adjustment plus the sum of every live incident's decayed severity. Espionage is therefore one of the few things in the game that can drive a relationship to war without a single fleet moving.
The four spy incidents
All four share a defining property: their severity includes
currentSpyIncidentSeverity(), the running sum of every other live spy incident on
that embassy, clamped at −50. Espionage grievances compound. Your third caught spy
hurts far more than your first, because the first two are still on the books.
| Incident | Severity | Duration | Notes |
|---|---|---|---|
EspionageTechIncident |
max(−20, −10 + spySeverity) |
10–20 | Longer against a technologist leader — they take tech theft personally. |
SabotageBasesIncident |
max(−30, −2×destroyed + spySeverity) |
10–20 | The harshest floor. Longer against a pacifist. |
SabotageFactoriesIncident |
max(−20, −1×destroyed + spySeverity) |
10–20 | Longer against an industrialist. |
SabotageRebellionIncident |
max(−25, −2×incited + spySeverity) |
10–20 | Longer against a xenophobe. |
SpyConfessionIncident |
espionage −5, sabotage −10, hiding −2 — each plus spySeverity |
2–10 | Duration doubles for a leader who hates all spies. Filed on confession, not merely capture. |
Each victim's leader personality picks the duration, so the same caught spy is a passing annoyance to one empire and a decade-long grudge to another. Notice also that the mission you were running determines the severity band — a confessed hiding spy costs you almost nothing, a confessed saboteur costs you five times as much.
Warning before war
This is the most important rule of the coupling, and the easiest to miss. Spy incidents explicitly do not trigger war on their own. They carry a "declare spying war" message key, but their trigger flag is false. The only route from espionage to war runs through the timer:
- A caught spy files an incident carrying the spy warning timer key.
- When the victim's AI decides to issue a diplomatic warning, it charges that timer by the incident's own duration.
- The war-declaration scan looks for incidents whose timer is currently active — and only then is a spying war legal.
- When the timer lapses, the victim calls
ignoreThreat()and the grievance stops being a casus belli, even though the relations damage lingers.
So the loop is: spy → get caught → get warned → keep spying → get invaded. An empire that has never warned you cannot go to war over espionage, and an empire that stops warning you has effectively forgiven you as a legal matter. Ignoring a warning is the actual decision point.
Treaties break themselves
checkForTreatyBreak() {
if (victim.isPlayerControlled()) return; // the player decides for himself
if (!isHide() && alliedWith(victim)) { breakAlliance(); breakAllTreaties(); }
if (isSabotage() && pactWith(victim)) { breakPact(); breakAllTreaties(); }
}
An AI victim does not deliberate. Any non-hiding mission caught by an ally ends the alliance immediately, and sabotage caught by a pact partner ends the pact — and both cascade into breaking every other treaty between you. Espionage against a friend is a one-strike offence, resolved without a diplomatic exchange.
The rest of the coupling
| Direction | Effect |
|---|---|
| Diplomacy → spying | Treaty changes re-task the network. Signing, breaking, or making first contact all re-invoke the spy AI's mission selection, so the network re-evaluates itself on every diplomatic event. |
| Diplomacy → spying | Signing peace hides spies on both sides automatically. Alliance grants free intel; unity disbands the network outright. |
| Diplomacy → spying | War preparations clear the threat state. Once an empire commits to attacking you, it stops caring about your spies — the grievance has been superseded by the war it justified. |
| Diplomacy → spying | A successful stop spying threat can shut down the offender's whole network against you — zeroed allocation, cleared spies, forced HIDE. |
| Spying → diplomacy | Trade treaties weaken your defence by removing the +0.10 no-trade bonus. Every trade route you sign is a small espionage liability. |
| Spying → diplomacy | The stolen-tech pool excludes techs you recently traded away, so diplomatic tech exchanges shape what espionage can reach. |
| Spying → diplomacy | A framed empire absorbs the incident. Espionage can be used to poison a relationship you are not part of. |
Normally an incident is filed only when a spy actually confesses — a spy who is merely caught and killed costs you nothing diplomatically. If the victim's leader is xenophobic, that grace disappears: any spy loss files the confession incident and runs the treaty-break check, as though the spy had talked.
The severity band still follows the mission you were actually running, so a hiding spy remains cheap (−2, two turns) and triggers no treaty break. But against a xenophobe you can no longer buy silence with a dead agent, and a running espionage or sabotage network will bleed relations on every casualty rather than only on the unlucky confessions.
11How the AI plays it
Two very different philosophies between the base AI and xilmi.
Mission selection
The base AI is cautious and characterful: it branches on leader personality, checks relations thresholds, respects an active spy warning by switching to HIDE, and at war prioritises war-relevant techs before falling through to sabotage.
xilmi is unconditionally aggressive. It spies on everyone it is in contact with — pact, peace, no-treaty and war alike — with no personality gate, no relations check, and no response to spy warnings at all. Its stated reasoning is that a victim who would declare war over espionage would have found another reason anyway. It stands down only for alliance, unity, or no contact.
| Relationship | xilmi headcount | Mission |
|---|---|---|
| Final war | 3 | Espionage if anything is stealable; otherwise sabotage (at war only); otherwise hide |
| War | 2 | |
| Pact / peace / no treaty | 2 | |
| No contact | 0 | |
| Alliance / unity | 0 | Hide — network stood down |
Xilmi also always prefers espionage over sabotage, even at war, and only sabotages when the tech well runs dry. For sabotage it picks rebellion first regardless of war status, and prefers unscouted target systems — so its sabotage doubles as reconnaissance, since a successful mission triggers a full scan of the target.
Security spending
The two AIs diverge completely here too. The base AI is threat-driven: it adds security per war and per untreatied contact, doubling for xenophobes. Xilmi is tech-lead-driven — it spends on counter-espionage only when it is ahead in technology, in proportion to how far ahead, and nothing at all when behind. The logic is that security protects an asset, and if you have no tech lead you have no asset to protect.
Spending efficiency
Xilmi computes exactly how many allocation ticks are needed to buy its target headcount and requests no more, rather than pinning the slider — with one exception: a network that has never produced a report gets a bootstrap, spending whatever it takes to field the first spy in a single turn. Getting one set of eyes onto a new contact is worth breaking the efficiency rule for.
12Quirks worth knowing
Places where the implemented system differs from what the design appears to intend.
-
The
fateaxis does nothing. The strategy-guide table has two axes — whether the spy was stopped, and whether the spy was identified — but nothing ever reads the stopped flag. A spy that rolls "stopped, undiscovered" attempts its mission exactly like a clean one. The real per-turn outcome collapses to 70% survive and act, 30% die. - Sabotage ignores enemy security except through casualties. Espionage is scaled by it twice over.
- The stealable-tech visibility threshold is computed from last turn's list. "Nothing to steal" grants a −0.30 security bonus, which widens this turn's visibility by 30% and can itself create something to steal — a small self-correcting oscillation.
- Security has no upper guard. Raising the security cap to its maximum lets the total exceed 1.0, at which point the stealable-tech ceiling goes negative and every enemy spy confesses on every roll — for most of your empire's production.
- Sabotage always does at least 1 damage on success, even when every damage roll failed.
- The eviction threat state is write-only in the main AIs — it is set but never read, so evicting spies is effectively not a mechanic outside one legacy personality.