@supalosa/chronodivide-bot 0.5.3 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/.env.template +4 -4
  2. package/.github/workflows/npm-publish.yml +24 -0
  3. package/README.md +108 -97
  4. package/dist/bot/bot.js +105 -105
  5. package/dist/bot/bot.js.map +1 -1
  6. package/dist/bot/logic/awareness.js +136 -136
  7. package/dist/bot/logic/building/antiAirStaticDefence.js +42 -42
  8. package/dist/bot/logic/building/antiGroundStaticDefence.js +34 -30
  9. package/dist/bot/logic/building/antiGroundStaticDefence.js.map +1 -1
  10. package/dist/bot/logic/building/{ArtilleryUnit.js → artilleryUnit.js} +18 -18
  11. package/dist/bot/logic/building/basicAirUnit.js +19 -19
  12. package/dist/bot/logic/building/basicBuilding.js +26 -26
  13. package/dist/bot/logic/building/basicGroundUnit.js +19 -19
  14. package/dist/bot/logic/building/buildingRules.js +175 -174
  15. package/dist/bot/logic/building/buildingRules.js.map +1 -1
  16. package/dist/bot/logic/building/common.js +19 -18
  17. package/dist/bot/logic/building/common.js.map +1 -1
  18. package/dist/bot/logic/building/harvester.js +16 -16
  19. package/dist/bot/logic/building/powerPlant.js +20 -20
  20. package/dist/bot/logic/building/queueController.js +183 -183
  21. package/dist/bot/logic/building/resourceCollectionBuilding.js +36 -36
  22. package/dist/bot/logic/common/scout.js +126 -126
  23. package/dist/bot/logic/common/utils.js +95 -85
  24. package/dist/bot/logic/common/utils.js.map +1 -1
  25. package/dist/bot/logic/composition/alliedCompositions.js +12 -12
  26. package/dist/bot/logic/composition/common.js +1 -1
  27. package/dist/bot/logic/composition/sovietCompositions.js +12 -12
  28. package/dist/bot/logic/map/map.js +44 -44
  29. package/dist/bot/logic/map/sector.js +137 -137
  30. package/dist/bot/logic/mission/actionBatcher.js +91 -91
  31. package/dist/bot/logic/mission/mission.js +122 -122
  32. package/dist/bot/logic/mission/missionController.js +321 -321
  33. package/dist/bot/logic/mission/missionFactories.js +12 -12
  34. package/dist/bot/logic/mission/missions/attackMission.js +214 -214
  35. package/dist/bot/logic/mission/missions/defenceMission.js +82 -82
  36. package/dist/bot/logic/mission/missions/engineerMission.js +63 -63
  37. package/dist/bot/logic/mission/missions/expansionMission.js +60 -60
  38. package/dist/bot/logic/mission/missions/retreatMission.js +33 -33
  39. package/dist/bot/logic/mission/missions/scoutingMission.js +133 -133
  40. package/dist/bot/logic/mission/missions/squads/combatSquad.js +115 -115
  41. package/dist/bot/logic/mission/missions/squads/common.js +57 -57
  42. package/dist/bot/logic/mission/missions/squads/squad.js +1 -1
  43. package/dist/bot/logic/threat/threat.js +22 -22
  44. package/dist/bot/logic/threat/threatCalculator.js +73 -73
  45. package/dist/exampleBot.js +100 -112
  46. package/dist/exampleBot.js.map +1 -1
  47. package/package.json +32 -29
  48. package/src/bot/bot.ts +161 -161
  49. package/src/bot/logic/awareness.ts +245 -245
  50. package/src/bot/logic/building/antiAirStaticDefence.ts +64 -64
  51. package/src/bot/logic/building/antiGroundStaticDefence.ts +55 -51
  52. package/src/bot/logic/building/artilleryUnit.ts +39 -39
  53. package/src/bot/logic/building/basicAirUnit.ts +39 -39
  54. package/src/bot/logic/building/basicBuilding.ts +49 -49
  55. package/src/bot/logic/building/basicGroundUnit.ts +39 -39
  56. package/src/bot/logic/building/buildingRules.ts +250 -247
  57. package/src/bot/logic/building/common.ts +21 -23
  58. package/src/bot/logic/building/harvester.ts +31 -31
  59. package/src/bot/logic/building/powerPlant.ts +32 -32
  60. package/src/bot/logic/building/queueController.ts +297 -297
  61. package/src/bot/logic/building/resourceCollectionBuilding.ts +52 -52
  62. package/src/bot/logic/common/scout.ts +183 -183
  63. package/src/bot/logic/common/utils.ts +120 -112
  64. package/src/bot/logic/composition/alliedCompositions.ts +22 -22
  65. package/src/bot/logic/composition/common.ts +3 -3
  66. package/src/bot/logic/composition/sovietCompositions.ts +21 -21
  67. package/src/bot/logic/map/map.ts +66 -66
  68. package/src/bot/logic/map/sector.ts +174 -174
  69. package/src/bot/logic/mission/actionBatcher.ts +124 -124
  70. package/src/bot/logic/mission/mission.ts +232 -232
  71. package/src/bot/logic/mission/missionController.ts +413 -413
  72. package/src/bot/logic/mission/missionFactories.ts +51 -51
  73. package/src/bot/logic/mission/missions/attackMission.ts +336 -336
  74. package/src/bot/logic/mission/missions/defenceMission.ts +151 -151
  75. package/src/bot/logic/mission/missions/engineerMission.ts +113 -113
  76. package/src/bot/logic/mission/missions/expansionMission.ts +104 -104
  77. package/src/bot/logic/mission/missions/retreatMission.ts +54 -54
  78. package/src/bot/logic/mission/missions/scoutingMission.ts +186 -186
  79. package/src/bot/logic/mission/missions/squads/combatSquad.ts +160 -160
  80. package/src/bot/logic/mission/missions/squads/common.ts +63 -63
  81. package/src/bot/logic/mission/missions/squads/squad.ts +19 -19
  82. package/src/bot/logic/threat/threatCalculator.ts +100 -100
  83. package/src/exampleBot.ts +111 -124
  84. package/tsconfig.json +73 -73
  85. package/dist/bot/logic/building/building.js +0 -82
  86. package/dist/bot/logic/building/massedAntiGroundUnit.js +0 -20
  87. package/dist/bot/logic/building/queues.js +0 -19
  88. package/dist/bot/logic/knowledge.js +0 -1
  89. package/dist/bot/logic/mission/basicMission.js +0 -26
  90. package/dist/bot/logic/mission/behaviours/combatSquad.js +0 -124
  91. package/dist/bot/logic/mission/behaviours/combatSquad.js.map +0 -1
  92. package/dist/bot/logic/mission/behaviours/common.js +0 -56
  93. package/dist/bot/logic/mission/behaviours/common.js.map +0 -1
  94. package/dist/bot/logic/mission/behaviours/engineerSquad.js +0 -39
  95. package/dist/bot/logic/mission/behaviours/engineerSquad.js.map +0 -1
  96. package/dist/bot/logic/mission/behaviours/expansionSquad.js +0 -46
  97. package/dist/bot/logic/mission/behaviours/expansionSquad.js.map +0 -1
  98. package/dist/bot/logic/mission/behaviours/retreatSquad.js +0 -31
  99. package/dist/bot/logic/mission/behaviours/retreatSquad.js.map +0 -1
  100. package/dist/bot/logic/mission/behaviours/scoutingSquad.js +0 -94
  101. package/dist/bot/logic/mission/behaviours/scoutingSquad.js.map +0 -1
  102. package/dist/bot/logic/mission/expansionMission.js +0 -32
  103. package/dist/bot/logic/mission/missions/basicMission.js +0 -13
  104. package/dist/bot/logic/mission/missions/basicMission.js.map +0 -1
  105. package/dist/bot/logic/mission/missions/missionBehaviour.js +0 -2
  106. package/dist/bot/logic/mission/missions/missionBehaviour.js.map +0 -1
  107. package/dist/bot/logic/mission/missions/oneTimeMission.js +0 -27
  108. package/dist/bot/logic/mission/missions/oneTimeMission.js.map +0 -1
  109. package/dist/bot/logic/squad/behaviours/actionBatcher.js +0 -36
  110. package/dist/bot/logic/squad/behaviours/actionBatcher.js.map +0 -1
  111. package/dist/bot/logic/squad/behaviours/attackSquad.js +0 -82
  112. package/dist/bot/logic/squad/behaviours/combatSquad.js +0 -106
  113. package/dist/bot/logic/squad/behaviours/combatSquad.js.map +0 -1
  114. package/dist/bot/logic/squad/behaviours/common.js +0 -55
  115. package/dist/bot/logic/squad/behaviours/common.js.map +0 -1
  116. package/dist/bot/logic/squad/behaviours/defenceSquad.js +0 -48
  117. package/dist/bot/logic/squad/behaviours/engineerSquad.js +0 -38
  118. package/dist/bot/logic/squad/behaviours/engineerSquad.js.map +0 -1
  119. package/dist/bot/logic/squad/behaviours/expansionSquad.js +0 -45
  120. package/dist/bot/logic/squad/behaviours/expansionSquad.js.map +0 -1
  121. package/dist/bot/logic/squad/behaviours/retreatSquad.js +0 -31
  122. package/dist/bot/logic/squad/behaviours/retreatSquad.js.map +0 -1
  123. package/dist/bot/logic/squad/behaviours/scoutingSquad.js +0 -93
  124. package/dist/bot/logic/squad/behaviours/scoutingSquad.js.map +0 -1
  125. package/dist/bot/logic/squad/behaviours/squadExpansion.js +0 -31
  126. package/dist/bot/logic/squad/behaviours/squadScouters.js +0 -8
  127. package/dist/bot/logic/squad/squad.js +0 -126
  128. package/dist/bot/logic/squad/squad.js.map +0 -1
  129. package/dist/bot/logic/squad/squadBehaviour.js +0 -6
  130. package/dist/bot/logic/squad/squadBehaviour.js.map +0 -1
  131. package/dist/bot/logic/squad/squadBehaviours.js +0 -7
  132. package/dist/bot/logic/squad/squadBehaviours.js.map +0 -1
  133. package/dist/bot/logic/squad/squadController.js +0 -215
  134. package/dist/bot/logic/squad/squadController.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"missionBehaviour.js","sourceRoot":"","sources":["../../../../../src/bot/logic/mission/missions/missionBehaviour.ts"],"names":[],"mappings":""}
@@ -1,27 +0,0 @@
1
- import { Mission, disbandMission, noop } from "../mission.js";
2
- import { Squad } from "../../squad/squad.js";
3
- /**
4
- * A mission that gets dispatched once, and once the squad decides to disband, the mission is disbanded.
5
- */
6
- export class OneTimeMission extends Mission {
7
- constructor(uniqueName, priority, behaviourFactory, logger) {
8
- super(uniqueName, priority, logger);
9
- this.behaviourFactory = behaviourFactory;
10
- this.hadSquad = false;
11
- }
12
- onAiUpdate(gameApi, playerData, matchAwareness) {
13
- if (this.getSquad() === null) {
14
- if (!this.hadSquad) {
15
- this.hadSquad = true;
16
- return this.setSquad(new Squad(this.getUniqueName(), this.behaviourFactory(), this));
17
- }
18
- else {
19
- return disbandMission();
20
- }
21
- }
22
- else {
23
- return noop();
24
- }
25
- }
26
- }
27
- //# sourceMappingURL=oneTimeMission.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oneTimeMission.js","sourceRoot":"","sources":["../../../../../src/bot/logic/mission/missions/oneTimeMission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAiB,cAAc,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAM7C;;GAEG;AACH,MAAM,OAAgB,cAA8B,SAAQ,OAAU;IAGlE,YAAY,UAAkB,EAAE,QAAgB,EAAU,gBAAsC,EAAE,MAAmB;QACjH,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QADkB,qBAAgB,GAAhB,gBAAgB,CAAsB;QAFxF,aAAQ,GAAG,KAAK,CAAC;IAIzB,CAAC;IAED,UAAU,CAAC,OAAgB,EAAE,UAAsB,EAAE,cAA8B;QAC/E,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;aACxF;iBAAM;gBACH,OAAO,cAAc,EAAE,CAAC;aAC3B;SACJ;aAAM;YACH,OAAO,IAAI,EAAE,CAAC;SACjB;IACL,CAAC;CACJ"}
@@ -1,36 +0,0 @@
1
- // Used to group related actions together to minimise actionApi calls. For example, if multiple units
2
- import { Vector2 } from "@chronodivide/game-api";
3
- import { groupBy } from "../../common/utils.js";
4
- export class ActionBatcher {
5
- constructor() {
6
- this.actions = [];
7
- }
8
- push(action) {
9
- this.actions.push(action);
10
- }
11
- resolve(actionsApi) {
12
- const groupedCommands = groupBy(this.actions, (action) => action.orderType.valueOf().toString());
13
- const vectorToStr = (v) => v.x + "," + v.y;
14
- const strToVector = (str) => {
15
- const [x, y] = str.split(",");
16
- return new Vector2(parseInt(x), parseInt(y));
17
- };
18
- // Group by command type.
19
- Object.entries(groupedCommands).forEach(([commandValue, commands]) => {
20
- // i hate this
21
- const commandType = parseInt(commandValue);
22
- // Group by command target ID.
23
- const byTarget = groupBy(commands.filter((command) => !!command.targetId), (command) => command.targetId?.toString());
24
- Object.entries(byTarget).forEach(([targetId, unitCommands]) => {
25
- actionsApi.orderUnits(unitCommands.map((command) => command.unitId), commandType, parseInt(targetId));
26
- });
27
- // Group by position (the vector is encoded as a string of the form "x,y")
28
- const byPosition = groupBy(commands.filter((command) => !!command.point), (command) => vectorToStr(command.point));
29
- Object.entries(byPosition).forEach(([point, unitCommands]) => {
30
- const vector = strToVector(point);
31
- actionsApi.orderUnits(unitCommands.map((command) => command.unitId), commandType, vector.x, vector.y);
32
- });
33
- });
34
- }
35
- }
36
- //# sourceMappingURL=actionBatcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actionBatcher.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/actionBatcher.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAErG,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAUhD,MAAM,OAAO,aAAa;IAGtB;QACI,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,MAAuB;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,UAAsB;QAC1B,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjG,MAAM,WAAW,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE;YAChC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9B,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC;QAEF,yBAAyB;QACzB,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAA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QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -1,82 +0,0 @@
1
- import _ from "lodash";
2
- import { MovementZone } from "@chronodivide/game-api";
3
- import { grabCombatants, noop } from "../squadBehaviour.js";
4
- import { getDistanceBetweenPoints } from "../../map/map.js";
5
- import { manageAttackMicro, manageMoveMicro } from "./common.js";
6
- const TARGET_UPDATE_INTERVAL_TICKS = 10;
7
- const GRAB_INTERVAL_TICKS = 10;
8
- const GRAB_RADIUS = 30;
9
- // Units must be in a certain radius of the center of mass before attacking.
10
- // This scales for number of units in the squad though.
11
- const MIN_GATHER_RADIUS = 5;
12
- const GATHER_RATIO = 10;
13
- var SquadState;
14
- (function (SquadState) {
15
- SquadState[SquadState["Gathering"] = 0] = "Gathering";
16
- SquadState[SquadState["Attacking"] = 1] = "Attacking";
17
- })(SquadState || (SquadState = {}));
18
- export class AttackOrDefenceSquad {
19
- constructor(rallyArea, targetArea, radius) {
20
- this.rallyArea = rallyArea;
21
- this.targetArea = targetArea;
22
- this.radius = radius;
23
- this.lastGrab = null;
24
- this.lastCommand = null;
25
- this.state = SquadState.Gathering;
26
- }
27
- setAttackArea(targetArea) {
28
- this.targetArea = targetArea;
29
- }
30
- onAiUpdate(gameApi, actionsApi, playerData, squad, matchAwareness) {
31
- if (!this.lastCommand || gameApi.getCurrentTick() > this.lastCommand + TARGET_UPDATE_INTERVAL_TICKS) {
32
- this.lastCommand = gameApi.getCurrentTick();
33
- const centerOfMass = squad.getCenterOfMass();
34
- const maxDistance = squad.getMaxDistanceToCenterOfMass();
35
- const units = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant);
36
- if (this.state === SquadState.Gathering) {
37
- // Only use ground units for center of mass.
38
- const groundUnits = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant &&
39
- (r.rules.movementZone === MovementZone.Infantry ||
40
- r.rules.movementZone === MovementZone.Normal ||
41
- r.rules.movementZone === MovementZone.InfantryDestroyer));
42
- const requiredGatherRadius = Math.sqrt(groundUnits.length) * GATHER_RATIO + MIN_GATHER_RADIUS;
43
- if (centerOfMass &&
44
- maxDistance &&
45
- gameApi.mapApi.getTile(centerOfMass.x, centerOfMass.y) !== undefined &&
46
- maxDistance > requiredGatherRadius) {
47
- units.forEach((unit) => {
48
- manageMoveMicro(actionsApi, unit, centerOfMass);
49
- });
50
- }
51
- else {
52
- this.state = SquadState.Attacking;
53
- }
54
- }
55
- else {
56
- const targetPoint = this.targetArea || playerData.startLocation;
57
- for (const unit of units) {
58
- if (unit.isIdle) {
59
- const { rx: x, ry: y } = unit.tile;
60
- const range = unit.primaryWeapon?.maxRange ?? unit.secondaryWeapon?.maxRange ?? 5;
61
- const nearbyHostiles = matchAwareness.getHostilesNearPoint(x, y, range * 2);
62
- const closest = _.minBy(nearbyHostiles, ({ x: hX, y: hY }) => getDistanceBetweenPoints({ x, y }, { x: hX, y: hY }));
63
- const closestUnit = closest ? gameApi.getUnitData(closest.unitId) ?? null : null;
64
- if (closestUnit) {
65
- manageAttackMicro(actionsApi, unit, closestUnit);
66
- }
67
- else {
68
- manageMoveMicro(actionsApi, unit, targetPoint);
69
- }
70
- }
71
- }
72
- }
73
- }
74
- if (!this.lastGrab || gameApi.getCurrentTick() > this.lastGrab + GRAB_INTERVAL_TICKS) {
75
- this.lastGrab = gameApi.getCurrentTick();
76
- return grabCombatants(this.rallyArea, this.radius * GRAB_RADIUS);
77
- }
78
- else {
79
- return noop();
80
- }
81
- }
82
- }
@@ -1,106 +0,0 @@
1
- import { GameMath, MovementZone } from "@chronodivide/game-api";
2
- import { grabCombatants, noop } from "../squadBehaviour.js";
3
- import { getAttackWeight, manageAttackMicro, manageMoveMicro } from "./common.js";
4
- import { maxBy } from "../../common/utils.js";
5
- const TARGET_UPDATE_INTERVAL_TICKS = 10;
6
- const GRAB_INTERVAL_TICKS = 10;
7
- const GRAB_RADIUS = 20;
8
- // Units must be in a certain radius of the center of mass before attacking.
9
- // This scales for number of units in the squad though.
10
- const MIN_GATHER_RADIUS = 5;
11
- // If the radius expands beyond this amount then we should switch back to gathering mode.
12
- const MAX_GATHER_RADIUS = 15;
13
- const GATHER_RATIO = 10;
14
- var SquadState;
15
- (function (SquadState) {
16
- SquadState[SquadState["Gathering"] = 0] = "Gathering";
17
- SquadState[SquadState["Attacking"] = 1] = "Attacking";
18
- })(SquadState || (SquadState = {}));
19
- export class CombatSquad {
20
- /**
21
- *
22
- * @param rallyArea the initial location to grab combatants
23
- * @param targetArea
24
- * @param radius
25
- */
26
- constructor(rallyArea, targetArea, radius) {
27
- this.rallyArea = rallyArea;
28
- this.targetArea = targetArea;
29
- this.radius = radius;
30
- this.lastGrab = null;
31
- this.lastCommand = null;
32
- this.state = SquadState.Gathering;
33
- }
34
- getGlobalDebugText() {
35
- return this.debugLastTarget ?? "<none>";
36
- }
37
- setAttackArea(targetArea) {
38
- this.targetArea = targetArea;
39
- }
40
- onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, squad, matchAwareness, logger) {
41
- if (squad.getUnitIds().length > 0 &&
42
- (!this.lastCommand || gameApi.getCurrentTick() > this.lastCommand + TARGET_UPDATE_INTERVAL_TICKS)) {
43
- this.lastCommand = gameApi.getCurrentTick();
44
- const centerOfMass = squad.getCenterOfMass();
45
- const maxDistance = squad.getMaxDistanceToCenterOfMass();
46
- const units = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant);
47
- // Only use ground units for center of mass.
48
- const groundUnits = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant &&
49
- (r.rules.movementZone === MovementZone.Infantry ||
50
- r.rules.movementZone === MovementZone.Normal ||
51
- r.rules.movementZone === MovementZone.InfantryDestroyer));
52
- if (this.state === SquadState.Gathering) {
53
- const requiredGatherRadius = GameMath.sqrt(groundUnits.length) * GATHER_RATIO + MIN_GATHER_RADIUS;
54
- if (centerOfMass &&
55
- maxDistance &&
56
- gameApi.mapApi.getTile(centerOfMass.x, centerOfMass.y) !== undefined &&
57
- maxDistance > requiredGatherRadius) {
58
- units.forEach((unit) => {
59
- actionBatcher.push(manageMoveMicro(unit, centerOfMass));
60
- });
61
- }
62
- else {
63
- logger(`CombatSquad ${squad.getName()} switching back to attack mode (${maxDistance})`);
64
- this.state = SquadState.Attacking;
65
- }
66
- }
67
- else {
68
- const targetPoint = this.targetArea || playerData.startLocation;
69
- const requiredGatherRadius = GameMath.sqrt(groundUnits.length) * GATHER_RATIO + MAX_GATHER_RADIUS;
70
- if (centerOfMass &&
71
- maxDistance &&
72
- gameApi.mapApi.getTile(centerOfMass.x, centerOfMass.y) !== undefined &&
73
- maxDistance > requiredGatherRadius) {
74
- // Switch back to gather mode
75
- logger(`CombatSquad ${squad.getName()} switching back to gather (${maxDistance})`);
76
- this.state = SquadState.Gathering;
77
- return noop();
78
- }
79
- for (const unit of units) {
80
- const { rx: x, ry: y } = unit.tile;
81
- const range = unit.primaryWeapon?.maxRange ?? unit.secondaryWeapon?.maxRange ?? 5;
82
- const nearbyHostiles = matchAwareness
83
- .getHostilesNearPoint(x, y, range * 2)
84
- .map(({ unitId }) => gameApi.getUnitData(unitId));
85
- const bestUnit = maxBy(nearbyHostiles, (target) => getAttackWeight(unit, target));
86
- if (bestUnit) {
87
- actionBatcher.push(manageAttackMicro(unit, bestUnit));
88
- this.debugLastTarget = `Unit ${bestUnit.id.toString()}`;
89
- }
90
- else {
91
- actionBatcher.push(manageMoveMicro(unit, targetPoint));
92
- this.debugLastTarget = `@${targetPoint.x},${targetPoint.y}`;
93
- }
94
- }
95
- }
96
- }
97
- if (!this.lastGrab || gameApi.getCurrentTick() > this.lastGrab + GRAB_INTERVAL_TICKS) {
98
- this.lastGrab = gameApi.getCurrentTick();
99
- return grabCombatants(squad.getCenterOfMass() ?? this.rallyArea, GRAB_RADIUS);
100
- }
101
- else {
102
- return noop();
103
- }
104
- }
105
- }
106
- //# sourceMappingURL=combatSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"combatSquad.js","sourceRoot":"","sources":["../../../../../src/bot/log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E,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAe,CAAC;oBACpE,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;oBAClF,IAAI,QAAQ,EAAE;wBACV,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;wBACtD,IAAI,CAAC,eAAe,GAAG,QAAQ,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;qBAC3D;yBAAM;wBACH,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;wBACvD,IAAI,CAAC,eAAe,GAAG,IAAI,WAAW,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC;qBAC/D;iBACJ;aACJ;SACJ;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,QAAQ,GAAG,mBAAmB,EAAE;YAClF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;YACzC,OAAO,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;SACjF;aAAM;YACH,OAAO,IAAI,EAAE,CAAC;SACjB;IACL,CAAC;CACJ"}
@@ -1,55 +0,0 @@
1
- import { AttackState, ObjectType, OrderType, StanceType, Vector2, ZoneType, } from "@chronodivide/game-api";
2
- import { getDistanceBetweenPoints, getDistanceBetweenUnits } from "../../map/map.js";
3
- // Micro methods
4
- export function manageMoveMicro(attacker, attackPoint) {
5
- if (attacker.name === "E1") {
6
- const isDeployed = attacker.stance === StanceType.Deployed;
7
- if (isDeployed) {
8
- return { unitId: attacker.id, orderType: OrderType.DeploySelected };
9
- }
10
- }
11
- return { unitId: attacker.id, orderType: OrderType.Move, point: attackPoint };
12
- }
13
- export function manageAttackMicro(attacker, target) {
14
- const distance = getDistanceBetweenUnits(attacker, target);
15
- if (attacker.name === "E1") {
16
- // Para (deployed weapon) range is 5.
17
- const deployedWeaponRange = attacker.secondaryWeapon?.maxRange || 5;
18
- const isDeployed = attacker.stance === StanceType.Deployed;
19
- if (!isDeployed && (distance <= deployedWeaponRange || attacker.attackState === AttackState.JustFired)) {
20
- return { unitId: attacker.id, orderType: OrderType.DeploySelected };
21
- }
22
- else if (isDeployed && distance > deployedWeaponRange) {
23
- return { unitId: attacker.id, orderType: OrderType.DeploySelected };
24
- }
25
- }
26
- let targetData = target;
27
- let orderType = OrderType.Attack;
28
- const primaryWeaponRange = attacker.primaryWeapon?.maxRange || 5;
29
- if (targetData?.type == ObjectType.Building && distance < primaryWeaponRange * 0.8) {
30
- orderType = OrderType.Attack;
31
- }
32
- else if (targetData?.rules.canDisguise) {
33
- // Special case for mirage tank/spy as otherwise they just sit next to it.
34
- orderType = OrderType.Attack;
35
- }
36
- return { unitId: attacker.id, orderType, targetId: target.id };
37
- }
38
- /**
39
- *
40
- * @param attacker
41
- * @param target
42
- * @returns A number describing the weight of the given target for the attacker, or null if it should not attack it.
43
- */
44
- export function getAttackWeight(attacker, target) {
45
- const { rx: x, ry: y } = attacker.tile;
46
- const { rx: hX, ry: hY } = target.tile;
47
- if (!attacker.primaryWeapon?.projectileRules.isAntiAir && target.zone === ZoneType.Air) {
48
- return null;
49
- }
50
- if (!attacker.primaryWeapon?.projectileRules.isAntiGround && target.zone === ZoneType.Ground) {
51
- return null;
52
- }
53
- return 1000000 - getDistanceBetweenPoints(new Vector2(x, y), new Vector2(hX, hY));
54
- }
55
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,EACX,UAAU,EACV,SA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AAC,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACtF,CAAC"}
@@ -1,48 +0,0 @@
1
- import _ from "lodash";
2
- import { disband, grabCombatants } from "../squadBehaviour.js";
3
- import { getDistanceBetween, getDistanceBetweenUnits } from "../../map/map.js";
4
- import { manageAttackMicro } from "./common.js";
5
- // If no enemies are seen in a circle IDLE_CHECK_RADIUS*radius for IDLE_COOLDOWN_TICKS ticks, the mission is disbanded.
6
- const IDLE_CHECK_RADIUS_RATIO = 2;
7
- const IDLE_COOLDOWN_TICKS = 15 * 30;
8
- const GRAB_RADIUS = 2;
9
- export class DefenceSquad {
10
- constructor(defenceArea, radius) {
11
- this.defenceArea = defenceArea;
12
- this.radius = radius;
13
- this.lastIdleCheck = null;
14
- }
15
- onAiUpdate(gameApi, actionsApi, playerData, squad, matchAwareness) {
16
- const enemyUnits = gameApi.getVisibleUnits(playerData.name, "hostile", (r) => r.isSelectableCombatant);
17
- const hasEnemiesInIdleCheckRadius = enemyUnits
18
- .map((unitId) => gameApi.getUnitData(unitId))
19
- .some((unit) => !!unit &&
20
- unit.tile &&
21
- getDistanceBetween(unit, this.defenceArea) < IDLE_CHECK_RADIUS_RATIO * this.radius);
22
- if (this.lastIdleCheck === null) {
23
- this.lastIdleCheck = gameApi.getCurrentTick();
24
- }
25
- else if (!hasEnemiesInIdleCheckRadius &&
26
- gameApi.getCurrentTick() > this.lastIdleCheck + IDLE_COOLDOWN_TICKS) {
27
- return disband();
28
- }
29
- const enemiesInRadius = enemyUnits
30
- .map((unitId) => gameApi.getUnitData(unitId))
31
- .filter((unit) => !!unit && unit.tile && getDistanceBetween(unit, this.defenceArea) < this.radius)
32
- .map((unit) => unit);
33
- const defenders = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant);
34
- defenders.forEach((defender) => {
35
- // Find closest attacking unit
36
- if (defender.isIdle) {
37
- const closestEnemy = _.minBy(enemiesInRadius.map((enemy) => ({
38
- enemy,
39
- distance: getDistanceBetweenUnits(defender, enemy),
40
- })), "distance");
41
- if (closestEnemy) {
42
- manageAttackMicro(actionsApi, defender, closestEnemy.enemy);
43
- }
44
- }
45
- });
46
- return grabCombatants(this.defenceArea, this.radius * GRAB_RADIUS);
47
- }
48
- }
@@ -1,38 +0,0 @@
1
- import { OrderType } from "@chronodivide/game-api";
2
- import { disband, noop, requestUnits } from "../squadBehaviour.js";
3
- const CAPTURE_COOLDOWN_TICKS = 30;
4
- // Capture squad
5
- export class EngineerSquad {
6
- /**
7
- * @param captureTarget ID of the target to try and capture/send engineer into.
8
- */
9
- constructor(captureTarget) {
10
- this.captureTarget = captureTarget;
11
- this.hasAttemptedCaptureWith = null;
12
- }
13
- onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, squad, matchAwareness) {
14
- const engineerTypes = ["ENGINEER", "SENGINEER"];
15
- const engineers = squad.getUnitsOfTypes(gameApi, ...engineerTypes);
16
- if (engineers.length === 0) {
17
- // Perhaps we deployed already (or the unit was destroyed), end the mission.
18
- if (this.hasAttemptedCaptureWith !== null) {
19
- return disband();
20
- }
21
- return requestUnits(engineerTypes, 100);
22
- }
23
- else if (!this.hasAttemptedCaptureWith ||
24
- gameApi.getCurrentTick() > this.hasAttemptedCaptureWith.gameTick + CAPTURE_COOLDOWN_TICKS) {
25
- actionsApi.orderUnits(engineers.map((engineer) => engineer.id), OrderType.Capture, this.captureTarget);
26
- // Add a cooldown to deploy attempts.
27
- this.hasAttemptedCaptureWith = {
28
- unitId: engineers[0].id,
29
- gameTick: gameApi.getCurrentTick(),
30
- };
31
- }
32
- return noop();
33
- }
34
- getGlobalDebugText() {
35
- return undefined;
36
- }
37
- }
38
- //# sourceMappingURL=engineerSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"engineerSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/engineerSquad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAwB,M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B,CAAC;IAEM,kBAAkB;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -1,45 +0,0 @@
1
- import { OrderType } from "@chronodivide/game-api";
2
- import { disband, noop, requestSpecificUnits, requestUnits } from "../squadBehaviour.js";
3
- const DEPLOY_COOLDOWN_TICKS = 30;
4
- // Expansion or initial base.
5
- export class ExpansionSquad {
6
- /**
7
- * @param selectedMcv ID of the MCV to try to expand with. If that unit dies, the squad will disband. If no value is provided,
8
- * the mission requests an MCV.
9
- */
10
- constructor(selectedMcv) {
11
- this.selectedMcv = selectedMcv;
12
- this.hasAttemptedDeployWith = null;
13
- }
14
- onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, squad, matchAwareness) {
15
- const mcvTypes = ["AMCV", "SMCV"];
16
- const mcvs = squad.getUnitsOfTypes(gameApi, ...mcvTypes);
17
- if (mcvs.length === 0) {
18
- // Perhaps we deployed already (or the unit was destroyed), end the mission.
19
- if (this.hasAttemptedDeployWith !== null) {
20
- return disband();
21
- }
22
- // We need an mcv!
23
- if (this.selectedMcv) {
24
- return requestSpecificUnits([this.selectedMcv], 100);
25
- }
26
- else {
27
- return requestUnits(mcvTypes, 100);
28
- }
29
- }
30
- else if (!this.hasAttemptedDeployWith ||
31
- gameApi.getCurrentTick() > this.hasAttemptedDeployWith.gameTick + DEPLOY_COOLDOWN_TICKS) {
32
- actionsApi.orderUnits(mcvs.map((mcv) => mcv.id), OrderType.DeploySelected);
33
- // Add a cooldown to deploy attempts.
34
- this.hasAttemptedDeployWith = {
35
- unitId: mcvs[0].id,
36
- gameTick: gameApi.getCurrentTick(),
37
- };
38
- }
39
- return noop();
40
- }
41
- getGlobalDebugText() {
42
- return undefined;
43
- }
44
- }
45
- //# sourceMappingURL=expansionSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expansionSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/expansionSquad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAA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AAG;gBAC1B,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClB,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;aACrC,CAAC;SACL;QACD,OAAO,IAAI,EAAE,CAAC;IAClB,CAAC;IAEM,kBAAkB;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -1,31 +0,0 @@
1
- import { OrderType } from "@chronodivide/game-api";
2
- import { disband, requestSpecificUnits } from "../squadBehaviour.js";
3
- const SCOUT_MOVE_COOLDOWN_TICKS = 30;
4
- export class RetreatSquad {
5
- constructor(unitIds, retreatToPoint) {
6
- this.unitIds = unitIds;
7
- this.retreatToPoint = retreatToPoint;
8
- this.createdAt = null;
9
- }
10
- onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, squad, matchAwareness) {
11
- if (!this.createdAt) {
12
- this.createdAt = gameApi.getCurrentTick();
13
- }
14
- if (squad.getUnitIds().length > 0) {
15
- // Only send the order once we have managed to claim some units.
16
- actionsApi.orderUnits(squad.getUnitIds(), OrderType.AttackMove, this.retreatToPoint.x, this.retreatToPoint.y);
17
- return disband();
18
- }
19
- if (this.createdAt && gameApi.getCurrentTick() > this.createdAt + 240) {
20
- // Disband automatically after 240 ticks in case we couldn't actually claim any units.
21
- return disband();
22
- }
23
- else {
24
- return requestSpecificUnits(this.unitIds, 1000);
25
- }
26
- }
27
- getGlobalDebugText() {
28
- return undefined;
29
- }
30
- }
31
- //# sourceMappingURL=retreatSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retreatSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/retreatSquad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAuB,MAAM,wBAAwB,CAAC;AAG7F,OAAO,EAA+B,OAAO,EAAQ,oBAAoB,EAAgB,MAAM,sBAAsB,CAAC;AAItH,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,MAAM,OAAO,YAAY;IAGrB,YACY,OAAiB,EACjB,cAAuB;QADvB,YAAO,GAAP,OAAO,CAAU;QACjB,mBAAc,GAAd,cAAc,CAAS;QAJ3B,cAAS,GAAkB,IAAI,CAAC;IAKrC,CAAC;IAEG,UAAU,CACb,OAAgB,EAChB,UAAsB,EACtB,aAA4B,EAC5B,UAAsB,EACtB,KAAY,EACZ,cAA8B;QAE9B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;SAC7C;QACD,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/B,gEAAgE;YAChE,UAAU,CAAC,UAAU,CACjB,KAAK,CAAC,UAAU,EAAE,EAClB,SAAS,CAAC,UAAU,EACpB,IAAI,CAAC,cAAc,CAAC,CAAC,EACrB,IAAI,CAAC,cAAc,CAAC,CAAC,CACxB,CAAC;YACF,OAAO,OAAO,EAAE,CAAC;SACpB;QACD,IAAI,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,EAAE;YACnE,sFAAsF;YACtF,OAAO,OAAO,EAAE,CAAC;SACpB;aAAM;YACH,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACnD;IACL,CAAC;IAEM,kBAAkB;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -1,93 +0,0 @@
1
- import { OrderType } from "@chronodivide/game-api";
2
- import { disband, noop, requestUnits } from "../squadBehaviour.js";
3
- import { getDistanceBetweenTileAndPoint } from "../../map/map.js";
4
- const SCOUT_MOVE_COOLDOWN_TICKS = 30;
5
- // Max units to spend on a particular scout target.
6
- const MAX_ATTEMPTS_PER_TARGET = 5;
7
- // Maximum ticks to spend trying to scout a target *without making progress towards it*.
8
- // Every time a unit gets closer to the target, the timer refreshes.
9
- const MAX_TICKS_PER_TARGET = 600;
10
- export class ScoutingSquad {
11
- constructor() {
12
- this.scoutTarget = null;
13
- this.attemptsOnCurrentTarget = 0;
14
- this.scoutTargetRefreshedAt = 0;
15
- this.lastMoveCommandTick = 0;
16
- this.scoutTargetIsPermanent = false;
17
- this.hadUnit = false;
18
- }
19
- onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, squad, matchAwareness, logger) {
20
- const scoutNames = ["ADOG", "DOG", "E1", "E2", "FV", "HTK"];
21
- const scouts = squad.getUnitsOfTypes(gameApi, ...scoutNames);
22
- if ((matchAwareness.getSectorCache().getOverallVisibility() || 0) > 0.9) {
23
- return disband();
24
- }
25
- if (scouts.length === 0) {
26
- // Count the number of times the scout dies trying to uncover the current scoutTarget.
27
- if (this.scoutTarget && this.hadUnit) {
28
- this.attemptsOnCurrentTarget++;
29
- this.hadUnit = false;
30
- }
31
- return requestUnits(scoutNames, 100);
32
- }
33
- else if (this.scoutTarget) {
34
- this.hadUnit = true;
35
- if (!this.scoutTargetIsPermanent) {
36
- if (this.attemptsOnCurrentTarget > MAX_ATTEMPTS_PER_TARGET) {
37
- logger(`Scout target ${this.scoutTarget.x},${this.scoutTarget.y} took too many attempts, moving to next`);
38
- this.setScoutTarget(null, 0);
39
- return noop();
40
- }
41
- if (gameApi.getCurrentTick() > this.scoutTargetRefreshedAt + MAX_TICKS_PER_TARGET) {
42
- logger(`Scout target ${this.scoutTarget.x},${this.scoutTarget.y} took too long, moving to next`);
43
- this.setScoutTarget(null, 0);
44
- return noop();
45
- }
46
- }
47
- const targetTile = gameApi.mapApi.getTile(this.scoutTarget.x, this.scoutTarget.y);
48
- if (!targetTile) {
49
- throw new Error(`target tile ${this.scoutTarget.x},${this.scoutTarget.y} does not exist`);
50
- }
51
- if (gameApi.getCurrentTick() > this.lastMoveCommandTick + SCOUT_MOVE_COOLDOWN_TICKS) {
52
- this.lastMoveCommandTick = gameApi.getCurrentTick();
53
- scouts.forEach((unit) => {
54
- if (this.scoutTarget) {
55
- actionsApi.orderUnits([unit.id], OrderType.AttackMove, this.scoutTarget.x, this.scoutTarget.y);
56
- }
57
- });
58
- // Check that a scout is actually moving closer to the target.
59
- const distances = scouts.map((unit) => getDistanceBetweenTileAndPoint(unit.tile, this.scoutTarget));
60
- const newMinDistance = Math.min(...distances);
61
- if (!this.scoutMinDistance || newMinDistance < this.scoutMinDistance) {
62
- logger(`Scout timeout refreshed because unit moved closer to point (${newMinDistance} < ${this.scoutMinDistance})`);
63
- this.scoutTargetRefreshedAt = gameApi.getCurrentTick();
64
- this.scoutMinDistance = newMinDistance;
65
- }
66
- }
67
- if (gameApi.mapApi.isVisibleTile(targetTile, playerData.name)) {
68
- logger(`Scout target ${this.scoutTarget.x},${this.scoutTarget.y} successfully scouted, moving to next`);
69
- this.setScoutTarget(null, gameApi.getCurrentTick());
70
- }
71
- }
72
- else {
73
- const nextScoutTarget = matchAwareness.getScoutingManager().getNewScoutTarget();
74
- if (!nextScoutTarget) {
75
- logger(`No more scouting targets available, disbanding.`);
76
- return disband();
77
- }
78
- this.setScoutTarget(nextScoutTarget, gameApi.getCurrentTick());
79
- }
80
- return noop();
81
- }
82
- setScoutTarget(target, currentTick) {
83
- this.attemptsOnCurrentTarget = 0;
84
- this.scoutTargetRefreshedAt = currentTick;
85
- this.scoutTarget = target?.asVector2() ?? null;
86
- this.scoutMinDistance = undefined;
87
- this.scoutTargetIsPermanent = target?.isPermanent ?? false;
88
- }
89
- getGlobalDebugText() {
90
- return undefined;
91
- }
92
- }
93
- //# sourceMappingURL=scoutingSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scoutingSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/scoutingSquad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,SAAS,EAAuB,MAAM,wBAAwB,CAAC;AAE7F,OAAO,EAA+B,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGhG,OAAO,EAAE,8BAA8B,EAAE,MAAM,kB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