From 51164ad13872a36d73d839ee2067abcfdea66d02 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 5 Jun 2025 13:02:25 -0400 Subject: [PATCH] AI nukes avoid SAM launchers (#1045) ## Description: AI nukes avoid SAM launchers ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com> Co-authored-by: evanpelle --- src/core/execution/FakeHumanExecution.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index 1d5ca31fe..7f4d5c024 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -373,14 +373,21 @@ export class FakeHumanExecution implements Execution { return 50_000; case UnitType.Port: return 10_000; - case UnitType.SAMLauncher: - return 5_000; default: return 0; } }) .reduce((prev, cur) => prev + cur, 0); + // Avoid areas defended by SAM launchers + const dist50 = euclDistFN(tile, 50, false); + tileValue -= + 50_000 * + targets.filter( + (unit) => + unit.type() === UnitType.SAMLauncher && dist50(this.mg, unit.tile()), + ).length; + // Prefer tiles that are closer to a silo const siloTiles = silos.map((u) => u.tile()); const result = closestTwoTiles(this.mg, siloTiles, [tile]);