@supalosa/chronodivide-bot 0.5.3 → 0.5.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.
- package/README.md +6 -0
- package/dist/bot/bot.js.map +1 -1
- package/dist/bot/logic/awarenessImpl.js +132 -0
- package/dist/bot/logic/awarenessImpl.js.map +1 -0
- package/dist/bot/logic/building/antiGroundStaticDefence.js +6 -2
- package/dist/bot/logic/building/antiGroundStaticDefence.js.map +1 -1
- package/dist/bot/logic/building/building.js +55 -11
- package/dist/bot/logic/building/building.js.map +1 -0
- package/dist/bot/logic/building/buildingRules.js +15 -14
- package/dist/bot/logic/building/buildingRules.js.map +1 -1
- package/dist/bot/logic/building/common.js +13 -12
- package/dist/bot/logic/building/common.js.map +1 -1
- package/dist/bot/logic/common/utils.js +12 -2
- package/dist/bot/logic/common/utils.js.map +1 -1
- package/dist/bot/logic/mission/behaviours/combatSquad.js +1 -1
- package/dist/bot/logic/mission/behaviours/combatSquad.js.map +1 -1
- package/dist/bot/logic/mission/behaviours/common.js +5 -3
- package/dist/bot/logic/mission/behaviours/common.js.map +1 -1
- package/dist/bot/logic/squad/behaviours/attackSquad.js +63 -56
- package/dist/bot/logic/squad/behaviours/combatSquad.js +21 -25
- package/dist/bot/logic/squad/behaviours/combatSquad.js.map +1 -1
- package/dist/bot/logic/squad/behaviours/common.js +11 -26
- package/dist/bot/logic/squad/behaviours/common.js.map +1 -1
- package/dist/bot/logic/squad/behaviours/defenceSquad.js +15 -2
- package/dist/bot/logic/squad/behaviours/engineerSquad.js +2 -4
- package/dist/bot/logic/squad/behaviours/engineerSquad.js.map +1 -1
- package/dist/bot/logic/squad/behaviours/expansionSquad.js +2 -4
- package/dist/bot/logic/squad/behaviours/expansionSquad.js.map +1 -1
- package/dist/bot/logic/squad/behaviours/retreatSquad.js +1 -4
- package/dist/bot/logic/squad/behaviours/retreatSquad.js.map +1 -1
- package/dist/bot/logic/squad/behaviours/scoutingSquad.js +18 -25
- package/dist/bot/logic/squad/behaviours/scoutingSquad.js.map +1 -1
- package/dist/bot/logic/squad/squad.js +10 -10
- package/dist/bot/logic/squad/squad.js.map +1 -1
- package/dist/bot/logic/squad/squadBehaviour.js.map +1 -1
- package/dist/bot/logic/squad/squadController.js +5 -21
- package/dist/bot/logic/squad/squadController.js.map +1 -1
- package/dist/exampleBot.js +10 -22
- package/dist/exampleBot.js.map +1 -1
- package/package.json +3 -3
- package/src/bot/bot.ts +2 -2
- package/src/bot/logic/building/antiGroundStaticDefence.ts +5 -1
- package/src/bot/logic/building/buildingRules.ts +19 -16
- package/src/bot/logic/building/common.ts +13 -15
- package/src/bot/logic/common/utils.ts +12 -4
- package/src/bot/logic/threat/threat.ts +15 -15
- package/src/exampleBot.ts +10 -23
- package/dist/bot/logic/building/massedAntiGroundUnit.js +0 -20
- package/dist/bot/logic/building/queues.js +0 -19
- package/dist/bot/logic/knowledge.js +0 -1
- package/dist/bot/logic/mission/basicMission.js +0 -26
- package/dist/bot/logic/mission/expansionMission.js +0 -32
- package/dist/bot/logic/squad/behaviours/actionBatcher.js +0 -36
- package/dist/bot/logic/squad/behaviours/actionBatcher.js.map +0 -1
- package/dist/bot/logic/squad/behaviours/squadExpansion.js +0 -31
- package/dist/bot/logic/squad/behaviours/squadScouters.js +0 -8
- /package/dist/bot/logic/building/{artilleryUnit.js.map → ArtilleryUnit.js.map} +0 -0
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Mission, disbandMission, noop } from "./mission.js";
|
|
2
|
-
import { SquadExpansion } from "../squad/behaviours/expansionSquad.js";
|
|
3
|
-
import { Squad } from "../squad/squad.js";
|
|
4
|
-
/**
|
|
5
|
-
* A mission that tries to create an MCV (if it doesn't exist) and deploy it somewhere it can be deployed.
|
|
6
|
-
*/
|
|
7
|
-
export class ExpansionMission extends Mission {
|
|
8
|
-
constructor(uniqueName, priority) {
|
|
9
|
-
super(uniqueName, priority);
|
|
10
|
-
this.hadSquad = false;
|
|
11
|
-
}
|
|
12
|
-
onAiUpdate(gameApi, playerData, threatData) {
|
|
13
|
-
if (this.getSquad() === null) {
|
|
14
|
-
if (!this.hadSquad) {
|
|
15
|
-
this.hadSquad = true;
|
|
16
|
-
return this.setSquad(new Squad(this.getUniqueName(), new SquadExpansion(), this));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return disbandMission();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return noop();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export class ExpansionMissionFactory {
|
|
28
|
-
maybeCreateMission(gameApi, playerData, threatData, existingMissions) {
|
|
29
|
-
// No auto-expansion missions.
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -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,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AAC,EAAE,EAAE;gBACzD,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;gBAClC,UAAU,CAAC,UAAU,CACjB,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAC7C,WAAW,EACX,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,CAAC,CACX,CAAC;YACN,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { OrderType, SideType } from "@chronodivide/game-api";
|
|
2
|
-
import { disband, noop, requestUnits } from "../squadBehaviour.js";
|
|
3
|
-
const DEPLOY_COOLDOWN_TICKS = 30;
|
|
4
|
-
// Expansion or initial base.
|
|
5
|
-
export class SquadExpansion {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.hasAttemptedDeployWith = null;
|
|
8
|
-
}
|
|
9
|
-
onAiUpdate(gameApi, actionsApi, playerData, squad, threatData) {
|
|
10
|
-
let myMcvName = playerData.country?.side == SideType.GDI ? "AMCV" : "SMCV";
|
|
11
|
-
const mcvs = squad.getUnitsOfType(gameApi, myMcvName);
|
|
12
|
-
if (mcvs.length === 0) {
|
|
13
|
-
// Perhaps we deployed already (or the unit was destroyed), end the mission.
|
|
14
|
-
if (this.hasAttemptedDeployWith !== null) {
|
|
15
|
-
return disband();
|
|
16
|
-
}
|
|
17
|
-
// We need an mcv!
|
|
18
|
-
return requestUnits(myMcvName, 100);
|
|
19
|
-
}
|
|
20
|
-
else if (!this.hasAttemptedDeployWith ||
|
|
21
|
-
gameApi.getCurrentTick() > this.hasAttemptedDeployWith.gameTick + DEPLOY_COOLDOWN_TICKS) {
|
|
22
|
-
actionsApi.orderUnits(mcvs.map((mcv) => mcv.id), OrderType.DeploySelected);
|
|
23
|
-
// Add a cooldown to deploy attempts.
|
|
24
|
-
this.hasAttemptedDeployWith = {
|
|
25
|
-
unitId: mcvs[0].id,
|
|
26
|
-
gameTick: gameApi.getCurrentTick(),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return noop();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
File without changes
|