@supalosa/chronodivide-bot 0.2.0 → 0.2.2-a
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 +11 -3
- package/dist/bot/bot.js +17 -9
- package/dist/bot/bot.js.map +1 -0
- package/dist/bot/logic/awareness.js +12 -2
- package/dist/bot/logic/awareness.js.map +1 -0
- package/dist/bot/logic/building/ArtilleryUnit.js +29 -8
- package/dist/bot/logic/building/antiGroundStaticDefence.js +3 -2
- package/dist/bot/logic/building/antiGroundStaticDefence.js.map +1 -0
- package/dist/bot/logic/building/artilleryUnit.js.map +1 -0
- package/dist/bot/logic/building/basicAirUnit.js +2 -1
- package/dist/bot/logic/building/basicAirUnit.js.map +1 -0
- package/dist/bot/logic/building/basicBuilding.js +2 -1
- package/dist/bot/logic/building/basicBuilding.js.map +1 -0
- package/dist/bot/logic/building/basicGroundUnit.js +2 -1
- package/dist/bot/logic/building/basicGroundUnit.js.map +1 -0
- package/dist/bot/logic/building/building.js +2 -0
- package/dist/bot/logic/building/buildingRules.js +168 -0
- package/dist/bot/logic/building/buildingRules.js.map +1 -0
- package/dist/bot/logic/building/harvester.js +1 -0
- package/dist/bot/logic/building/harvester.js.map +1 -0
- package/dist/bot/logic/building/powerPlant.js +2 -1
- package/dist/bot/logic/building/powerPlant.js.map +1 -0
- package/dist/bot/logic/building/queueController.js +2 -1
- package/dist/bot/logic/building/queueController.js.map +1 -0
- package/dist/bot/logic/building/resourceCollectionBuilding.js +2 -1
- package/dist/bot/logic/building/resourceCollectionBuilding.js.map +1 -0
- package/dist/bot/logic/common/scout.js +100 -0
- package/dist/bot/logic/common/scout.js.map +1 -0
- package/dist/bot/logic/common/utils.js +14 -0
- package/dist/bot/logic/common/utils.js.map +1 -0
- package/dist/bot/logic/map/map.js +9 -25
- package/dist/bot/logic/map/map.js.map +1 -0
- package/dist/bot/logic/map/sector.js +33 -1
- package/dist/bot/logic/map/sector.js.map +1 -0
- package/dist/bot/logic/mission/mission.js +3 -1
- package/dist/bot/logic/mission/mission.js.map +1 -0
- package/dist/bot/logic/mission/missionController.js +5 -4
- package/dist/bot/logic/mission/missionController.js.map +1 -0
- package/dist/bot/logic/mission/missionFactories.js +3 -0
- package/dist/bot/logic/mission/missionFactories.js.map +1 -0
- package/dist/bot/logic/mission/missions/attackMission.js +9 -10
- package/dist/bot/logic/mission/missions/attackMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/defenceMission.js +12 -7
- package/dist/bot/logic/mission/missions/defenceMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/engineerMission.js +34 -0
- package/dist/bot/logic/mission/missions/engineerMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/expansionMission.js +5 -4
- package/dist/bot/logic/mission/missions/expansionMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/oneTimeMission.js +3 -2
- package/dist/bot/logic/mission/missions/oneTimeMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/retreatMission.js +3 -2
- package/dist/bot/logic/mission/missions/retreatMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/scoutingMission.js +8 -9
- package/dist/bot/logic/mission/missions/scoutingMission.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/combatSquad.js +20 -18
- package/dist/bot/logic/squad/behaviours/combatSquad.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/common.js +25 -5
- package/dist/bot/logic/squad/behaviours/common.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/engineerSquad.js +36 -0
- package/dist/bot/logic/squad/behaviours/engineerSquad.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/expansionSquad.js +1 -0
- package/dist/bot/logic/squad/behaviours/expansionSquad.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/retreatSquad.js +6 -10
- package/dist/bot/logic/squad/behaviours/retreatSquad.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/scoutingSquad.js +66 -18
- package/dist/bot/logic/squad/behaviours/scoutingSquad.js.map +1 -0
- package/dist/bot/logic/squad/squad.js +4 -5
- package/dist/bot/logic/squad/squad.js.map +1 -0
- package/dist/bot/logic/squad/squadBehaviour.js +1 -0
- package/dist/bot/logic/squad/squadBehaviour.js.map +1 -0
- package/dist/bot/logic/squad/squadBehaviours.js +1 -0
- package/dist/bot/logic/squad/squadBehaviours.js.map +1 -0
- package/dist/bot/logic/squad/squadController.js +73 -23
- package/dist/bot/logic/squad/squadController.js.map +1 -0
- package/dist/bot/logic/threat/threat.js +1 -0
- package/dist/bot/logic/threat/threat.js.map +1 -0
- package/dist/bot/logic/threat/threatCalculator.js +1 -0
- package/dist/bot/logic/threat/threatCalculator.js.map +1 -0
- package/dist/exampleBot.js +29 -12
- package/dist/exampleBot.js.map +1 -0
- package/package.json +15 -7
- package/src/bot/bot.ts +21 -16
- package/src/bot/logic/awareness.ts +22 -5
- package/src/bot/logic/building/antiGroundStaticDefence.ts +60 -60
- package/src/bot/logic/building/artilleryUnit.ts +68 -0
- package/src/bot/logic/building/basicAirUnit.ts +68 -68
- package/src/bot/logic/building/basicBuilding.ts +47 -47
- package/src/bot/logic/building/basicGroundUnit.ts +1 -1
- package/src/bot/logic/building/buildingRules.ts +233 -0
- package/src/bot/logic/building/powerPlant.ts +32 -32
- package/src/bot/logic/building/queueController.ts +1 -1
- package/src/bot/logic/building/resourceCollectionBuilding.ts +56 -56
- package/src/bot/logic/common/scout.ts +127 -1
- package/src/bot/logic/common/utils.ts +17 -0
- package/src/bot/logic/map/map.ts +70 -84
- package/src/bot/logic/map/sector.ts +46 -4
- package/src/bot/logic/mission/mission.ts +2 -2
- package/src/bot/logic/mission/missionController.ts +7 -6
- package/src/bot/logic/mission/missionFactories.ts +5 -0
- package/src/bot/logic/mission/missions/attackMission.ts +19 -12
- package/src/bot/logic/mission/missions/defenceMission.ts +35 -15
- package/src/bot/logic/mission/missions/engineerMission.ts +61 -0
- package/src/bot/logic/mission/missions/expansionMission.ts +6 -4
- package/src/bot/logic/mission/missions/oneTimeMission.ts +3 -2
- package/src/bot/logic/mission/missions/retreatMission.ts +3 -2
- package/src/bot/logic/mission/missions/scoutingMission.ts +9 -6
- package/src/bot/logic/squad/behaviours/combatSquad.ts +22 -18
- package/src/bot/logic/squad/behaviours/common.ts +38 -5
- package/src/bot/logic/squad/behaviours/engineerSquad.ts +53 -0
- package/src/bot/logic/squad/behaviours/retreatSquad.ts +10 -12
- package/src/bot/logic/squad/behaviours/scoutingSquad.ts +79 -26
- package/src/bot/logic/squad/squad.ts +4 -4
- package/src/bot/logic/squad/squadBehaviour.ts +3 -1
- package/src/bot/logic/squad/squadController.ts +135 -70
- package/src/exampleBot.ts +31 -12
- package/tsconfig.json +73 -73
- package/src/bot/logic/building/ArtilleryUnit.ts +0 -43
- package/src/bot/logic/building/building.ts +0 -125
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Meta-controller for forming and controlling squads.
|
|
2
2
|
import { SquadLiveness } from "./squad.js";
|
|
3
3
|
import { getDistanceBetween } from "../map/map.js";
|
|
4
|
+
import countBy from "lodash.countby";
|
|
4
5
|
export class SquadController {
|
|
5
|
-
constructor() {
|
|
6
|
+
constructor(logger) {
|
|
7
|
+
this.logger = logger;
|
|
6
8
|
this.squads = [];
|
|
7
9
|
this.unitIdToSquad = new Map();
|
|
8
10
|
}
|
|
9
|
-
onAiUpdate(gameApi, actionsApi, playerData, matchAwareness
|
|
11
|
+
onAiUpdate(gameApi, actionsApi, playerData, matchAwareness) {
|
|
10
12
|
// Remove dead squads or those where the mission is dead.
|
|
11
13
|
this.squads = this.squads.filter((squad) => squad.getLiveness() !== SquadLiveness.SquadDead);
|
|
12
14
|
this.squads.sort((a, b) => a.getName().localeCompare(b.getName()));
|
|
@@ -15,7 +17,7 @@ export class SquadController {
|
|
|
15
17
|
this.squads.forEach((squad) => {
|
|
16
18
|
squad.getUnitIds().forEach((unitId) => {
|
|
17
19
|
if (this.unitIdToSquad.has(unitId)) {
|
|
18
|
-
logger(`WARNING: unit ${unitId} is in multiple squads, please debug.`);
|
|
20
|
+
this.logger(`WARNING: unit ${unitId} is in multiple squads, please debug.`);
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
23
|
this.unitIdToSquad.set(unitId, squad);
|
|
@@ -25,7 +27,7 @@ export class SquadController {
|
|
|
25
27
|
const squadActions = this.squads.map((squad) => {
|
|
26
28
|
return {
|
|
27
29
|
squad,
|
|
28
|
-
action: squad.onAiUpdate(gameApi, actionsApi, playerData, matchAwareness),
|
|
30
|
+
action: squad.onAiUpdate(gameApi, actionsApi, playerData, matchAwareness, this.logger),
|
|
29
31
|
};
|
|
30
32
|
});
|
|
31
33
|
// Handle disbands and merges.
|
|
@@ -35,7 +37,7 @@ export class SquadController {
|
|
|
35
37
|
squadActions
|
|
36
38
|
.filter((a) => isDisband(a.action))
|
|
37
39
|
.forEach((a) => {
|
|
38
|
-
logger(`Squad ${a.squad.getName()} disbanding as requested.`);
|
|
40
|
+
this.logger(`Squad ${a.squad.getName()} disbanding as requested.`);
|
|
39
41
|
a.squad.getMission()?.removeSquad();
|
|
40
42
|
a.squad.getUnitIds().forEach((unitId) => {
|
|
41
43
|
this.unitIdToSquad.delete(unitId);
|
|
@@ -47,7 +49,7 @@ export class SquadController {
|
|
|
47
49
|
.forEach((a) => {
|
|
48
50
|
let mergeInto = a.action;
|
|
49
51
|
if (disbandedSquads.has(mergeInto.mergeInto.getName())) {
|
|
50
|
-
logger(`Squad ${a.squad.getName()} tried to merge into disbanded squad ${mergeInto.mergeInto.getName()}, cancelling.`);
|
|
52
|
+
this.logger(`Squad ${a.squad.getName()} tried to merge into disbanded squad ${mergeInto.mergeInto.getName()}, cancelling.`);
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
55
|
a.squad.getUnitIds().forEach((unitId) => mergeInto.mergeInto.addUnit(unitId));
|
|
@@ -74,19 +76,37 @@ export class SquadController {
|
|
|
74
76
|
});
|
|
75
77
|
return prev;
|
|
76
78
|
}, {});
|
|
77
|
-
|
|
79
|
+
// Map of Squad ID to Unit Type to Count.
|
|
80
|
+
const newSquadAssignments = Object.entries(unitIdToHighestRequest)
|
|
81
|
+
.flatMap(([id, request]) => {
|
|
78
82
|
const unitId = Number.parseInt(id);
|
|
79
83
|
const unit = gameApi.getUnitData(unitId);
|
|
80
84
|
const { squad: requestingSquad } = request;
|
|
81
85
|
const missionName = requestingSquad.getMission()?.getUniqueName();
|
|
82
86
|
if (!unit) {
|
|
83
|
-
logger(`mission ${missionName} requested non-existent unit ${unitId}`);
|
|
84
|
-
return;
|
|
87
|
+
this.logger(`mission ${missionName} requested non-existent unit ${unitId}`);
|
|
88
|
+
return [];
|
|
85
89
|
}
|
|
86
90
|
if (!this.unitIdToSquad.has(unitId)) {
|
|
87
|
-
logger(`granting specific unit ${unitId} to squad ${requestingSquad.getName()} in mission ${missionName}`);
|
|
88
91
|
this.addUnitToSquad(requestingSquad, unit);
|
|
92
|
+
return [{ unitName: unit?.name, squad: requestingSquad.getName() }];
|
|
93
|
+
}
|
|
94
|
+
return [];
|
|
95
|
+
})
|
|
96
|
+
.reduce((acc, curr) => {
|
|
97
|
+
if (!acc[curr.squad]) {
|
|
98
|
+
acc[curr.squad] = {};
|
|
89
99
|
}
|
|
100
|
+
if (!acc[curr.squad][curr.unitName]) {
|
|
101
|
+
acc[curr.squad][curr.unitName] = 0;
|
|
102
|
+
}
|
|
103
|
+
acc[curr.squad][curr.unitName] = acc[curr.squad][curr.unitName] + 1;
|
|
104
|
+
return acc;
|
|
105
|
+
}, {});
|
|
106
|
+
Object.entries(newSquadAssignments).forEach(([squad, assignments]) => {
|
|
107
|
+
this.logger(`Squad ${squad} received: ${Object.entries(assignments)
|
|
108
|
+
.map(([unitType, count]) => unitType + " x " + count)
|
|
109
|
+
.join(", ")}`);
|
|
90
110
|
});
|
|
91
111
|
// Request units by type
|
|
92
112
|
const isRequest = (a) => a.type === "request";
|
|
@@ -116,27 +136,48 @@ export class SquadController {
|
|
|
116
136
|
.map((unitId) => gameApi.getUnitData(unitId))
|
|
117
137
|
.filter((unit) => !!unit && !this.unitIdToSquad.has(unit.id || 0))
|
|
118
138
|
.map((unit) => unit);
|
|
119
|
-
|
|
139
|
+
// [squadName][unitName]['type' | 'grab']
|
|
140
|
+
const newAssignmentsByType = freeUnits
|
|
141
|
+
.flatMap((freeUnit) => {
|
|
120
142
|
if (unitTypeToHighestRequest.hasOwnProperty(freeUnit.name)) {
|
|
121
143
|
const { squad: requestingSquad } = unitTypeToHighestRequest[freeUnit.name];
|
|
122
|
-
logger(`granting unit ${freeUnit.id}#${freeUnit.name} to squad ${requestingSquad.getName()}`);
|
|
144
|
+
this.logger(`granting unit ${freeUnit.id}#${freeUnit.name} to squad ${requestingSquad.getName()}`);
|
|
123
145
|
this.addUnitToSquad(requestingSquad, freeUnit);
|
|
124
146
|
delete unitTypeToHighestRequest[freeUnit.name];
|
|
147
|
+
return [
|
|
148
|
+
{ unitName: freeUnit.name, squad: requestingSquad.getName(), method: "type" },
|
|
149
|
+
];
|
|
125
150
|
}
|
|
126
151
|
else if (grabRequests.length > 0) {
|
|
127
|
-
grabRequests.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
getDistanceBetween(freeUnit, request.action.point) <= request.action.radius) {
|
|
131
|
-
logger(`granting unit ${freeUnit.id}#${freeUnit.name} to squad ${requestingSquad.getName()} via grab at ${request.action.point.x},${request.action.point.y}`);
|
|
132
|
-
this.addUnitToSquad(requestingSquad, freeUnit);
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
152
|
+
const grantedSquad = grabRequests.find((request) => {
|
|
153
|
+
return (freeUnit.rules.isSelectableCombatant &&
|
|
154
|
+
getDistanceBetween(freeUnit, request.action.point) <= request.action.radius);
|
|
138
155
|
});
|
|
156
|
+
if (grantedSquad) {
|
|
157
|
+
this.addUnitToSquad(grantedSquad.squad, freeUnit);
|
|
158
|
+
return [
|
|
159
|
+
{ unitName: freeUnit.name, squad: grantedSquad.squad.getName(), method: "grab" },
|
|
160
|
+
];
|
|
161
|
+
}
|
|
139
162
|
}
|
|
163
|
+
return [];
|
|
164
|
+
})
|
|
165
|
+
.reduce((acc, curr) => {
|
|
166
|
+
if (!acc[curr.squad]) {
|
|
167
|
+
acc[curr.squad] = {};
|
|
168
|
+
}
|
|
169
|
+
if (!acc[curr.squad][curr.unitName]) {
|
|
170
|
+
acc[curr.squad][curr.unitName] = { grab: 0, type: 0 };
|
|
171
|
+
}
|
|
172
|
+
acc[curr.squad][curr.unitName][curr.method] = acc[curr.squad][curr.unitName][curr.method] + 1;
|
|
173
|
+
return acc;
|
|
174
|
+
}, {});
|
|
175
|
+
Object.entries(newAssignmentsByType).forEach(([squad, assignments]) => {
|
|
176
|
+
this.logger(`Squad ${squad} received: ${Object.entries(assignments)
|
|
177
|
+
.flatMap(([unitType, methodToCount]) => Object.entries(methodToCount)
|
|
178
|
+
.filter(([, count]) => count > 0)
|
|
179
|
+
.map(([method, count]) => unitType + " x " + count + " (by " + method + ")"))
|
|
180
|
+
.join(", ")}`);
|
|
140
181
|
});
|
|
141
182
|
}
|
|
142
183
|
addUnitToSquad(squad, unit) {
|
|
@@ -146,4 +187,13 @@ export class SquadController {
|
|
|
146
187
|
registerSquad(squad) {
|
|
147
188
|
this.squads.push(squad);
|
|
148
189
|
}
|
|
190
|
+
debugSquads(gameApi) {
|
|
191
|
+
const unitsInSquad = (unitIds) => countBy(unitIds, (unitId) => gameApi.getUnitData(unitId)?.name);
|
|
192
|
+
this.squads.forEach((squad) => {
|
|
193
|
+
this.logger(`Squad ${squad.getName()}: ${Object.entries(unitsInSquad(squad.getUnitIds()))
|
|
194
|
+
.map(([unitName, count]) => `${unitName} x ${count}`)
|
|
195
|
+
.join(", ")}`);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
149
198
|
}
|
|
199
|
+
//# sourceMappingURL=squadController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"squadController.js","sourceRoot":"","sources":["../../../../src/bot/logic/squad/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C,IAAa,EAAE,OAAiB;IAChE,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACvB,IAAI,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,QAAQ,EAAE;YACV,MAAM,IAAI,yBAAyB,CAAC,QAAQ,CAAC,CAAC;SACjD;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/dist/exampleBot.js
CHANGED
|
@@ -5,31 +5,47 @@ async function main() {
|
|
|
5
5
|
Ladder maps:
|
|
6
6
|
CDR2 1v1 2_malibu_cliffs_le.map
|
|
7
7
|
CDR2 1v1 4_country_swing_le_v2.map
|
|
8
|
-
CDR2 1v1 mp01t4.map
|
|
9
|
-
CDR2 1v1 tn04t2.map
|
|
10
|
-
CDR2 1v1 mp10s4.map
|
|
8
|
+
CDR2 1v1 mp01t4.map, large map, oil derricks
|
|
9
|
+
CDR2 1v1 tn04t2.map, small map
|
|
10
|
+
CDR2 1v1 mp10s4.map <- depth charge, naval map (not supported)
|
|
11
11
|
CDR2 1v1 heckcorners.map
|
|
12
12
|
CDR2 1v1 4_montana_dmz_le.map
|
|
13
13
|
CDR2 1v1 barrel.map
|
|
14
14
|
|
|
15
15
|
Other maps:
|
|
16
|
-
mp03t4
|
|
16
|
+
mp03t4 large map, no oil derricks
|
|
17
17
|
*/
|
|
18
|
-
const mapName = "
|
|
18
|
+
const mapName = "tn04t2.map";
|
|
19
19
|
// Bot names must be unique in online mode
|
|
20
20
|
const botName = `Joe${String(Date.now()).substr(-6)}`;
|
|
21
21
|
const otherBotName = `Bob${String(Date.now() + 1).substr(-6)}`;
|
|
22
22
|
await cdapi.init(process.env.MIX_DIR || "./");
|
|
23
23
|
console.log("Server URL: " + process.env.SERVER_URL);
|
|
24
24
|
console.log("Client URL: " + process.env.CLIENT_URL);
|
|
25
|
+
/*
|
|
26
|
+
Countries:
|
|
27
|
+
0=Americans
|
|
28
|
+
1=Alliance -> Korea
|
|
29
|
+
2=French
|
|
30
|
+
3=Germans
|
|
31
|
+
4=British
|
|
32
|
+
|
|
33
|
+
5=Africans -> Libya
|
|
34
|
+
6=Arabs -> Iraq
|
|
35
|
+
7=Confederation -> Cuba
|
|
36
|
+
8=Russians
|
|
37
|
+
*/
|
|
38
|
+
const onlineSettings = {
|
|
39
|
+
online: true,
|
|
40
|
+
serverUrl: process.env.SERVER_URL,
|
|
41
|
+
clientUrl: process.env.CLIENT_URL,
|
|
42
|
+
agents: [new SupalosaBot(botName, "Americans"), { name: otherBotName, country: "French" }],
|
|
43
|
+
};
|
|
44
|
+
const offlineSettings = {
|
|
45
|
+
agents: [new SupalosaBot(botName, "French", false), new SupalosaBot(otherBotName, "Russians", true)],
|
|
46
|
+
};
|
|
25
47
|
const game = await cdapi.createGame({
|
|
26
|
-
|
|
27
|
-
/*online: true,
|
|
28
|
-
serverUrl: process.env.SERVER_URL!,
|
|
29
|
-
clientUrl: process.env.CLIENT_URL!,
|
|
30
|
-
agents: [new SupalosaBot(botName, "Americans"), { name: otherBotName, country: "French" }],*/
|
|
31
|
-
agents: [new SupalosaBot(botName, "French", false), new SupalosaBot(otherBotName, "French", true)],
|
|
32
|
-
//agents: [new SupalosaBot(botName, "Americans", false), new SupalosaBot(otherBotName, "Russians", false)],
|
|
48
|
+
...offlineSettings,
|
|
33
49
|
buildOffAlly: false,
|
|
34
50
|
cratesAppear: false,
|
|
35
51
|
credits: 10000,
|
|
@@ -51,3 +67,4 @@ main().catch((e) => {
|
|
|
51
67
|
console.error(e);
|
|
52
68
|
process.exit(1);
|
|
53
69
|
});
|
|
70
|
+
//# sourceMappingURL=exampleBot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exampleBot.js","sourceRoot":"","sources":["../src/exampleBot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,MAAM,wBAAwB,CAAC;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AAe;QAClB,YAAY,EAAE,KAAK;QACnB,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjD,SAAS,EAAE,CAAC;QACZ,OAAO;QACP,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,KAAK;QACnB,SAAS,EAAE,CAAC;KACf,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE;QACvB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;KACvB;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;IAClB,IAAI,CAAC,OAAO,EAAE,CAAC;AACnB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supalosa/chronodivide-bot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2a",
|
|
4
4
|
"description": "Example bot for Chrono Divide",
|
|
5
5
|
"repository": "https://github.com/Supalosa/supalosa-chronodivide-bot",
|
|
6
6
|
"main": "dist/exampleBot.js",
|
|
@@ -13,17 +13,25 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "UNLICENSED",
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@
|
|
16
|
+
"@chronodivide/game-api": "^0.45.0",
|
|
17
|
+
"@types/lodash.countby": "^4.6.8",
|
|
18
|
+
"@types/lodash.maxby": "^4.6.8",
|
|
19
|
+
"@types/lodash.min": "^4.0.8",
|
|
20
|
+
"@types/lodash.uniqby": "^4.7.8",
|
|
17
21
|
"@types/node": "^14.17.32",
|
|
18
22
|
"prettier": "3.0.3",
|
|
19
23
|
"typescript": "^4.3.5"
|
|
20
24
|
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@chronodivide/game-api": "^0.45.0"
|
|
27
|
+
},
|
|
21
28
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
29
|
+
"@datastructures-js/priority-queue": "^6.3.0",
|
|
30
|
+
"@timohausmann/quadtree-ts": "^2.0.0-beta.1",
|
|
24
31
|
"@types/luxon": "^3.3.2",
|
|
25
|
-
"lodash": "^4.
|
|
26
|
-
"
|
|
27
|
-
"
|
|
32
|
+
"lodash.countby": "^4.6.0",
|
|
33
|
+
"lodash.maxby": "^4.6.0",
|
|
34
|
+
"lodash.min": "^4.0.1",
|
|
35
|
+
"lodash.uniqby": "^4.7.0"
|
|
28
36
|
}
|
|
29
37
|
}
|
package/src/bot/bot.ts
CHANGED
|
@@ -10,21 +10,22 @@ import {
|
|
|
10
10
|
FactoryType,
|
|
11
11
|
} from "@chronodivide/game-api";
|
|
12
12
|
|
|
13
|
-
import { Duration } from "luxon";
|
|
14
|
-
|
|
15
13
|
import { determineMapBounds } from "./logic/map/map.js";
|
|
16
14
|
import { SectorCache } from "./logic/map/sector.js";
|
|
17
15
|
import { MissionController } from "./logic/mission/missionController.js";
|
|
18
16
|
import { SquadController } from "./logic/squad/squadController.js";
|
|
19
17
|
import { QUEUES, QueueController, queueTypeToName } from "./logic/building/queueController.js";
|
|
20
|
-
import { MatchAwareness
|
|
18
|
+
import { MatchAwareness, MatchAwarenessImpl } from "./logic/awareness.js";
|
|
19
|
+
import { formatTimeDuration } from "./logic/common/utils.js";
|
|
21
20
|
|
|
22
21
|
const DEBUG_TIMESTAMP_OUTPUT_INTERVAL_SECONDS = 60;
|
|
22
|
+
|
|
23
|
+
// Number of ticks per second at the base speed.
|
|
23
24
|
const NATURAL_TICK_RATE = 15;
|
|
24
25
|
const BOT_AUTO_SURRENDER_TIME_SECONDS = 7200; // 7200; // 2 hours (approx 30 mins in real game)
|
|
25
26
|
|
|
26
27
|
export class SupalosaBot extends Bot {
|
|
27
|
-
private tickRatio
|
|
28
|
+
private tickRatio?: number;
|
|
28
29
|
private knownMapBounds: Point2D | undefined;
|
|
29
30
|
private missionController: MissionController;
|
|
30
31
|
private squadController: SquadController;
|
|
@@ -37,8 +38,8 @@ export class SupalosaBot extends Bot {
|
|
|
37
38
|
|
|
38
39
|
constructor(name: string, country: string, enableLogging = true) {
|
|
39
40
|
super(name, country);
|
|
40
|
-
this.missionController = new MissionController((message) => this.logBotStatus(message));
|
|
41
|
-
this.squadController = new SquadController();
|
|
41
|
+
this.missionController = new MissionController((message, sayInGame) => this.logBotStatus(message, sayInGame));
|
|
42
|
+
this.squadController = new SquadController((message, sayInGame) => this.logBotStatus(message, sayInGame));
|
|
42
43
|
this.queueController = new QueueController();
|
|
43
44
|
this.enableLogging = enableLogging;
|
|
44
45
|
}
|
|
@@ -50,13 +51,15 @@ export class SupalosaBot extends Bot {
|
|
|
50
51
|
this.tickRatio = Math.ceil(gameRate / botRate);
|
|
51
52
|
|
|
52
53
|
this.knownMapBounds = determineMapBounds(game.mapApi);
|
|
54
|
+
const myPlayer = game.getPlayerData(this.name);
|
|
53
55
|
|
|
54
56
|
this.matchAwareness = new MatchAwarenessImpl(
|
|
55
57
|
null,
|
|
56
58
|
new SectorCache(game.mapApi, this.knownMapBounds),
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
+
myPlayer.startLocation,
|
|
60
|
+
(message, sayInGame) => this.logBotStatus(message, sayInGame),
|
|
59
61
|
);
|
|
62
|
+
this.matchAwareness.onGameStart(game, myPlayer);
|
|
60
63
|
|
|
61
64
|
this.logBotStatus(`Map bounds: ${this.knownMapBounds.x}, ${this.knownMapBounds.y}`);
|
|
62
65
|
}
|
|
@@ -72,7 +75,7 @@ export class SupalosaBot extends Bot {
|
|
|
72
75
|
this.logDebugState(game);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
if (game.getCurrentTick() % this.tickRatio === 0) {
|
|
78
|
+
if (game.getCurrentTick() % this.tickRatio! === 0) {
|
|
76
79
|
const myPlayer = game.getPlayerData(this.name);
|
|
77
80
|
|
|
78
81
|
this.matchAwareness.onAiUpdate(game, myPlayer);
|
|
@@ -116,22 +119,24 @@ export class SupalosaBot extends Bot {
|
|
|
116
119
|
|
|
117
120
|
// Squad logic every 3 ticks
|
|
118
121
|
if (this.gameApi.getCurrentTick() % 3 === 0) {
|
|
119
|
-
this.squadController.onAiUpdate(game, this.actionsApi, myPlayer, this.matchAwareness
|
|
120
|
-
this.logBotStatus(message),
|
|
121
|
-
);
|
|
122
|
+
this.squadController.onAiUpdate(game, this.actionsApi, myPlayer, this.matchAwareness);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
private getHumanTimestamp(game: GameApi) {
|
|
127
|
-
return
|
|
128
|
+
return formatTimeDuration(game.getCurrentTick() / NATURAL_TICK_RATE);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
private logBotStatus(message: string) {
|
|
131
|
+
private logBotStatus(message: string, sayInGame: boolean = false) {
|
|
131
132
|
if (!this.enableLogging) {
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
+
const timestamp = this.getHumanTimestamp(this.gameApi);
|
|
136
|
+
console.log(`[${timestamp} ${this.name}] ${message}`);
|
|
137
|
+
if (sayInGame) {
|
|
138
|
+
this.actionsApi.sayAll(`${timestamp}: ${message}`);
|
|
139
|
+
}
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
private logDebugState(game: GameApi) {
|
|
@@ -157,9 +162,9 @@ export class SupalosaBot extends Bot {
|
|
|
157
162
|
this.logBotStatus(`----- Cash: ${myPlayer.credits} ----- | Queues: ${queueState}`);
|
|
158
163
|
const harvesters = game.getVisibleUnits(this.name, "self", (r) => r.harvester).length;
|
|
159
164
|
this.logBotStatus(`Harvesters: ${harvesters}`);
|
|
165
|
+
this.squadController.debugSquads(this.gameApi);
|
|
160
166
|
this.logBotStatus(`----- End -----`);
|
|
161
167
|
this.missionController.logDebugOutput();
|
|
162
|
-
this.actionsApi.sayAll(`Cash: ${myPlayer.credits}`);
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
override onGameEvent(ev: ApiEvent) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { GameApi, ObjectType, PlayerData, Point2D, UnitData } from "@chronodivide/game-api";
|
|
2
2
|
import { SectorCache } from "./map/sector";
|
|
3
3
|
import { GlobalThreat } from "./threat/threat";
|
|
4
|
-
import { calculateGlobalThreat } from "
|
|
5
|
-
import { determineMapBounds, getDistanceBetweenPoints, getPointTowardsOtherPoint } from "
|
|
6
|
-
import { Circle, Quadtree
|
|
4
|
+
import { calculateGlobalThreat } from "./threat/threatCalculator.js";
|
|
5
|
+
import { determineMapBounds, getDistanceBetweenPoints, getPointTowardsOtherPoint } from "./map/map.js";
|
|
6
|
+
import { Circle, Quadtree } from "@timohausmann/quadtree-ts";
|
|
7
|
+
import { ScoutingManager } from "./common/scout.js";
|
|
8
|
+
|
|
9
|
+
export type UnitPositionQuery = { x: number; y: number; unitId: number };
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* The bot's understanding of the current state of the game.
|
|
@@ -31,6 +34,8 @@ export interface MatchAwareness {
|
|
|
31
34
|
*/
|
|
32
35
|
getMainRallyPoint(): Point2D;
|
|
33
36
|
|
|
37
|
+
onGameStart(gameApi: GameApi, playerData: PlayerData): void;
|
|
38
|
+
|
|
34
39
|
/**
|
|
35
40
|
* Update the internal state of the Ai.
|
|
36
41
|
* @param gameApi
|
|
@@ -42,6 +47,8 @@ export interface MatchAwareness {
|
|
|
42
47
|
* True if the AI should initiate an attack.
|
|
43
48
|
*/
|
|
44
49
|
shouldAttack(): boolean;
|
|
50
|
+
|
|
51
|
+
getScoutingManager(): ScoutingManager;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
const SECTORS_TO_UPDATE_PER_CYCLE = 8;
|
|
@@ -51,7 +58,6 @@ const RALLY_POINT_UPDATE_INTERVAL_TICKS = 60;
|
|
|
51
58
|
const THREAT_UPDATE_INTERVAL_TICKS = 30;
|
|
52
59
|
|
|
53
60
|
type QTUnit = Circle<number>;
|
|
54
|
-
export type UnitPositionQuery = { x: number; y: number; unitId: number };
|
|
55
61
|
|
|
56
62
|
const rebuildQuadtree = (quadtree: Quadtree<QTUnit>, units: UnitData[]) => {
|
|
57
63
|
quadtree.clear();
|
|
@@ -64,15 +70,17 @@ export class MatchAwarenessImpl implements MatchAwareness {
|
|
|
64
70
|
private _shouldAttack: boolean = false;
|
|
65
71
|
|
|
66
72
|
private hostileQuadTree: Quadtree<QTUnit>;
|
|
73
|
+
private scoutingManager: ScoutingManager;
|
|
67
74
|
|
|
68
75
|
constructor(
|
|
69
76
|
private threatCache: GlobalThreat | null,
|
|
70
77
|
private sectorCache: SectorCache,
|
|
71
78
|
private mainRallyPoint: Point2D,
|
|
72
|
-
private logger: (message: string) => void,
|
|
79
|
+
private logger: (message: string, sayInGame?: boolean) => void,
|
|
73
80
|
) {
|
|
74
81
|
const { x: width, y: height } = sectorCache.getMapBounds();
|
|
75
82
|
this.hostileQuadTree = new Quadtree({ width, height });
|
|
83
|
+
this.scoutingManager = new ScoutingManager(logger);
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
getHostilesNearPoint2d(point: Point2D, radius: number): UnitPositionQuery[] {
|
|
@@ -96,6 +104,9 @@ export class MatchAwarenessImpl implements MatchAwareness {
|
|
|
96
104
|
getMainRallyPoint(): Point2D {
|
|
97
105
|
return this.mainRallyPoint;
|
|
98
106
|
}
|
|
107
|
+
getScoutingManager(): ScoutingManager {
|
|
108
|
+
return this.scoutingManager;
|
|
109
|
+
}
|
|
99
110
|
|
|
100
111
|
shouldAttack(): boolean {
|
|
101
112
|
return this._shouldAttack;
|
|
@@ -121,11 +132,17 @@ export class MatchAwarenessImpl implements MatchAwareness {
|
|
|
121
132
|
return hostilePlayerNames.includes(unit.owner);
|
|
122
133
|
}
|
|
123
134
|
|
|
135
|
+
public onGameStart(gameApi: GameApi, playerData: PlayerData) {
|
|
136
|
+
this.scoutingManager.onGameStart(gameApi, playerData, this.sectorCache);
|
|
137
|
+
}
|
|
138
|
+
|
|
124
139
|
onAiUpdate(game: GameApi, playerData: PlayerData): void {
|
|
125
140
|
const sectorCache = this.sectorCache;
|
|
126
141
|
|
|
127
142
|
sectorCache.updateSectors(game.getCurrentTick(), SECTORS_TO_UPDATE_PER_CYCLE, game.mapApi, playerData);
|
|
128
143
|
|
|
144
|
+
this.scoutingManager.onAiUpdate(game, playerData);
|
|
145
|
+
|
|
129
146
|
let updateRatio = sectorCache?.getSectorUpdateRatio(game.getCurrentTick() - game.getTickRate() * 60);
|
|
130
147
|
if (updateRatio && updateRatio < 1.0) {
|
|
131
148
|
this.logger(`${updateRatio * 100.0}% of sectors updated in last 60 seconds.`);
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { GameApi, PlayerData, Point2D, TechnoRules } from "@chronodivide/game-api";
|
|
2
|
-
import { getPointTowardsOtherPoint } from "../map/map.js";
|
|
3
|
-
import { GlobalThreat } from "../threat/threat.js";
|
|
4
|
-
import { AiBuildingRules, getDefaultPlacementLocation, numBuildingsOwnedOfType } from "./
|
|
5
|
-
|
|
6
|
-
export class AntiGroundStaticDefence implements AiBuildingRules {
|
|
7
|
-
constructor(private basePriority: number, private baseAmount: number, private strength: number) {}
|
|
8
|
-
|
|
9
|
-
getPlacementLocation(
|
|
10
|
-
game: GameApi,
|
|
11
|
-
playerData: PlayerData,
|
|
12
|
-
technoRules: TechnoRules
|
|
13
|
-
): { rx: number; ry: number } | undefined {
|
|
14
|
-
// Prefer front towards enemy.
|
|
15
|
-
let startLocation = playerData.startLocation;
|
|
16
|
-
let players = game.getPlayers();
|
|
17
|
-
let enemyFacingLocationCandidates: Point2D[] = [];
|
|
18
|
-
for (let i = 0; i < players.length; ++i) {
|
|
19
|
-
let playerName = players[i];
|
|
20
|
-
if (playerName == playerData.name) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
let enemyPlayer = game.getPlayerData(playerName);
|
|
24
|
-
enemyFacingLocationCandidates.push(
|
|
25
|
-
getPointTowardsOtherPoint(game, startLocation, enemyPlayer.startLocation, 4, 16, 1.5)
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
let selectedLocation =
|
|
29
|
-
enemyFacingLocationCandidates[Math.floor(game.generateRandom() * enemyFacingLocationCandidates.length)];
|
|
30
|
-
return getDefaultPlacementLocation(game, playerData, selectedLocation, technoRules);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getPriority(
|
|
34
|
-
game: GameApi,
|
|
35
|
-
playerData: PlayerData,
|
|
36
|
-
technoRules: TechnoRules,
|
|
37
|
-
threatCache: GlobalThreat | null
|
|
38
|
-
): number {
|
|
39
|
-
// If the enemy's ground power is increasing we should try to keep up.
|
|
40
|
-
if (threatCache) {
|
|
41
|
-
let denominator =
|
|
42
|
-
threatCache.totalAvailableAntiGroundFirepower + threatCache.totalDefensivePower + this.strength;
|
|
43
|
-
if (threatCache.totalOffensiveLandThreat > denominator * 1.1) {
|
|
44
|
-
return this.basePriority * (threatCache.totalOffensiveLandThreat / Math.max(1, denominator));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const strengthPerCost = (this.strength / technoRules.cost) * 1000;
|
|
48
|
-
const numOwned = numBuildingsOwnedOfType(game, playerData, technoRules);
|
|
49
|
-
return this.basePriority * (1.0 - numOwned / this.baseAmount) * strengthPerCost;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getMaxCount(
|
|
53
|
-
game: GameApi,
|
|
54
|
-
playerData: PlayerData,
|
|
55
|
-
technoRules: TechnoRules,
|
|
56
|
-
threatCache: GlobalThreat | null
|
|
57
|
-
): number | null {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
import { GameApi, PlayerData, Point2D, TechnoRules } from "@chronodivide/game-api";
|
|
2
|
+
import { getPointTowardsOtherPoint } from "../map/map.js";
|
|
3
|
+
import { GlobalThreat } from "../threat/threat.js";
|
|
4
|
+
import { AiBuildingRules, getDefaultPlacementLocation, numBuildingsOwnedOfType } from "./buildingRules.js";
|
|
5
|
+
|
|
6
|
+
export class AntiGroundStaticDefence implements AiBuildingRules {
|
|
7
|
+
constructor(private basePriority: number, private baseAmount: number, private strength: number) {}
|
|
8
|
+
|
|
9
|
+
getPlacementLocation(
|
|
10
|
+
game: GameApi,
|
|
11
|
+
playerData: PlayerData,
|
|
12
|
+
technoRules: TechnoRules
|
|
13
|
+
): { rx: number; ry: number } | undefined {
|
|
14
|
+
// Prefer front towards enemy.
|
|
15
|
+
let startLocation = playerData.startLocation;
|
|
16
|
+
let players = game.getPlayers();
|
|
17
|
+
let enemyFacingLocationCandidates: Point2D[] = [];
|
|
18
|
+
for (let i = 0; i < players.length; ++i) {
|
|
19
|
+
let playerName = players[i];
|
|
20
|
+
if (playerName == playerData.name) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
let enemyPlayer = game.getPlayerData(playerName);
|
|
24
|
+
enemyFacingLocationCandidates.push(
|
|
25
|
+
getPointTowardsOtherPoint(game, startLocation, enemyPlayer.startLocation, 4, 16, 1.5)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
let selectedLocation =
|
|
29
|
+
enemyFacingLocationCandidates[Math.floor(game.generateRandom() * enemyFacingLocationCandidates.length)];
|
|
30
|
+
return getDefaultPlacementLocation(game, playerData, selectedLocation, technoRules, 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getPriority(
|
|
34
|
+
game: GameApi,
|
|
35
|
+
playerData: PlayerData,
|
|
36
|
+
technoRules: TechnoRules,
|
|
37
|
+
threatCache: GlobalThreat | null
|
|
38
|
+
): number {
|
|
39
|
+
// If the enemy's ground power is increasing we should try to keep up.
|
|
40
|
+
if (threatCache) {
|
|
41
|
+
let denominator =
|
|
42
|
+
threatCache.totalAvailableAntiGroundFirepower + threatCache.totalDefensivePower + this.strength;
|
|
43
|
+
if (threatCache.totalOffensiveLandThreat > denominator * 1.1) {
|
|
44
|
+
return this.basePriority * (threatCache.totalOffensiveLandThreat / Math.max(1, denominator));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const strengthPerCost = (this.strength / technoRules.cost) * 1000;
|
|
48
|
+
const numOwned = numBuildingsOwnedOfType(game, playerData, technoRules);
|
|
49
|
+
return this.basePriority * (1.0 - numOwned / this.baseAmount) * strengthPerCost;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getMaxCount(
|
|
53
|
+
game: GameApi,
|
|
54
|
+
playerData: PlayerData,
|
|
55
|
+
technoRules: TechnoRules,
|
|
56
|
+
threatCache: GlobalThreat | null
|
|
57
|
+
): number | null {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|