@supalosa/chronodivide-bot 0.4.0 → 0.5.1
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/.env.template +5 -0
- package/README.md +54 -47
- package/dist/bot/bot.js +14 -30
- package/dist/bot/bot.js.map +1 -1
- package/dist/bot/logic/awareness.js +13 -8
- package/dist/bot/logic/awareness.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/ArtilleryUnit.js +2 -29
- package/dist/bot/logic/building/ArtilleryUnit.js.map +1 -0
- package/dist/bot/logic/building/antiAirStaticDefence.js +43 -0
- package/dist/bot/logic/building/antiAirStaticDefence.js.map +1 -0
- package/dist/bot/logic/building/antiGroundStaticDefence.js +7 -4
- package/dist/bot/logic/building/antiGroundStaticDefence.js.map +1 -1
- package/dist/bot/logic/building/basicAirUnit.js +2 -23
- package/dist/bot/logic/building/basicAirUnit.js.map +1 -1
- package/dist/bot/logic/building/basicBuilding.js +3 -2
- package/dist/bot/logic/building/basicBuilding.js.map +1 -1
- package/dist/bot/logic/building/basicGroundUnit.js +2 -43
- package/dist/bot/logic/building/basicGroundUnit.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 +10 -5
- package/dist/bot/logic/building/buildingRules.js.map +1 -1
- package/dist/bot/logic/building/common.js +19 -0
- package/dist/bot/logic/building/common.js.map +1 -0
- package/dist/bot/logic/building/harvester.js +2 -1
- package/dist/bot/logic/building/harvester.js.map +1 -1
- package/dist/bot/logic/building/queueController.js +69 -42
- package/dist/bot/logic/building/queueController.js.map +1 -1
- package/dist/bot/logic/common/utils.js +21 -0
- package/dist/bot/logic/common/utils.js.map +1 -1
- package/dist/bot/logic/composition/alliedCompositions.js +13 -0
- package/dist/bot/logic/composition/alliedCompositions.js.map +1 -0
- package/dist/bot/logic/composition/common.js +2 -0
- package/dist/bot/logic/composition/common.js.map +1 -0
- package/dist/bot/logic/composition/sovietCompositions.js +13 -0
- package/dist/bot/logic/composition/sovietCompositions.js.map +1 -0
- package/dist/bot/logic/mission/actionBatcher.js +92 -0
- package/dist/bot/logic/mission/actionBatcher.js.map +1 -0
- package/dist/bot/logic/mission/behaviours/combatSquad.js +124 -0
- package/dist/bot/logic/mission/behaviours/combatSquad.js.map +1 -0
- package/dist/bot/logic/mission/behaviours/common.js +58 -0
- package/dist/bot/logic/mission/behaviours/common.js.map +1 -0
- package/dist/bot/logic/mission/behaviours/engineerSquad.js +39 -0
- package/dist/bot/logic/mission/behaviours/engineerSquad.js.map +1 -0
- package/dist/bot/logic/mission/behaviours/expansionSquad.js +46 -0
- package/dist/bot/logic/mission/behaviours/expansionSquad.js.map +1 -0
- package/dist/bot/logic/mission/behaviours/retreatSquad.js +31 -0
- package/dist/bot/logic/mission/behaviours/retreatSquad.js.map +1 -0
- package/{src/bot/logic/squad/behaviours/scoutingSquad.ts → dist/bot/logic/mission/behaviours/scoutingSquad.js} +27 -51
- package/dist/bot/logic/mission/behaviours/scoutingSquad.js.map +1 -0
- package/dist/bot/logic/mission/mission.js +91 -19
- package/dist/bot/logic/mission/mission.js.map +1 -1
- package/dist/bot/logic/mission/missionController.js +262 -21
- package/dist/bot/logic/mission/missionController.js.map +1 -1
- package/dist/bot/logic/mission/missions/attackMission.js +113 -39
- package/dist/bot/logic/mission/missions/attackMission.js.map +1 -1
- package/dist/bot/logic/mission/missions/basicMission.js +13 -0
- package/dist/bot/logic/mission/missions/basicMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/defenceMission.js +43 -28
- package/dist/bot/logic/mission/missions/defenceMission.js.map +1 -1
- package/dist/bot/logic/mission/missions/engineerMission.js +37 -7
- package/dist/bot/logic/mission/missions/engineerMission.js.map +1 -1
- package/dist/bot/logic/mission/missions/expansionMission.js +42 -6
- package/dist/bot/logic/mission/missions/expansionMission.js.map +1 -1
- package/dist/bot/logic/mission/missions/missionBehaviour.js +2 -0
- package/dist/bot/logic/mission/missions/missionBehaviour.js.map +1 -0
- package/dist/bot/logic/mission/missions/retreatMission.js +31 -5
- package/dist/bot/logic/mission/missions/retreatMission.js.map +1 -1
- package/dist/bot/logic/mission/missions/scoutingMission.js +103 -6
- package/dist/bot/logic/mission/missions/scoutingMission.js.map +1 -1
- package/dist/bot/logic/mission/missions/squads/combatSquad.js +116 -0
- package/dist/bot/logic/mission/missions/squads/combatSquad.js.map +1 -0
- package/dist/bot/logic/mission/missions/squads/common.js +58 -0
- package/dist/bot/logic/mission/missions/squads/common.js.map +1 -0
- package/dist/bot/logic/mission/missions/squads/squad.js +2 -0
- package/dist/bot/logic/mission/missions/squads/squad.js.map +1 -0
- 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 -17
- package/dist/bot/logic/squad/squadController.js.map +1 -1
- package/dist/bot/logic/threat/threatCalculator.js +5 -5
- package/dist/bot/logic/threat/threatCalculator.js.map +1 -1
- package/dist/exampleBot.js +45 -18
- package/dist/exampleBot.js.map +1 -1
- package/package.json +5 -4
- package/src/bot/bot.ts +19 -45
- package/src/bot/logic/awareness.ts +34 -22
- package/src/bot/logic/building/antiAirStaticDefence.ts +64 -0
- package/src/bot/logic/building/antiGroundStaticDefence.ts +7 -20
- package/src/bot/logic/building/artilleryUnit.ts +2 -28
- package/src/bot/logic/building/basicAirUnit.ts +2 -33
- package/src/bot/logic/building/basicBuilding.ts +8 -6
- package/src/bot/logic/building/basicGroundUnit.ts +2 -46
- package/src/bot/logic/building/buildingRules.ts +15 -9
- package/src/bot/logic/building/common.ts +23 -0
- package/src/bot/logic/building/harvester.ts +2 -1
- package/src/bot/logic/building/queueController.ts +98 -43
- package/src/bot/logic/common/utils.ts +28 -0
- package/src/bot/logic/composition/alliedCompositions.ts +22 -0
- package/src/bot/logic/composition/common.ts +3 -0
- package/src/bot/logic/composition/sovietCompositions.ts +21 -0
- package/src/bot/logic/{squad/behaviours → mission}/actionBatcher.ts +66 -7
- package/src/bot/logic/mission/mission.ts +186 -37
- package/src/bot/logic/mission/missionController.ts +340 -31
- package/src/bot/logic/mission/missionFactories.ts +3 -3
- package/src/bot/logic/mission/missions/attackMission.ts +181 -44
- package/src/bot/logic/mission/missions/defenceMission.ts +72 -45
- package/src/bot/logic/mission/missions/engineerMission.ts +67 -15
- package/src/bot/logic/mission/missions/expansionMission.ts +67 -14
- package/src/bot/logic/mission/missions/retreatMission.ts +50 -6
- package/src/bot/logic/mission/missions/scoutingMission.ts +138 -14
- package/src/bot/logic/{squad/behaviours → mission/missions/squads}/combatSquad.ts +56 -33
- package/src/bot/logic/{squad/behaviours → mission/missions/squads}/common.ts +11 -17
- package/src/bot/logic/mission/missions/squads/squad.ts +19 -0
- package/src/bot/logic/threat/threat.ts +15 -15
- package/src/bot/logic/threat/threatCalculator.ts +10 -10
- package/src/exampleBot.ts +50 -24
- package/.prettierrc +0 -5
- package/TODO.md +0 -15
- package/dist/bot/logic/building/artilleryUnit.js.map +0 -1
- 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/rules.ini +0 -23126
- package/src/bot/logic/mission/missions/oneTimeMission.ts +0 -33
- package/src/bot/logic/squad/behaviours/engineerSquad.ts +0 -58
- package/src/bot/logic/squad/behaviours/expansionSquad.ts +0 -64
- package/src/bot/logic/squad/behaviours/retreatSquad.ts +0 -50
- package/src/bot/logic/squad/squad.ts +0 -165
- package/src/bot/logic/squad/squadBehaviour.ts +0 -66
- package/src/bot/logic/squad/squadBehaviours.ts +0 -8
- package/src/bot/logic/squad/squadController.ts +0 -271
|
@@ -4,25 +4,25 @@ import { GlobalThreat } from "./threat.js";
|
|
|
4
4
|
export function calculateGlobalThreat(game: GameApi, playerData: PlayerData, visibleAreaPercent: number): GlobalThreat {
|
|
5
5
|
let groundUnits = game.getVisibleUnits(
|
|
6
6
|
playerData.name,
|
|
7
|
-
"
|
|
7
|
+
"enemy",
|
|
8
8
|
(r) => r.type == ObjectType.Vehicle || r.type == ObjectType.Infantry,
|
|
9
9
|
);
|
|
10
|
-
let airUnits = game.getVisibleUnits(playerData.name, "
|
|
10
|
+
let airUnits = game.getVisibleUnits(playerData.name, "enemy", (r) => r.movementZone == MovementZone.Fly);
|
|
11
11
|
let groundDefence = game
|
|
12
|
-
.getVisibleUnits(playerData.name, "
|
|
12
|
+
.getVisibleUnits(playerData.name, "enemy", (r) => r.type == ObjectType.Building)
|
|
13
13
|
.filter((unitId) => isAntiGround(game, unitId));
|
|
14
14
|
let antiAirPower = game
|
|
15
|
-
.getVisibleUnits(playerData.name, "
|
|
15
|
+
.getVisibleUnits(playerData.name, "enemy", (r) => r.type != ObjectType.Building)
|
|
16
16
|
.filter((unitId) => isAntiAir(game, unitId));
|
|
17
17
|
|
|
18
18
|
let ourAntiGroundUnits = game
|
|
19
19
|
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant)
|
|
20
20
|
.filter((unitId) => isAntiGround(game, unitId));
|
|
21
21
|
let ourAntiAirUnits = game
|
|
22
|
-
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant)
|
|
22
|
+
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant || r.type === ObjectType.Building)
|
|
23
23
|
.filter((unitId) => isAntiAir(game, unitId));
|
|
24
24
|
let ourGroundDefence = game
|
|
25
|
-
.getVisibleUnits(playerData.name, "self", (r) => r.type
|
|
25
|
+
.getVisibleUnits(playerData.name, "self", (r) => r.type === ObjectType.Building)
|
|
26
26
|
.filter((unitId) => isAntiGround(game, unitId));
|
|
27
27
|
let ourAirUnits = game.getVisibleUnits(
|
|
28
28
|
playerData.name,
|
|
@@ -45,8 +45,8 @@ export function calculateGlobalThreat(game: GameApi, playerData: PlayerData, vis
|
|
|
45
45
|
observedGroundThreat,
|
|
46
46
|
observedAirThreat,
|
|
47
47
|
observedAntiAirThreat,
|
|
48
|
-
observedGroundDefence
|
|
49
|
-
ourGroundDefencePower
|
|
48
|
+
observedGroundDefence,
|
|
49
|
+
ourGroundDefencePower,
|
|
50
50
|
ourAntiGroundPower,
|
|
51
51
|
ourAntiAirPower,
|
|
52
52
|
ourAirPower,
|
|
@@ -76,14 +76,14 @@ function calculateFirepowerForUnit(unitData: UnitData): number {
|
|
|
76
76
|
threat +=
|
|
77
77
|
(hpRatio *
|
|
78
78
|
((unitData.primaryWeapon.rules.damage + 1) * GameMath.sqrt(unitData.primaryWeapon.rules.range + 1))) /
|
|
79
|
-
Math.max(unitData.primaryWeapon.
|
|
79
|
+
Math.max(unitData.primaryWeapon.rules.rof, 1);
|
|
80
80
|
}
|
|
81
81
|
if (unitData.secondaryWeapon) {
|
|
82
82
|
threat +=
|
|
83
83
|
(hpRatio *
|
|
84
84
|
((unitData.secondaryWeapon.rules.damage + 1) *
|
|
85
85
|
GameMath.sqrt(unitData.secondaryWeapon.rules.range + 1))) /
|
|
86
|
-
Math.max(unitData.secondaryWeapon.
|
|
86
|
+
Math.max(unitData.secondaryWeapon.rules.rof, 1);
|
|
87
87
|
}
|
|
88
88
|
return Math.min(800, threat);
|
|
89
89
|
}
|
package/src/exampleBot.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { Agent, Bot, CreateBaseOpts, CreateOfflineOpts, CreateOnlineOpts, cdapi } from "@chronodivide/game-api";
|
|
2
3
|
import { SupalosaBot } from "./bot/bot.js";
|
|
4
|
+
import { off } from "process";
|
|
3
5
|
|
|
4
6
|
async function main() {
|
|
5
7
|
/*
|
|
@@ -15,6 +17,19 @@ async function main() {
|
|
|
15
17
|
|
|
16
18
|
Other maps:
|
|
17
19
|
mp03t4 large map, no oil derricks
|
|
20
|
+
mp02t2.map,mp06t2.map,mp11t2.map,mp08t2.map,mp21s2.map,mp14t2.map,mp29u2.map,mp31s2.map,mp18s3.map,mp09t3.map,mp01t4.map,mp03t4.map,mp05t4.map,mp10s4.map,mp12s4.map,mp13s4.map,mp19t4.map,
|
|
21
|
+
mp15s4.map,mp16s4.map,mp23t4.map,mp33u4.map,mp34u4.map,mp17t6.map,mp20t6.map,mp25t6.map,mp26s6.map,mp30s6.map,mp22s8.map,mp27t8.map,mp32s8.map,mp06mw.map,mp08mw.map,mp14mw.map,mp29mw.map,
|
|
22
|
+
mp05mw.map,mp13mw.map,mp15mw.map,mp16mw.map,mp23mw.map,mp17mw.map,mp25mw.map,mp30mw.map,mp22mw.map,mp27mw.map,mp32mw.map,mp09du.map,mp01du.map,mp05du.map,mp13du.map,mp15du.map,mp18du.map,
|
|
23
|
+
mp24du.map,mp17du.map,mp25du.map,mp27du.map,mp32du.map,c1m1a.map,c1m1b.map,c1m1c.map,c1m2a.map,c1m2b.map,c1m2c.map,c1m3a.map,c1m3b.map,c1m3c.map,c1m4a.map,c1m4b.map,c1m4c.map,c1m5a.map,
|
|
24
|
+
c1m5b.map,c1m5c.map,c2m1a.map,c2m1b.map,c2m1c.map,c2m2a.map,c2m2b.map,c2m2c.map,c2m3a.map,c2m3b.map,c2m3c.map,c2m4a.map,c2m4b.map,c2m4c.map,c2m5a.map,c2m5b.map,c2m5c.map,c3m1a.map,c3m1b.map,
|
|
25
|
+
c3m1c.map,c3m2a.map,c3m2b.map,c3m2c.map,c3m3a.map,c3m3b.map,c3m3c.map,c3m4a.map,c3m4b.map,c3m4c.map,c3m5a.map,c3m5b.map,c3m5c.map,c4m1a.map,c4m1b.map,c4m1c.map,c4m2a.map,c4m2b.map,c4m2c.map,
|
|
26
|
+
c4m3a.map,c4m3b.map,c4m3c.map,c4m4a.map,c4m4b.map,c4m4c.map,c4m5a.map,c4m5b.map,c4m5c.map,c5m1a.map,c5m1b.map,c5m1c.map,c5m2a.map,c5m2b.map,c5m2c.map,c5m3a.map,c5m3b.map,c5m3c.map,c5m4a.map,
|
|
27
|
+
c5m4b.map,c5m4c.map,c5m5a.map,c5m5b.map,c5m5c.map,tn01t2.map,tn01mw.map,tn04t2.map,tn04mw.map,tn02s4.map,tn02mw.map,amazon01.map,eb1.map,eb2.map,eb3.map,eb4.map,eb5.map,invasion.map,arena.map,
|
|
28
|
+
barrel.map,bayopigs.map,bermuda.map,break.map,carville.map,deadman.map,death.map,disaster.map,dustbowl.map,goldst.map,grinder.map,hailmary.map,hills.map,kaliforn.map,killer.map,lostlake.map,
|
|
29
|
+
newhghts.map,oceansid.map,pacific.map,potomac.map,powdrkeg.map,rockets.map,roulette.map,round.map,seaofiso.map,shrapnel.map,tanyas.map,tower.map,tsunami.map,valley.map,xmas.map,yuriplot.map,
|
|
30
|
+
cavernsofsiberia.map,countryswingfixed.map,4_country_swing_le_v2.map,dorado_descent_yr_port.mpr,dryheat.map,dunepatrolremake.map,heckbvb.map,heckcorners.map,heckgolden.mpr,heckcorners_b.map,
|
|
31
|
+
heckcorners_b_golden.map,hecklvl.map,heckrvr.map,hecktvt.map,isleland.map,jungleofvietnam.map,2_malibu_cliffs_le.map,mojosprt.map,4_montana_dmz_le.map,6_near_ore_far.map,8_near_ore_far.map,
|
|
32
|
+
offensedefense.map,ore2_startfixed.map,rekoool_fast_6players.mpr,rekoool_fast_8players.mpr,riverram.map,tourofegypt.map,unrepent.map,sinkswim_yr_port.map
|
|
18
33
|
*/
|
|
19
34
|
const mapName = "mp03t4.map";
|
|
20
35
|
// Bot names must be unique in online mode
|
|
@@ -43,41 +58,52 @@ async function main() {
|
|
|
43
58
|
8=Russians
|
|
44
59
|
*/
|
|
45
60
|
|
|
46
|
-
const
|
|
47
|
-
|
|
61
|
+
const baseSettings: CreateBaseOpts = {
|
|
62
|
+
buildOffAlly: false,
|
|
63
|
+
cratesAppear: false,
|
|
64
|
+
credits: 10000,
|
|
65
|
+
gameMode: cdapi.getAvailableGameModes(mapName)[0],
|
|
66
|
+
gameSpeed: 6,
|
|
67
|
+
mapName,
|
|
68
|
+
mcvRepacks: true,
|
|
69
|
+
shortGame: true,
|
|
70
|
+
superWeapons: false,
|
|
71
|
+
unitCount: 0,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const onlineSettings: CreateOnlineOpts = {
|
|
75
|
+
...baseSettings,
|
|
76
|
+
online: true,
|
|
48
77
|
serverUrl: process.env.SERVER_URL!,
|
|
49
78
|
clientUrl: process.env.CLIENT_URL!,
|
|
50
|
-
agents: [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
],
|
|
79
|
+
agents: [
|
|
80
|
+
new SupalosaBot(process.env.ONLINE_BOT_NAME ?? firstBotName, "Americans"),
|
|
81
|
+
{ name: process.env.PLAYER_NAME ?? secondBotName, country: "French" },
|
|
82
|
+
] as [Bot, ...Agent[]],
|
|
83
|
+
botPassword: process.env.ONLINE_BOT_PASSWORD ?? "default",
|
|
54
84
|
};
|
|
55
85
|
|
|
56
|
-
const
|
|
57
|
-
|
|
86
|
+
const offlineSettings1v1: CreateOfflineOpts = {
|
|
87
|
+
...baseSettings,
|
|
88
|
+
online: false,
|
|
89
|
+
agents: [
|
|
90
|
+
new SupalosaBot(firstBotName, "French", [], true).setDebugMode(true),
|
|
91
|
+
new SupalosaBot(secondBotName, "Russians", [], false),
|
|
92
|
+
],
|
|
93
|
+
};
|
|
58
94
|
|
|
59
|
-
const
|
|
95
|
+
const offlineSettings2v2: CreateOfflineOpts = {
|
|
96
|
+
...baseSettings,
|
|
97
|
+
online: false,
|
|
60
98
|
agents: [
|
|
61
99
|
new SupalosaBot(firstBotName, "French", [firstBotName], false),
|
|
62
|
-
|
|
100
|
+
new SupalosaBot(secondBotName, "Russians", [firstBotName], true).setDebugMode(true),
|
|
63
101
|
new SupalosaBot(thirdBotName, "Russians", [fourthBotName], false),
|
|
64
102
|
new SupalosaBot(fourthBotName, "French", [thirdBotName], false),
|
|
65
103
|
],
|
|
66
104
|
};
|
|
67
105
|
|
|
68
|
-
const game = await cdapi.createGame(
|
|
69
|
-
...offlineSettings,
|
|
70
|
-
buildOffAlly: false,
|
|
71
|
-
cratesAppear: false,
|
|
72
|
-
credits: 10000,
|
|
73
|
-
gameMode: cdapi.getAvailableGameModes(mapName)[0],
|
|
74
|
-
gameSpeed: 6,
|
|
75
|
-
mapName,
|
|
76
|
-
mcvRepacks: true,
|
|
77
|
-
shortGame: true,
|
|
78
|
-
superWeapons: false,
|
|
79
|
-
unitCount: 0,
|
|
80
|
-
});
|
|
106
|
+
const game = await cdapi.createGame(process.env.ONLINE_MATCH ? onlineSettings : offlineSettings1v1);
|
|
81
107
|
while (!game.isFinished()) {
|
|
82
108
|
await game.update();
|
|
83
109
|
}
|
package/.prettierrc
DELETED
package/TODO.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# TODO for Supabot
|
|
2
|
-
|
|
3
|
-
Urgent
|
|
4
|
-
|
|
5
|
-
- leader pathfinding
|
|
6
|
-
|
|
7
|
-
Medium priority
|
|
8
|
-
|
|
9
|
-
- detect naval map (can scan tiles to check if more of the map is water or not)
|
|
10
|
-
- handle naval construction
|
|
11
|
-
- detect islands and implement island-hopping
|
|
12
|
-
|
|
13
|
-
Not urgent
|
|
14
|
-
|
|
15
|
-
- Remove squad paradigm, all unit-related for mission can just go into the mission.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"artilleryUnit.js","sourceRoot":"","sources":["../../../../src/bot/logic/building/artilleryUnit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAA2B,MAAM,wBAAwB,CAAC;AAEpF,OAAO,EAAmB,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE9E,MAAM,OAAO,aAAa;IACtB,YACY,YAAoB,EACpB,cAAsB,EACtB,eAAuB,EACvB,UAAkB;QAHlB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,mBAAc,GAAd,cAAc,CAAQ;QACtB,oBAAe,GAAf,eAAe,CAAQ;QACvB,eAAU,GAAV,UAAU,CAAQ;IAC3B,CAAC;IAEJ,oBAAoB,CAChB,IAAa,EACb,UAAsB,EACtB,WAAwB;QAExB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,WAAW,CACP,IAAa,EACb,UAAsB,EACtB,WAAwB,EACxB,WAAgC;QAEhC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QACxE,IAAI,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC;QACjC,6EAA6E;QAC7E,IAAI,WAAW,IAAI,WAAW,CAAC,mBAAmB,GAAG,WAAW,CAAC,iCAAiC,EAAE;YAChG,QAAQ;gBACJ,IAAI,CAAC,cAAc;oBACnB,CAAC,WAAW,CAAC,iCAAiC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;SACtG;QACD,IAAI,WAAW,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE;YACzC,+DAA+D;YAC/D,IAAI,WAAW,CAAC,wBAAwB,GAAG,WAAW,CAAC,iCAAiC,EAAE;gBACtF,QAAQ;oBACJ,IAAI,CAAC,eAAe;wBACpB,IAAI,CAAC,YAAY;wBACjB,CAAC,WAAW,CAAC,wBAAwB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,iCAAiC,CAAC,CAAC,CAAC;aAC3G;iBAAM;gBACH,wEAAwE;gBACxE,QAAQ;oBACJ,CAAC,IAAI,CAAC,eAAe;wBACjB,IAAI,CAAC,YAAY;wBACjB,QAAQ,CAAC,IAAI,CACT,WAAW,CAAC,iCAAiC;4BACzC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,wBAAwB,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAC3F,CAAC;wBACN,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;aACtB;SACJ;QACD,OAAO,QAAQ,GAAG,CAAC,GAAG,GAAG,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,WAAW,CACP,IAAa,EACb,UAAsB,EACtB,WAAwB,EACxB,WAAgC;QAEhC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { numBuildingsOwnedOfType } from "./building.js";
|
|
2
|
-
export class MassedAntiGroundUnit {
|
|
3
|
-
constructor(basePriority, baseAmount) {
|
|
4
|
-
this.basePriority = basePriority;
|
|
5
|
-
this.baseAmount = baseAmount;
|
|
6
|
-
}
|
|
7
|
-
getPlacementLocation(game, playerData, technoRules) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
getPriority(game, playerData, technoRules, threatCache) {
|
|
11
|
-
// If the enemy's ground power is increasing we should try to keep up.
|
|
12
|
-
if (threatCache) {
|
|
13
|
-
if (threatCache.totalAvailableAntiGroundFirepower * threatCache.certainty > threatCache.totalAvailableAntiGroundFirepower) {
|
|
14
|
-
return this.basePriority * (threatCache.totalAvailableAntiGroundFirepower / Math.max(1, threatCache.totalAvailableAntiGroundFirepower));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const numOwned = numBuildingsOwnedOfType(game, playerData, technoRules);
|
|
18
|
-
return this.basePriority * (1.0 - (numOwned / this.baseAmount));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { QueueType } from "@chronodivide/game-api";
|
|
2
|
-
export const queueTypeToName = (queue) => {
|
|
3
|
-
switch (queue) {
|
|
4
|
-
case QueueType.Structures:
|
|
5
|
-
return "Structures";
|
|
6
|
-
case QueueType.Armory:
|
|
7
|
-
return "Armory";
|
|
8
|
-
case QueueType.Infantry:
|
|
9
|
-
return "Infantry";
|
|
10
|
-
case QueueType.Vehicles:
|
|
11
|
-
return "Vehicles";
|
|
12
|
-
case QueueType.Aircrafts:
|
|
13
|
-
return "Aircrafts";
|
|
14
|
-
case QueueType.Ships:
|
|
15
|
-
return "Ships";
|
|
16
|
-
default:
|
|
17
|
-
return "Unknown";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// A basic mission requests specific units.
|
|
2
|
-
export class BasicMission {
|
|
3
|
-
constructor(uniqueName, priority = 1, squads = []) {
|
|
4
|
-
this.uniqueName = uniqueName;
|
|
5
|
-
this.priority = priority;
|
|
6
|
-
this.squads = squads;
|
|
7
|
-
}
|
|
8
|
-
getUniqueName() {
|
|
9
|
-
return this.uniqueName;
|
|
10
|
-
}
|
|
11
|
-
isActive() {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
removeSquad(squad) {
|
|
15
|
-
this.squads = this.squads.filter((s) => s != squad);
|
|
16
|
-
}
|
|
17
|
-
addSquad(squad) {
|
|
18
|
-
if (!this.squads.find((s) => s == squad)) {
|
|
19
|
-
this.squads.push(squad);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
getSquads() {
|
|
23
|
-
return this.squads;
|
|
24
|
-
}
|
|
25
|
-
onSquadAdded(gameApi, playerData, threatData) { }
|
|
26
|
-
}
|
|
@@ -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,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,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,EAAE;YACjE,cAAc;YACd,MAAM,WAAW,GAAc,QAAQ,CAAC,YAAY,CAAc,CAAC;YACnE,8BAA8B;YAC9B,MAAM,QAAQ,GAAG,OAAO,CACpB,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAChD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAG,CAC7C,CAAC;YACF,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE;gBAC1D,UAAU,CAAC,UAAU,CACjB,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAC7C,WAAW,EACX,QAAQ,CAAC,QAAQ,CAAC,CACrB,CAAC;YACN,CAAC,CAAC,CAAC;YACH,0EAA0E;YAC1E,MAAM,UAAU,GAAG,OAAO,CACtB,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7C,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,KAAM,CAAC,CAC3C,CAAC;YACF,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,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
|
-
}
|