From c43480f07d010fb960996ec37b5a0d163a38f761 Mon Sep 17 00:00:00 2001 From: TKTK123456 <103334266+TKTK123456@users.noreply.github.com> Date: Sat, 18 Jul 2026 11:32:21 -0400 Subject: [PATCH 1/6] Made SAM's pay attention to cooldown and the like well intercepting multipul MIRV warheads --- src/core/execution/SAMLauncherExecution.ts | 71 +++++++++++++--------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index c27328f453..0b92140bea 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -110,11 +110,11 @@ class SAMTargetingSystem { const rangeSquared = range * range; // Look beyond the SAM range so it can preshot nukes - const detectionRange = this.mg.config().maxSamRange() * 2; + const detectionRange = 1200; const nukes = this.mg.nearbyUnits( samTile, detectionRange, - [UnitType.AtomBomb, UnitType.HydrogenBomb], + [UnitType.AtomBomb, UnitType.HydrogenBomb, UnitType.MIRVWarhead], ({ unit }) => { if (!isUnit(unit) || unit.targetedBySAM()) return false; if (unit.owner() === this.sam.owner()) return false; @@ -271,35 +271,39 @@ export class SAMLauncherExecution implements Execution { this.pseudoRandom ??= new PseudoRandom(this.sam.id()); - const mirvWarheadTargets = this.mg.nearbyUnits( - this.sam.tile(), - this.MIRVWarheadSearchRadius, - UnitType.MIRVWarhead, - ({ unit }) => { - if (!isUnit(unit)) return false; - if (unit.owner() === this.player) return false; - - // After game-over in team games, SAMs also target teammate MIRVs (aftergame fun) - const nukeOwner = unit.owner(); - if (this.player.isFriendly(nukeOwner)) { - if ( - this.mg.getWinner() === null || - !this.player.isOnSameTeam(nukeOwner) - ) { - return false; + let mirvWarheadTargets = this.mg + .nearbyUnits( + this.sam.tile(), + this.MIRVWarheadSearchRadius, + UnitType.MIRVWarhead, + ({ unit }) => { + if (!isUnit(unit)) return false; + if (unit.owner() === this.player) return false; + + // After game-over in team games, SAMs also target teammate MIRVs (aftergame fun) + const nukeOwner = unit.owner(); + if (this.player.isFriendly(nukeOwner)) { + if ( + this.mg.getWinner() === null || + !this.player.isOnSameTeam(nukeOwner) + ) { + return false; + } } - } - - const dst = unit.targetTile(); - return ( - this.sam !== null && - dst !== undefined && - this.mg.manhattanDist(dst, this.sam.tile()) < - this.MIRVWarheadProtectionRadius - ); - }, - ); + const dst = unit.targetTile(); + return ( + this.sam !== null && + dst !== undefined && + this.mg.manhattanDist(dst, this.sam.tile()) < + this.mg.config().samRange(this.sam.level()) + ); + }, + ) + .filter((v, i) => { + return i <= (this.sam?.level() ?? Infinity); + }); + console.log(mirvWarheadTargets.length); let target: Target | null = null; if (mirvWarheadTargets.length === 0) { target = this.targetingSystem.getSingleTarget(ticks); @@ -325,7 +329,14 @@ export class SAMLauncherExecution implements Execution { { count: mirvWarheadTargets.length }, ); - mirvWarheadTargets.forEach(({ unit: u }) => { + mirvWarheadTargets.forEach(({ unit: u }, i) => { + if (this.sam !== null && i > 0) { + if (this.sam.isInCooldown()) { + return; + } + this.sam.launch(); + } + // Delete warheads u.delete(); }); From e6b37d7c8a070a9f3b60ae406963a16f32497684 Mon Sep 17 00:00:00 2001 From: TKTK123456 <103334266+TKTK123456@users.noreply.github.com> Date: Sat, 18 Jul 2026 11:41:24 -0400 Subject: [PATCH 2/6] Removed unneeded changes --- src/core/execution/SAMLauncherExecution.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 0b92140bea..936185bd9d 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -110,11 +110,11 @@ class SAMTargetingSystem { const rangeSquared = range * range; // Look beyond the SAM range so it can preshot nukes - const detectionRange = 1200; + const detectionRange = this.mg.config().maxSamRange() * 4; const nukes = this.mg.nearbyUnits( samTile, detectionRange, - [UnitType.AtomBomb, UnitType.HydrogenBomb, UnitType.MIRVWarhead], + [UnitType.AtomBomb, UnitType.HydrogenBomb], ({ unit }) => { if (!isUnit(unit) || unit.targetedBySAM()) return false; if (unit.owner() === this.sam.owner()) return false; From b8866be97ff6b2ad55a7a3b7d5ad00fd0336a640 Mon Sep 17 00:00:00 2001 From: TKTK123456 <103334266+TKTK123456@users.noreply.github.com> Date: Sat, 18 Jul 2026 11:44:32 -0400 Subject: [PATCH 3/6] Removed unneeded filter --- src/core/execution/SAMLauncherExecution.ts | 57 ++++++++++------------ 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 936185bd9d..10304c25b9 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -271,39 +271,34 @@ export class SAMLauncherExecution implements Execution { this.pseudoRandom ??= new PseudoRandom(this.sam.id()); - let mirvWarheadTargets = this.mg - .nearbyUnits( - this.sam.tile(), - this.MIRVWarheadSearchRadius, - UnitType.MIRVWarhead, - ({ unit }) => { - if (!isUnit(unit)) return false; - if (unit.owner() === this.player) return false; - - // After game-over in team games, SAMs also target teammate MIRVs (aftergame fun) - const nukeOwner = unit.owner(); - if (this.player.isFriendly(nukeOwner)) { - if ( - this.mg.getWinner() === null || - !this.player.isOnSameTeam(nukeOwner) - ) { - return false; - } + const mirvWarheadTargets = this.mg.nearbyUnits( + this.sam.tile(), + this.MIRVWarheadSearchRadius, + UnitType.MIRVWarhead, + ({ unit }) => { + if (!isUnit(unit)) return false; + if (unit.owner() === this.player) return false; + + // After game-over in team games, SAMs also target teammate MIRVs (aftergame fun) + const nukeOwner = unit.owner(); + if (this.player.isFriendly(nukeOwner)) { + if ( + this.mg.getWinner() === null || + !this.player.isOnSameTeam(nukeOwner) + ) { + return false; } + } - const dst = unit.targetTile(); - return ( - this.sam !== null && - dst !== undefined && - this.mg.manhattanDist(dst, this.sam.tile()) < - this.mg.config().samRange(this.sam.level()) - ); - }, - ) - .filter((v, i) => { - return i <= (this.sam?.level() ?? Infinity); - }); - console.log(mirvWarheadTargets.length); + const dst = unit.targetTile(); + return ( + this.sam !== null && + dst !== undefined && + this.mg.manhattanDist(dst, this.sam.tile()) < + this.mg.config().samRange(this.sam.level()) + ); + }, + ); let target: Target | null = null; if (mirvWarheadTargets.length === 0) { target = this.targetingSystem.getSingleTarget(ticks); From c485fd5ce229c9e60036534ecc34442a4d22e25c Mon Sep 17 00:00:00 2001 From: TKTK123456 <103334266+TKTK123456@users.noreply.github.com> Date: Sat, 18 Jul 2026 11:48:15 -0400 Subject: [PATCH 4/6] Fixed a few unintentional changes and removed unneeded variable --- src/core/execution/SAMLauncherExecution.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 10304c25b9..346cbaea1f 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -110,7 +110,7 @@ class SAMTargetingSystem { const rangeSquared = range * range; // Look beyond the SAM range so it can preshot nukes - const detectionRange = this.mg.config().maxSamRange() * 4; + const detectionRange = this.mg.config().maxSamRange() * 2; const nukes = this.mg.nearbyUnits( samTile, detectionRange, @@ -206,7 +206,6 @@ export class SAMLauncherExecution implements Execution { // As MIRV go very fast we have to detect them very early but we only // shoot the one targeting very close (MIRVWarheadProtectionRadius) private MIRVWarheadSearchRadius = 400; - private MIRVWarheadProtectionRadius = 50; private targetingSystem: SAMTargetingSystem; private pseudoRandom: PseudoRandom | undefined; From 3ad07636a3bdabfdaecba4d684acb66ffc9158a5 Mon Sep 17 00:00:00 2001 From: TKTK123456 <103334266+TKTK123456@users.noreply.github.com> Date: Sat, 18 Jul 2026 11:52:30 -0400 Subject: [PATCH 5/6] made statistic thing acurate --- src/core/execution/SAMLauncherExecution.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 346cbaea1f..16f031ee39 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -322,12 +322,13 @@ export class SAMLauncherExecution implements Execution { undefined, { count: mirvWarheadTargets.length }, ); - + let amountOfWarheads = 0 mirvWarheadTargets.forEach(({ unit: u }, i) => { if (this.sam !== null && i > 0) { if (this.sam.isInCooldown()) { return; } + amountOfWarheads++ this.sam.launch(); } @@ -341,7 +342,7 @@ export class SAMLauncherExecution implements Execution { .bombIntercept( samOwner, UnitType.MIRVWarhead, - mirvWarheadTargets.length, + amountOfWarheads, ); } else if (target !== null) { target.unit.setTargetedBySAM(true); From c06dc3a3b2ef2af44ad4764e3dc03f97b80a5abc Mon Sep 17 00:00:00 2001 From: TKTK123456 <103334266+TKTK123456@users.noreply.github.com> Date: Sat, 18 Jul 2026 20:14:34 -0400 Subject: [PATCH 6/6] Moved amount of warheads counter to better location --- src/core/execution/SAMLauncherExecution.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 16f031ee39..7dad58b764 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -322,16 +322,15 @@ export class SAMLauncherExecution implements Execution { undefined, { count: mirvWarheadTargets.length }, ); - let amountOfWarheads = 0 + let amountOfWarheads = 0; mirvWarheadTargets.forEach(({ unit: u }, i) => { if (this.sam !== null && i > 0) { if (this.sam.isInCooldown()) { return; } - amountOfWarheads++ this.sam.launch(); } - + amountOfWarheads++; // Delete warheads u.delete(); }); @@ -339,11 +338,7 @@ export class SAMLauncherExecution implements Execution { // Record stats this.mg .stats() - .bombIntercept( - samOwner, - UnitType.MIRVWarhead, - amountOfWarheads, - ); + .bombIntercept(samOwner, UnitType.MIRVWarhead, amountOfWarheads); } else if (target !== null) { target.unit.setTargetedBySAM(true); this.mg.addExecution(