@supalosa/chronodivide-bot 0.5.4 → 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 (124) hide show
  1. package/.env.template +4 -4
  2. package/.github/workflows/npm-publish.yml +24 -0
  3. package/README.md +108 -103
  4. package/dist/bot/bot.js +105 -105
  5. package/dist/bot/logic/awareness.js +136 -136
  6. package/dist/bot/logic/building/antiAirStaticDefence.js +42 -42
  7. package/dist/bot/logic/building/antiGroundStaticDefence.js +34 -34
  8. package/dist/bot/logic/building/{ArtilleryUnit.js → artilleryUnit.js} +18 -18
  9. package/dist/bot/logic/building/basicAirUnit.js +19 -19
  10. package/dist/bot/logic/building/basicBuilding.js +26 -26
  11. package/dist/bot/logic/building/basicGroundUnit.js +19 -19
  12. package/dist/bot/logic/building/buildingRules.js +175 -175
  13. package/dist/bot/logic/building/common.js +19 -19
  14. package/dist/bot/logic/building/harvester.js +16 -16
  15. package/dist/bot/logic/building/powerPlant.js +20 -20
  16. package/dist/bot/logic/building/queueController.js +183 -183
  17. package/dist/bot/logic/building/resourceCollectionBuilding.js +36 -36
  18. package/dist/bot/logic/common/scout.js +126 -126
  19. package/dist/bot/logic/common/utils.js +95 -95
  20. package/dist/bot/logic/composition/alliedCompositions.js +12 -12
  21. package/dist/bot/logic/composition/common.js +1 -1
  22. package/dist/bot/logic/composition/sovietCompositions.js +12 -12
  23. package/dist/bot/logic/map/map.js +44 -44
  24. package/dist/bot/logic/map/sector.js +137 -137
  25. package/dist/bot/logic/mission/actionBatcher.js +91 -91
  26. package/dist/bot/logic/mission/mission.js +122 -122
  27. package/dist/bot/logic/mission/missionController.js +321 -321
  28. package/dist/bot/logic/mission/missionFactories.js +12 -12
  29. package/dist/bot/logic/mission/missions/attackMission.js +214 -214
  30. package/dist/bot/logic/mission/missions/defenceMission.js +82 -82
  31. package/dist/bot/logic/mission/missions/engineerMission.js +63 -63
  32. package/dist/bot/logic/mission/missions/expansionMission.js +60 -60
  33. package/dist/bot/logic/mission/missions/retreatMission.js +33 -33
  34. package/dist/bot/logic/mission/missions/scoutingMission.js +133 -133
  35. package/dist/bot/logic/mission/missions/squads/combatSquad.js +115 -115
  36. package/dist/bot/logic/mission/missions/squads/common.js +57 -57
  37. package/dist/bot/logic/mission/missions/squads/squad.js +1 -1
  38. package/dist/bot/logic/threat/threat.js +22 -22
  39. package/dist/bot/logic/threat/threatCalculator.js +73 -73
  40. package/dist/exampleBot.js +100 -100
  41. package/package.json +32 -29
  42. package/src/bot/bot.ts +161 -161
  43. package/src/bot/logic/awareness.ts +245 -245
  44. package/src/bot/logic/building/antiAirStaticDefence.ts +64 -64
  45. package/src/bot/logic/building/antiGroundStaticDefence.ts +55 -55
  46. package/src/bot/logic/building/artilleryUnit.ts +39 -39
  47. package/src/bot/logic/building/basicAirUnit.ts +39 -39
  48. package/src/bot/logic/building/basicBuilding.ts +49 -49
  49. package/src/bot/logic/building/basicGroundUnit.ts +39 -39
  50. package/src/bot/logic/building/buildingRules.ts +250 -250
  51. package/src/bot/logic/building/common.ts +21 -21
  52. package/src/bot/logic/building/harvester.ts +31 -31
  53. package/src/bot/logic/building/powerPlant.ts +32 -32
  54. package/src/bot/logic/building/queueController.ts +297 -297
  55. package/src/bot/logic/building/resourceCollectionBuilding.ts +52 -52
  56. package/src/bot/logic/common/scout.ts +183 -183
  57. package/src/bot/logic/common/utils.ts +120 -120
  58. package/src/bot/logic/composition/alliedCompositions.ts +22 -22
  59. package/src/bot/logic/composition/common.ts +3 -3
  60. package/src/bot/logic/composition/sovietCompositions.ts +21 -21
  61. package/src/bot/logic/map/map.ts +66 -66
  62. package/src/bot/logic/map/sector.ts +174 -174
  63. package/src/bot/logic/mission/actionBatcher.ts +124 -124
  64. package/src/bot/logic/mission/mission.ts +232 -232
  65. package/src/bot/logic/mission/missionController.ts +413 -413
  66. package/src/bot/logic/mission/missionFactories.ts +51 -51
  67. package/src/bot/logic/mission/missions/attackMission.ts +336 -336
  68. package/src/bot/logic/mission/missions/defenceMission.ts +151 -151
  69. package/src/bot/logic/mission/missions/engineerMission.ts +113 -113
  70. package/src/bot/logic/mission/missions/expansionMission.ts +104 -104
  71. package/src/bot/logic/mission/missions/retreatMission.ts +54 -54
  72. package/src/bot/logic/mission/missions/scoutingMission.ts +186 -186
  73. package/src/bot/logic/mission/missions/squads/combatSquad.ts +160 -160
  74. package/src/bot/logic/mission/missions/squads/common.ts +63 -63
  75. package/src/bot/logic/mission/missions/squads/squad.ts +19 -19
  76. package/src/bot/logic/threat/threat.ts +15 -15
  77. package/src/bot/logic/threat/threatCalculator.ts +100 -100
  78. package/src/exampleBot.ts +111 -111
  79. package/tsconfig.json +73 -73
  80. package/dist/bot/logic/awarenessImpl.js +0 -132
  81. package/dist/bot/logic/awarenessImpl.js.map +0 -1
  82. package/dist/bot/logic/building/building.js +0 -126
  83. package/dist/bot/logic/building/building.js.map +0 -1
  84. package/dist/bot/logic/mission/behaviours/combatSquad.js +0 -124
  85. package/dist/bot/logic/mission/behaviours/combatSquad.js.map +0 -1
  86. package/dist/bot/logic/mission/behaviours/common.js +0 -58
  87. package/dist/bot/logic/mission/behaviours/common.js.map +0 -1
  88. package/dist/bot/logic/mission/behaviours/engineerSquad.js +0 -39
  89. package/dist/bot/logic/mission/behaviours/engineerSquad.js.map +0 -1
  90. package/dist/bot/logic/mission/behaviours/expansionSquad.js +0 -46
  91. package/dist/bot/logic/mission/behaviours/expansionSquad.js.map +0 -1
  92. package/dist/bot/logic/mission/behaviours/retreatSquad.js +0 -31
  93. package/dist/bot/logic/mission/behaviours/retreatSquad.js.map +0 -1
  94. package/dist/bot/logic/mission/behaviours/scoutingSquad.js +0 -94
  95. package/dist/bot/logic/mission/behaviours/scoutingSquad.js.map +0 -1
  96. package/dist/bot/logic/mission/missions/basicMission.js +0 -13
  97. package/dist/bot/logic/mission/missions/basicMission.js.map +0 -1
  98. package/dist/bot/logic/mission/missions/missionBehaviour.js +0 -2
  99. package/dist/bot/logic/mission/missions/missionBehaviour.js.map +0 -1
  100. package/dist/bot/logic/mission/missions/oneTimeMission.js +0 -27
  101. package/dist/bot/logic/mission/missions/oneTimeMission.js.map +0 -1
  102. package/dist/bot/logic/squad/behaviours/attackSquad.js +0 -89
  103. package/dist/bot/logic/squad/behaviours/combatSquad.js +0 -102
  104. package/dist/bot/logic/squad/behaviours/combatSquad.js.map +0 -1
  105. package/dist/bot/logic/squad/behaviours/common.js +0 -40
  106. package/dist/bot/logic/squad/behaviours/common.js.map +0 -1
  107. package/dist/bot/logic/squad/behaviours/defenceSquad.js +0 -61
  108. package/dist/bot/logic/squad/behaviours/engineerSquad.js +0 -36
  109. package/dist/bot/logic/squad/behaviours/engineerSquad.js.map +0 -1
  110. package/dist/bot/logic/squad/behaviours/expansionSquad.js +0 -43
  111. package/dist/bot/logic/squad/behaviours/expansionSquad.js.map +0 -1
  112. package/dist/bot/logic/squad/behaviours/retreatSquad.js +0 -28
  113. package/dist/bot/logic/squad/behaviours/retreatSquad.js.map +0 -1
  114. package/dist/bot/logic/squad/behaviours/scoutingSquad.js +0 -86
  115. package/dist/bot/logic/squad/behaviours/scoutingSquad.js.map +0 -1
  116. package/dist/bot/logic/squad/squad.js +0 -126
  117. package/dist/bot/logic/squad/squad.js.map +0 -1
  118. package/dist/bot/logic/squad/squadBehaviour.js +0 -6
  119. package/dist/bot/logic/squad/squadBehaviour.js.map +0 -1
  120. package/dist/bot/logic/squad/squadBehaviours.js +0 -7
  121. package/dist/bot/logic/squad/squadBehaviours.js.map +0 -1
  122. package/dist/bot/logic/squad/squadController.js +0 -199
  123. package/dist/bot/logic/squad/squadController.js.map +0 -1
  124. /package/dist/bot/logic/building/{ArtilleryUnit.js.map → artilleryUnit.js.map} +0 -0
@@ -1,94 +0,0 @@
1
- import { OrderType } from "@chronodivide/game-api";
2
- import { getDistanceBetweenTileAndPoint } from "../../map/map.js";
3
- import { disbandMission, noop, requestUnits } from "../mission.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(priority) {
12
- this.priority = priority;
13
- this.scoutTarget = null;
14
- this.attemptsOnCurrentTarget = 0;
15
- this.scoutTargetRefreshedAt = 0;
16
- this.lastMoveCommandTick = 0;
17
- this.scoutTargetIsPermanent = false;
18
- this.hadUnit = false;
19
- }
20
- onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, mission, matchAwareness, logger) {
21
- const scoutNames = ["ADOG", "DOG", "E1", "E2", "FV", "HTK"];
22
- const scouts = mission.getUnitsOfTypes(gameApi, ...scoutNames);
23
- if ((matchAwareness.getSectorCache().getOverallVisibility() || 0) > 0.9) {
24
- return disbandMission();
25
- }
26
- if (scouts.length === 0) {
27
- // Count the number of times the scout dies trying to uncover the current scoutTarget.
28
- if (this.scoutTarget && this.hadUnit) {
29
- this.attemptsOnCurrentTarget++;
30
- this.hadUnit = false;
31
- }
32
- return requestUnits(scoutNames, this.priority);
33
- }
34
- else if (this.scoutTarget) {
35
- this.hadUnit = true;
36
- if (!this.scoutTargetIsPermanent) {
37
- if (this.attemptsOnCurrentTarget > MAX_ATTEMPTS_PER_TARGET) {
38
- logger(`Scout target ${this.scoutTarget.x},${this.scoutTarget.y} took too many attempts, moving to next`);
39
- this.setScoutTarget(null, 0);
40
- return noop();
41
- }
42
- if (gameApi.getCurrentTick() > this.scoutTargetRefreshedAt + MAX_TICKS_PER_TARGET) {
43
- logger(`Scout target ${this.scoutTarget.x},${this.scoutTarget.y} took too long, moving to next`);
44
- this.setScoutTarget(null, 0);
45
- return noop();
46
- }
47
- }
48
- const targetTile = gameApi.mapApi.getTile(this.scoutTarget.x, this.scoutTarget.y);
49
- if (!targetTile) {
50
- throw new Error(`target tile ${this.scoutTarget.x},${this.scoutTarget.y} does not exist`);
51
- }
52
- if (gameApi.getCurrentTick() > this.lastMoveCommandTick + SCOUT_MOVE_COOLDOWN_TICKS) {
53
- this.lastMoveCommandTick = gameApi.getCurrentTick();
54
- scouts.forEach((unit) => {
55
- if (this.scoutTarget) {
56
- actionsApi.orderUnits([unit.id], OrderType.AttackMove, this.scoutTarget.x, this.scoutTarget.y);
57
- }
58
- });
59
- // Check that a scout is actually moving closer to the target.
60
- const distances = scouts.map((unit) => getDistanceBetweenTileAndPoint(unit.tile, this.scoutTarget));
61
- const newMinDistance = Math.min(...distances);
62
- if (!this.scoutMinDistance || newMinDistance < this.scoutMinDistance) {
63
- logger(`Scout timeout refreshed because unit moved closer to point (${newMinDistance} < ${this.scoutMinDistance})`);
64
- this.scoutTargetRefreshedAt = gameApi.getCurrentTick();
65
- this.scoutMinDistance = newMinDistance;
66
- }
67
- }
68
- if (gameApi.mapApi.isVisibleTile(targetTile, playerData.name)) {
69
- logger(`Scout target ${this.scoutTarget.x},${this.scoutTarget.y} successfully scouted, moving to next`);
70
- this.setScoutTarget(null, gameApi.getCurrentTick());
71
- }
72
- }
73
- else {
74
- const nextScoutTarget = matchAwareness.getScoutingManager().getNewScoutTarget();
75
- if (!nextScoutTarget) {
76
- logger(`No more scouting targets available, disbanding.`);
77
- return disbandMission();
78
- }
79
- this.setScoutTarget(nextScoutTarget, gameApi.getCurrentTick());
80
- }
81
- return noop();
82
- }
83
- setScoutTarget(target, currentTick) {
84
- this.attemptsOnCurrentTarget = 0;
85
- this.scoutTargetRefreshedAt = currentTick;
86
- this.scoutTarget = target?.asVector2() ?? null;
87
- this.scoutMinDistance = undefined;
88
- this.scoutTargetIsPermanent = target?.isPermanent ?? false;
89
- }
90
- getGlobalDebugText() {
91
- return undefined;
92
- }
93
- }
94
- //# sourceMappingURL=scoutingSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scoutingSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/mission/behaviours/scoutingSquad.ts"],"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AAE,CAAC;YAChF,IAAI,CAAC,eAAe,EAAE;gBAClB,MAAM,CAAC,iDAAiD,CAAC,CAAC;gBAC1D,OAAO,cAAc,EAAE,CAAC;aAC3B;YACD,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,cAAc,CAAC,MAAqC,EAAE,WAAmB;QACrE,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,sBAAsB,GAAG,WAAW,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC;QAC/C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,sBAAsB,GAAG,MAAM,EAAE,WAAW,IAAI,KAAK,CAAC;IAC/D,CAAC;IAEM,kBAAkB;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -1,13 +0,0 @@
1
- import { Mission } from "../mission.js";
2
- /**
3
- * A mission that just delegates to the mission behaviour.
4
- */
5
- export class BasicMission extends Mission {
6
- constructor(uniqueName, behaviour, logger) {
7
- super(uniqueName, behaviour, logger);
8
- }
9
- _onAiUpdate(gameApi, actionsApi, playerData, matchAwareness, actionBatcher) {
10
- return this.getBehaviour.onAiUpdate(gameApi, actionsApi, actionBatcher, playerData, this, matchAwareness, this.logger);
11
- }
12
- }
13
- //# sourceMappingURL=basicMission.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basicMission.js","sourceRoot":"","sources":["../../../../../src/bot/logic/mission/missions/basicMission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuC,MAAM,eAAe,CAAC;AAM7E;;GAEG;AACH,MAAM,OAAgB,YAAwD,SAAQ,OAAa;IAC/F,YAAY,UAAkB,EAAE,SAAY,EAAE,MAAmB;QAC7D,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,WAAW,CACP,OAAgB,EAChB,UAAsB,EACtB,UAAsB,EACtB,cAA8B,EAC9B,aAA4B;QAE5B,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAC/B,OAAO,EACP,UAAU,EACV,aAAa,EACb,UAAU,EACV,IAAI,EACJ,cAAc,EACd,IAAI,CAAC,MAAM,CACd,CAAC;IACN,CAAC;CACJ"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=missionBehaviour.js.map
@@ -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,89 +0,0 @@
1
- import _ from "lodash";
2
- import { ObjectType, OrderType, } from "@chronodivide/game-api";
3
- import { grabCombatants, noop } from "../squadBehaviour.js";
4
- import { getDistanceBetweenPoints, getDistanceBetweenUnits } from "../../map/map.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 TARGET_UPDATE_INTERVAL_TICKS = 4;
9
- const GRAB_INTERVAL_TICKS = 10;
10
- const GRAB_RADIUS = 30;
11
- export class AttackSquad {
12
- constructor(rallyArea, attackArea, radius) {
13
- this.rallyArea = rallyArea;
14
- this.attackArea = attackArea;
15
- this.radius = radius;
16
- this.lastIdleCheck = null;
17
- this.lastGrab = null;
18
- this.lastCommand = null;
19
- }
20
- setAttackArea(attackArea) {
21
- this.attackArea = attackArea;
22
- }
23
- onAiUpdate(gameApi, actionsApi, playerData, squad, matchAwareness) {
24
- if (!this.lastCommand || gameApi.getCurrentTick() > this.lastCommand + TARGET_UPDATE_INTERVAL_TICKS) {
25
- const units = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant);
26
- const attackPoint = this.attackArea || playerData.startLocation;
27
- for (const attacker of units) {
28
- if (attacker.isIdle) {
29
- const { rx: x, ry: y } = attacker.tile;
30
- const range = attacker.primaryWeapon?.maxRange ?? attacker.secondaryWeapon?.maxRange ?? 5;
31
- const nearbyHostiles = matchAwareness.getHostilesInRadius2(x, y, range * 2);
32
- const closest = _.minBy(nearbyHostiles, ({ x: hX, y: hY }) => getDistanceBetweenPoints({ x, y }, { x: hX, y: hY }));
33
- const closestUnit = closest ? gameApi.getUnitData(closest.unitId) ?? null : null;
34
- if (closestUnit) {
35
- this.manageAttackMicro(actionsApi, attacker, closestUnit);
36
- }
37
- else {
38
- this.manageMoveMicro(actionsApi, attacker, attackPoint);
39
- }
40
- }
41
- }
42
- this.lastCommand = gameApi.getCurrentTick();
43
- }
44
- if (!this.lastGrab || gameApi.getCurrentTick() > this.lastGrab + GRAB_INTERVAL_TICKS) {
45
- this.lastGrab = gameApi.getCurrentTick();
46
- return grabCombatants(this.rallyArea, this.radius * GRAB_RADIUS);
47
- }
48
- else {
49
- return noop();
50
- }
51
- }
52
- // Micro methods
53
- manageMoveMicro(actionsApi, attacker, attackPoint) {
54
- if (attacker.name === "E1") {
55
- if (attacker.canMove === false) {
56
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
57
- }
58
- }
59
- actionsApi.orderUnits([attacker.id], OrderType.AttackMove, attackPoint.x, attackPoint.y);
60
- }
61
- manageAttackMicro(actionsApi, attacker, target) {
62
- const distance = getDistanceBetweenUnits(attacker, target);
63
- if (attacker.name === "E1") {
64
- // Para (deployed weapon) range is 5.
65
- const deployedWeaponRange = attacker.secondaryWeapon?.maxRange || 5;
66
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
67
- //console.dir({distance, attacker: attacker.name, canMove: attacker.canMove, primaryMaxRange: attacker.primaryWeapon?.maxRange, secondaryMaxRange: attacker.secondaryWeapon?.maxRange})
68
- if (attacker.canMove && distance <= deployedWeaponRange * 0.8) {
69
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
70
- return;
71
- }
72
- else if (!attacker.canMove && distance > deployedWeaponRange) {
73
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
74
- return;
75
- }
76
- }
77
- let targetData = target;
78
- let orderType = OrderType.AttackMove;
79
- const primaryWeaponRange = attacker.primaryWeapon?.maxRange || 5;
80
- if (targetData?.type == ObjectType.Building && distance < primaryWeaponRange * 0.8) {
81
- orderType = OrderType.Attack;
82
- }
83
- else if (targetData?.rules.canDisguise) {
84
- // Special case for mirage tank/spy as otherwise they just sit next to it.
85
- orderType = OrderType.Attack;
86
- }
87
- actionsApi.orderUnits([attacker.id], orderType, target.id);
88
- }
89
- }
@@ -1,102 +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 = 20;
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
- // If the radius expands beyond this amount then we should switch back to gathering mode.
13
- const MAX_GATHER_RADIUS = 15;
14
- const GATHER_RATIO = 10;
15
- var SquadState;
16
- (function (SquadState) {
17
- SquadState[SquadState["Gathering"] = 0] = "Gathering";
18
- SquadState[SquadState["Attacking"] = 1] = "Attacking";
19
- })(SquadState || (SquadState = {}));
20
- export class CombatSquad {
21
- /**
22
- *
23
- * @param rallyArea the initial location to grab combatants
24
- * @param targetArea
25
- * @param radius
26
- */
27
- constructor(rallyArea, targetArea, radius) {
28
- this.rallyArea = rallyArea;
29
- this.targetArea = targetArea;
30
- this.radius = radius;
31
- this.lastGrab = null;
32
- this.lastCommand = null;
33
- this.state = SquadState.Gathering;
34
- }
35
- setAttackArea(targetArea) {
36
- this.targetArea = targetArea;
37
- }
38
- onAiUpdate(gameApi, actionsApi, playerData, squad, matchAwareness, logger) {
39
- if (squad.getUnitIds().length > 0 && (!this.lastCommand || gameApi.getCurrentTick() > this.lastCommand + TARGET_UPDATE_INTERVAL_TICKS)) {
40
- this.lastCommand = gameApi.getCurrentTick();
41
- const centerOfMass = squad.getCenterOfMass();
42
- const maxDistance = squad.getMaxDistanceToCenterOfMass();
43
- const units = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant);
44
- // Only use ground units for center of mass.
45
- const groundUnits = squad.getUnitsMatching(gameApi, (r) => r.rules.isSelectableCombatant &&
46
- (r.rules.movementZone === MovementZone.Infantry ||
47
- r.rules.movementZone === MovementZone.Normal ||
48
- r.rules.movementZone === MovementZone.InfantryDestroyer));
49
- if (this.state === SquadState.Gathering) {
50
- const requiredGatherRadius = Math.sqrt(groundUnits.length) * GATHER_RATIO + MIN_GATHER_RADIUS;
51
- if (centerOfMass &&
52
- maxDistance &&
53
- gameApi.mapApi.getTile(centerOfMass.x, centerOfMass.y) !== undefined &&
54
- maxDistance > requiredGatherRadius) {
55
- units.forEach((unit) => {
56
- manageMoveMicro(actionsApi, unit, centerOfMass);
57
- });
58
- }
59
- else {
60
- logger(`CombatSquad ${squad.getName()} switching back to attack mode (${maxDistance})`);
61
- this.state = SquadState.Attacking;
62
- }
63
- }
64
- else {
65
- const targetPoint = this.targetArea || playerData.startLocation;
66
- const requiredGatherRadius = Math.sqrt(groundUnits.length) * GATHER_RATIO + MAX_GATHER_RADIUS;
67
- if (centerOfMass &&
68
- maxDistance &&
69
- gameApi.mapApi.getTile(centerOfMass.x, centerOfMass.y) !== undefined &&
70
- maxDistance > requiredGatherRadius) {
71
- // Switch back to gather mode
72
- logger(`CombatSquad ${squad.getName()} switching back to gather (${maxDistance})`);
73
- this.state = SquadState.Gathering;
74
- return noop();
75
- }
76
- for (const unit of units) {
77
- if (unit.isIdle) {
78
- const { rx: x, ry: y } = unit.tile;
79
- const range = unit.primaryWeapon?.maxRange ?? unit.secondaryWeapon?.maxRange ?? 5;
80
- const nearbyHostiles = matchAwareness.getHostilesNearPoint(x, y, range * 2);
81
- const closest = _.minBy(nearbyHostiles, ({ x: hX, y: hY }) => getDistanceBetweenPoints({ x, y }, { x: hX, y: hY }));
82
- const closestUnit = closest ? gameApi.getUnitData(closest.unitId) ?? null : null;
83
- if (closestUnit) {
84
- manageAttackMicro(actionsApi, unit, closestUnit);
85
- }
86
- else {
87
- manageMoveMicro(actionsApi, unit, targetPoint);
88
- }
89
- }
90
- }
91
- }
92
- }
93
- if (!this.lastGrab || gameApi.getCurrentTick() > this.lastGrab + GRAB_INTERVAL_TICKS) {
94
- this.lastGrab = gameApi.getCurrentTick();
95
- return grabCombatants(squad.getCenterOfMass() ?? this.rallyArea, GRAB_RADIUS);
96
- }
97
- else {
98
- return noop();
99
- }
100
- }
101
- }
102
- //# sourceMappingURL=combatSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"combatSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squad/behaviours/combatSquad.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAuB,YAAY,EAAuB,MAAM,wBAAwB,CAAC;AAEhG,OAAO,EAA+B,cAAc,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGjE,MAAM,4BAA4B,GAAG,EAAE,C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AU,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;yBACpD;6BAAM;4BACH,eAAe,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;yBAClD;qBACJ;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,40 +0,0 @@
1
- import { AttackState, ObjectType, OrderType, StanceType } from "@chronodivide/game-api";
2
- import { getDistanceBetweenUnits } from "../../map/map.js";
3
- // Micro methods
4
- export function manageMoveMicro(actionsApi, attacker, attackPoint) {
5
- if (attacker.name === "E1") {
6
- const isDeployed = attacker.stance === StanceType.Deployed;
7
- if (isDeployed) {
8
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
9
- }
10
- }
11
- actionsApi.orderUnits([attacker.id], OrderType.Move, attackPoint.x, attackPoint.y);
12
- }
13
- export function manageAttackMicro(actionsApi, 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
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
21
- return;
22
- }
23
- else if (isDeployed && distance > deployedWeaponRange) {
24
- actionsApi.orderUnits([attacker.id], OrderType.DeploySelected);
25
- return;
26
- }
27
- }
28
- let targetData = target;
29
- let orderType = OrderType.Attack;
30
- const primaryWeaponRange = attacker.primaryWeapon?.maxRange || 5;
31
- if (targetData?.type == ObjectType.Building && distance < primaryWeaponRange * 0.8) {
32
- orderType = OrderType.Attack;
33
- }
34
- else if (targetData?.rules.canDisguise) {
35
- // Special case for mirage tank/spy as otherwise they just sit next to it.
36
- orderType = OrderType.Attack;
37
- }
38
- actionsApi.orderUnits([attacker.id], orderType, target.id);
39
- }
40
- //# 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,EAAc,WAAW,EAAE,UAAU,EAAE,SAAS,EAAW,UAAU,EAAY,MAAM,wBAAwB,CAAC;AACvH,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,UAAsB,EAAE,QAAkB,EAAE,WAAoB;IAC5F,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE;QACxB,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,QAAQ,CAAC;QAC3D,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;SAClE;KACJ;IACD,UAAU,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAsB,EAAE,QAAkB,EAAE,MAAgB;IAC1F,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3D,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE;QACxB,qCAAqC;QACrC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,eAAe,EAAE,QAAQ,IAAI,CAAC,CAAC;QACpE,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,QAAQ,CAAC;QAC3D,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ,IAAI,mBAAmB,IAAI,QAAQ,CAAC,WAAW,KAAK,WAAW,CAAC,SAAS,CAAC,EAAE;YACpG,UAAU,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;YAC/D,OAAO;SACV;aAAM,IAAI,UAAU,IAAI,QAAQ,GAAG,mBAAmB,EAAE;YACrD,UAAU,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;YAC/D,OAAO;SACV;KACJ;IACD,IAAI,UAAU,GAAG,MAAM,CAAC;IACxB,IAAI,SAAS,GAAc,SAAS,CAAC,MAAM,CAAC;IAC5C,MAAM,kBAAkB,GAAG,QAAQ,CAAC,aAAa,EAAE,QAAQ,IAAI,CAAC,CAAC;IACjE,IAAI,UAAU,EAAE,IAAI,IAAI,UAAU,CAAC,QAAQ,IAAI,QAAQ,GAAG,kBAAkB,GAAG,GAAG,EAAE;QAChF,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;KAChC;SAAM,IAAI,UAAU,EAAE,KAAK,CAAC,WAAW,EAAE;QACtC,0EAA0E;QAC1E,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;KAChC;IACD,UAAU,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,61 +0,0 @@
1
- import _ from "lodash";
2
- import { OrderType, } from "@chronodivide/game-api";
3
- import { disband, grabCombatants } from "../squadBehaviour.js";
4
- import { getDistanceBetween, getDistanceBetweenUnits } from "../../map/map.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
- this.manageMicro(actionsApi, defender, closestEnemy.enemy, closestEnemy.distance);
43
- }
44
- }
45
- });
46
- return grabCombatants(this.defenceArea, this.radius * GRAB_RADIUS);
47
- }
48
- // Micro methods
49
- manageMicro(actionsApi, defender, closestEnemy, distance) {
50
- if (defender.name === "E1") {
51
- // Para (deployed weapon) range is 5.
52
- if (defender.canMove && distance <= 4) {
53
- actionsApi.orderUnits([defender.id], OrderType.DeploySelected);
54
- }
55
- else if (!defender.canMove && distance >= 5) {
56
- actionsApi.orderUnits([defender.id], OrderType.DeploySelected);
57
- }
58
- }
59
- actionsApi.orderUnits([defender.id], OrderType.AttackMove, closestEnemy.tile.rx, closestEnemy.tile.ry);
60
- }
61
- }
@@ -1,36 +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
- ;
14
- onAiUpdate(gameApi, actionsApi, playerData, squad, matchAwareness) {
15
- const engineerTypes = ["ENGINEER", "SENGINEER"];
16
- const engineers = squad.getUnitsOfTypes(gameApi, ...engineerTypes);
17
- if (engineers.length === 0) {
18
- // Perhaps we deployed already (or the unit was destroyed), end the mission.
19
- if (this.hasAttemptedCaptureWith !== null) {
20
- return disband();
21
- }
22
- return requestUnits(engineerTypes, 100);
23
- }
24
- else if (!this.hasAttemptedCaptureWith ||
25
- gameApi.getCurrentTick() > this.hasAttemptedCaptureWith.gameTick + CAPTURE_COOLDOWN_TICKS) {
26
- actionsApi.orderUnits(engineers.map((engineer) => engineer.id), OrderType.Capture, this.captureTarget);
27
- // Add a cooldown to deploy attempts.
28
- this.hasAttemptedCaptureWith = {
29
- unitId: engineers[0].id,
30
- gameTick: gameApi.getCurrentTick(),
31
- };
32
- }
33
- return noop();
34
- }
35
- }
36
- //# sourceMappingURL=engineerSquad.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"engineerSquad.js","sourceRoot":"","sources":["../../../../../src/bot/logic/squ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AAC,cAAc,EAAE;aACrC,CAAC;SACL;QACD,OAAO,IAAI,EAAE,CAAC;IAClB,CAAC;CACJ"}
@@ -1,43 +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
- ;
15
- onAiUpdate(gameApi, actionsApi, playerData, squad, matchAwareness) {
16
- const mcvTypes = ["AMCV", "SMCV"];
17
- const mcvs = squad.getUnitsOfTypes(gameApi, ...mcvTypes);
18
- if (mcvs.length === 0) {
19
- // Perhaps we deployed already (or the unit was destroyed), end the mission.
20
- if (this.hasAttemptedDeployWith !== null) {
21
- return disband();
22
- }
23
- // We need an mcv!
24
- if (this.selectedMcv) {
25
- return requestSpecificUnits([this.selectedMcv], 100);
26
- }
27
- else {
28
- return requestUnits(mcvTypes, 100);
29
- }
30
- }
31
- else if (!this.hasAttemptedDeployWith ||
32
- gameApi.getCurrentTick() > this.hasAttemptedDeployWith.gameTick + DEPLOY_COOLDOWN_TICKS) {
33
- actionsApi.orderUnits(mcvs.map((mcv) => mcv.id), OrderType.DeploySelected);
34
- // Add a cooldown to deploy attempts.
35
- this.hasAttemptedDeployWith = {
36
- unitId: mcvs[0].id,
37
- gameTick: gameApi.getCurrentTick(),
38
- };
39
- }
40
- return noop();
41
- }
42
- }
43
- //# 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,SAAS,EAAwB,MAAM,wBAA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E,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClB,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;aACrC,CAAC;SACL;QACD,OAAO,IAAI,EAAE,CAAC;IAClB,CAAC;CACJ"}
@@ -1,28 +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, 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
- }
28
- //# 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,EAAiC,MAAM,wBAAwB,CAAC;AAGvG,OAAO,EAA+B,OAAO,EAAQ,oBAAoB,EAAgB,MAAM,sBAAsB,CAAC;AAGtH,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,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;CACJ"}