@supalosa/chronodivide-bot 0.2.0 → 0.2.2
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/.prettierrc +5 -5
- package/README.md +11 -3
- package/dist/bot/bot.js +15 -7
- 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/awarenessImpl.js +132 -0
- package/dist/bot/logic/awarenessImpl.js.map +1 -0
- package/dist/bot/logic/building/ArtilleryUnit.js +1 -0
- package/dist/bot/logic/building/ArtilleryUnit.js.map +1 -0
- package/dist/bot/logic/building/antiGroundStaticDefence.js +1 -0
- package/dist/bot/logic/building/antiGroundStaticDefence.js.map +1 -0
- package/dist/bot/logic/building/basicAirUnit.js +1 -0
- package/dist/bot/logic/building/basicAirUnit.js.map +1 -0
- package/dist/bot/logic/building/basicBuilding.js +1 -0
- package/dist/bot/logic/building/basicBuilding.js.map +1 -0
- package/dist/bot/logic/building/basicGroundUnit.js +1 -0
- package/dist/bot/logic/building/basicGroundUnit.js.map +1 -0
- package/dist/bot/logic/building/building.js +57 -11
- package/dist/bot/logic/building/building.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 +1 -0
- package/dist/bot/logic/building/powerPlant.js.map +1 -0
- package/dist/bot/logic/building/queueController.js +1 -0
- package/dist/bot/logic/building/queueController.js.map +1 -0
- package/dist/bot/logic/building/resourceCollectionBuilding.js +1 -0
- 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 +2 -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 +1 -0
- package/dist/bot/logic/mission/missionFactories.js.map +1 -0
- package/dist/bot/logic/mission/missions/attackMission.js +7 -8
- 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/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/attackSquad.js +63 -56
- package/dist/bot/logic/squad/behaviours/combatSquad.js +6 -3
- package/dist/bot/logic/squad/behaviours/combatSquad.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/common.js +7 -4
- package/dist/bot/logic/squad/behaviours/common.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/defenceSquad.js +15 -2
- 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 +3 -3
- 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 +24 -7
- package/dist/exampleBot.js.map +1 -0
- package/package.json +9 -6
- package/src/bot/bot.ts +17 -11
- package/src/bot/logic/awareness.ts +22 -5
- package/src/bot/logic/building/ArtilleryUnit.ts +43 -43
- package/src/bot/logic/building/antiGroundStaticDefence.ts +60 -60
- package/src/bot/logic/building/basicAirUnit.ts +68 -68
- package/src/bot/logic/building/basicBuilding.ts +47 -47
- package/src/bot/logic/building/building.ts +72 -12
- package/src/bot/logic/building/powerPlant.ts +32 -32
- 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 +1 -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 +3 -0
- package/src/bot/logic/mission/missions/attackMission.ts +19 -13
- package/src/bot/logic/mission/missions/defenceMission.ts +35 -15
- 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 +6 -2
- package/src/bot/logic/squad/behaviours/common.ts +6 -4
- package/src/bot/logic/squad/behaviours/retreatSquad.ts +10 -12
- package/src/bot/logic/squad/behaviours/scoutingSquad.ts +81 -23
- package/src/bot/logic/squad/squad.ts +3 -2
- package/src/bot/logic/squad/squadBehaviour.ts +3 -1
- package/src/bot/logic/squad/squadController.ts +136 -69
- package/src/bot/logic/threat/threat.ts +15 -15
- package/src/bot/logic/threat/threatCalculator.ts +99 -99
- package/src/exampleBot.ts +25 -6
- package/tsconfig.json +73 -73
- 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/squadExpansion.js +0 -31
- package/dist/bot/logic/squad/behaviours/squadScouters.js +0 -8
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// A periodically-refreshed cache of known threats to a bot so we can use it in decision making.
|
|
2
|
-
|
|
3
|
-
export class GlobalThreat {
|
|
4
|
-
constructor(
|
|
5
|
-
public certainty: number, // 0.0 - 1.0 based on approximate visibility around the map.
|
|
6
|
-
public totalOffensiveLandThreat: number, // a number that approximates how much land-based firepower our opponents have.
|
|
7
|
-
public totalOffensiveAirThreat: number, // a number that approximates how much airborne firepower our opponents have.
|
|
8
|
-
public totalOffensiveAntiAirThreat: number, // a number that approximates how much anti-air firepower our opponents have.
|
|
9
|
-
public totalDefensiveThreat: number, // a number that approximates how much defensive power our opponents have.
|
|
10
|
-
public totalDefensivePower: number, // a number that approximates how much defensive power we have.
|
|
11
|
-
public totalAvailableAntiGroundFirepower: number, // how much anti-ground power we have
|
|
12
|
-
public totalAvailableAntiAirFirepower: number, // how much anti-air power we have
|
|
13
|
-
public totalAvailableAirPower: number, // how much firepower we have in air units
|
|
14
|
-
) {}
|
|
15
|
-
}
|
|
1
|
+
// A periodically-refreshed cache of known threats to a bot so we can use it in decision making.
|
|
2
|
+
|
|
3
|
+
export class GlobalThreat {
|
|
4
|
+
constructor(
|
|
5
|
+
public certainty: number, // 0.0 - 1.0 based on approximate visibility around the map.
|
|
6
|
+
public totalOffensiveLandThreat: number, // a number that approximates how much land-based firepower our opponents have.
|
|
7
|
+
public totalOffensiveAirThreat: number, // a number that approximates how much airborne firepower our opponents have.
|
|
8
|
+
public totalOffensiveAntiAirThreat: number, // a number that approximates how much anti-air firepower our opponents have.
|
|
9
|
+
public totalDefensiveThreat: number, // a number that approximates how much defensive power our opponents have.
|
|
10
|
+
public totalDefensivePower: number, // a number that approximates how much defensive power we have.
|
|
11
|
+
public totalAvailableAntiGroundFirepower: number, // how much anti-ground power we have
|
|
12
|
+
public totalAvailableAntiAirFirepower: number, // how much anti-air power we have
|
|
13
|
+
public totalAvailableAirPower: number, // how much firepower we have in air units
|
|
14
|
+
) {}
|
|
15
|
+
}
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import { GameApi, MovementZone, ObjectType, PlayerData, UnitData } from "@chronodivide/game-api";
|
|
2
|
-
import { GlobalThreat } from "./threat.js";
|
|
3
|
-
|
|
4
|
-
export function calculateGlobalThreat(game: GameApi, playerData: PlayerData, visibleAreaPercent: number): GlobalThreat {
|
|
5
|
-
let groundUnits = game.getVisibleUnits(
|
|
6
|
-
playerData.name,
|
|
7
|
-
"hostile",
|
|
8
|
-
(r) => r.type == ObjectType.Vehicle || r.type == ObjectType.Infantry,
|
|
9
|
-
);
|
|
10
|
-
let airUnits = game.getVisibleUnits(playerData.name, "hostile", (r) => r.movementZone == MovementZone.Fly);
|
|
11
|
-
let groundDefence = game
|
|
12
|
-
.getVisibleUnits(playerData.name, "hostile", (r) => r.type == ObjectType.Building)
|
|
13
|
-
.filter((unitId) => isAntiGround(game, unitId));
|
|
14
|
-
let antiAirPower = game
|
|
15
|
-
.getVisibleUnits(playerData.name, "hostile", (r) => r.type != ObjectType.Building)
|
|
16
|
-
.filter((unitId) => isAntiAir(game, unitId));
|
|
17
|
-
|
|
18
|
-
let ourAntiGroundUnits = game
|
|
19
|
-
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant)
|
|
20
|
-
.filter((unitId) => isAntiGround(game, unitId));
|
|
21
|
-
let ourAntiAirUnits = game
|
|
22
|
-
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant)
|
|
23
|
-
.filter((unitId) => isAntiAir(game, unitId));
|
|
24
|
-
let ourGroundDefence = game
|
|
25
|
-
.getVisibleUnits(playerData.name, "self", (r) => r.type == ObjectType.Building)
|
|
26
|
-
.filter((unitId) => isAntiGround(game, unitId));
|
|
27
|
-
let ourAirUnits = game.getVisibleUnits(
|
|
28
|
-
playerData.name,
|
|
29
|
-
"self",
|
|
30
|
-
(r) => r.movementZone == MovementZone.Fly && r.isSelectableCombatant,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
let observedGroundThreat = calculateFirepowerForUnits(game, groundUnits);
|
|
34
|
-
let observedAirThreat = calculateFirepowerForUnits(game, airUnits);
|
|
35
|
-
let observedAntiAirThreat = calculateFirepowerForUnits(game, antiAirPower);
|
|
36
|
-
let observedGroundDefence = calculateFirepowerForUnits(game, groundDefence);
|
|
37
|
-
|
|
38
|
-
let ourAntiGroundPower = calculateFirepowerForUnits(game, ourAntiGroundUnits);
|
|
39
|
-
let ourAntiAirPower = calculateFirepowerForUnits(game, ourAntiAirUnits);
|
|
40
|
-
let ourAirPower = calculateFirepowerForUnits(game, ourAirUnits);
|
|
41
|
-
let ourGroundDefencePower = calculateFirepowerForUnits(game, ourGroundDefence);
|
|
42
|
-
|
|
43
|
-
return new GlobalThreat(
|
|
44
|
-
visibleAreaPercent,
|
|
45
|
-
observedGroundThreat,
|
|
46
|
-
observedAirThreat,
|
|
47
|
-
observedAntiAirThreat,
|
|
48
|
-
observedGroundDefence * 0.25,
|
|
49
|
-
ourGroundDefencePower * 0.25,
|
|
50
|
-
ourAntiGroundPower,
|
|
51
|
-
ourAntiAirPower,
|
|
52
|
-
ourAirPower,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function isAntiGround(gameApi: GameApi, unitId: number): boolean {
|
|
57
|
-
let unit = gameApi.getUnitData(unitId);
|
|
58
|
-
if (unit && unit.primaryWeapon) {
|
|
59
|
-
return unit.primaryWeapon.projectileRules.isAntiGround;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function isAntiAir(gameApi: GameApi, unitId: number): boolean {
|
|
65
|
-
let unit = gameApi.getUnitData(unitId);
|
|
66
|
-
if (unit && unit.primaryWeapon) {
|
|
67
|
-
return unit.primaryWeapon.projectileRules.isAntiAir;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function calculateFirepowerForUnit(unitData: UnitData): number {
|
|
73
|
-
let threat = 0;
|
|
74
|
-
let hpRatio = unitData.hitPoints / Math.max(1, unitData.maxHitPoints);
|
|
75
|
-
if (unitData.primaryWeapon) {
|
|
76
|
-
threat +=
|
|
77
|
-
(hpRatio *
|
|
78
|
-
((unitData.primaryWeapon.rules.damage + 1) * Math.sqrt(unitData.primaryWeapon.rules.range + 1))) /
|
|
79
|
-
Math.max(unitData.primaryWeapon.cooldownTicks, 1);
|
|
80
|
-
}
|
|
81
|
-
if (unitData.secondaryWeapon) {
|
|
82
|
-
threat +=
|
|
83
|
-
(hpRatio *
|
|
84
|
-
((unitData.secondaryWeapon.rules.damage + 1) * Math.sqrt(unitData.secondaryWeapon.rules.range + 1))) /
|
|
85
|
-
Math.max(unitData.secondaryWeapon.cooldownTicks, 1);
|
|
86
|
-
}
|
|
87
|
-
return Math.min(800, threat);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function calculateFirepowerForUnits(game: GameApi, unitIds: number[]) {
|
|
91
|
-
let threat = 0;
|
|
92
|
-
unitIds.forEach((unitId) => {
|
|
93
|
-
let unitData = game.getUnitData(unitId);
|
|
94
|
-
if (unitData) {
|
|
95
|
-
threat += calculateFirepowerForUnit(unitData);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return threat;
|
|
99
|
-
}
|
|
1
|
+
import { GameApi, MovementZone, ObjectType, PlayerData, UnitData } from "@chronodivide/game-api";
|
|
2
|
+
import { GlobalThreat } from "./threat.js";
|
|
3
|
+
|
|
4
|
+
export function calculateGlobalThreat(game: GameApi, playerData: PlayerData, visibleAreaPercent: number): GlobalThreat {
|
|
5
|
+
let groundUnits = game.getVisibleUnits(
|
|
6
|
+
playerData.name,
|
|
7
|
+
"hostile",
|
|
8
|
+
(r) => r.type == ObjectType.Vehicle || r.type == ObjectType.Infantry,
|
|
9
|
+
);
|
|
10
|
+
let airUnits = game.getVisibleUnits(playerData.name, "hostile", (r) => r.movementZone == MovementZone.Fly);
|
|
11
|
+
let groundDefence = game
|
|
12
|
+
.getVisibleUnits(playerData.name, "hostile", (r) => r.type == ObjectType.Building)
|
|
13
|
+
.filter((unitId) => isAntiGround(game, unitId));
|
|
14
|
+
let antiAirPower = game
|
|
15
|
+
.getVisibleUnits(playerData.name, "hostile", (r) => r.type != ObjectType.Building)
|
|
16
|
+
.filter((unitId) => isAntiAir(game, unitId));
|
|
17
|
+
|
|
18
|
+
let ourAntiGroundUnits = game
|
|
19
|
+
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant)
|
|
20
|
+
.filter((unitId) => isAntiGround(game, unitId));
|
|
21
|
+
let ourAntiAirUnits = game
|
|
22
|
+
.getVisibleUnits(playerData.name, "self", (r) => r.isSelectableCombatant)
|
|
23
|
+
.filter((unitId) => isAntiAir(game, unitId));
|
|
24
|
+
let ourGroundDefence = game
|
|
25
|
+
.getVisibleUnits(playerData.name, "self", (r) => r.type == ObjectType.Building)
|
|
26
|
+
.filter((unitId) => isAntiGround(game, unitId));
|
|
27
|
+
let ourAirUnits = game.getVisibleUnits(
|
|
28
|
+
playerData.name,
|
|
29
|
+
"self",
|
|
30
|
+
(r) => r.movementZone == MovementZone.Fly && r.isSelectableCombatant,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
let observedGroundThreat = calculateFirepowerForUnits(game, groundUnits);
|
|
34
|
+
let observedAirThreat = calculateFirepowerForUnits(game, airUnits);
|
|
35
|
+
let observedAntiAirThreat = calculateFirepowerForUnits(game, antiAirPower);
|
|
36
|
+
let observedGroundDefence = calculateFirepowerForUnits(game, groundDefence);
|
|
37
|
+
|
|
38
|
+
let ourAntiGroundPower = calculateFirepowerForUnits(game, ourAntiGroundUnits);
|
|
39
|
+
let ourAntiAirPower = calculateFirepowerForUnits(game, ourAntiAirUnits);
|
|
40
|
+
let ourAirPower = calculateFirepowerForUnits(game, ourAirUnits);
|
|
41
|
+
let ourGroundDefencePower = calculateFirepowerForUnits(game, ourGroundDefence);
|
|
42
|
+
|
|
43
|
+
return new GlobalThreat(
|
|
44
|
+
visibleAreaPercent,
|
|
45
|
+
observedGroundThreat,
|
|
46
|
+
observedAirThreat,
|
|
47
|
+
observedAntiAirThreat,
|
|
48
|
+
observedGroundDefence * 0.25,
|
|
49
|
+
ourGroundDefencePower * 0.25,
|
|
50
|
+
ourAntiGroundPower,
|
|
51
|
+
ourAntiAirPower,
|
|
52
|
+
ourAirPower,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isAntiGround(gameApi: GameApi, unitId: number): boolean {
|
|
57
|
+
let unit = gameApi.getUnitData(unitId);
|
|
58
|
+
if (unit && unit.primaryWeapon) {
|
|
59
|
+
return unit.primaryWeapon.projectileRules.isAntiGround;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isAntiAir(gameApi: GameApi, unitId: number): boolean {
|
|
65
|
+
let unit = gameApi.getUnitData(unitId);
|
|
66
|
+
if (unit && unit.primaryWeapon) {
|
|
67
|
+
return unit.primaryWeapon.projectileRules.isAntiAir;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function calculateFirepowerForUnit(unitData: UnitData): number {
|
|
73
|
+
let threat = 0;
|
|
74
|
+
let hpRatio = unitData.hitPoints / Math.max(1, unitData.maxHitPoints);
|
|
75
|
+
if (unitData.primaryWeapon) {
|
|
76
|
+
threat +=
|
|
77
|
+
(hpRatio *
|
|
78
|
+
((unitData.primaryWeapon.rules.damage + 1) * Math.sqrt(unitData.primaryWeapon.rules.range + 1))) /
|
|
79
|
+
Math.max(unitData.primaryWeapon.cooldownTicks, 1);
|
|
80
|
+
}
|
|
81
|
+
if (unitData.secondaryWeapon) {
|
|
82
|
+
threat +=
|
|
83
|
+
(hpRatio *
|
|
84
|
+
((unitData.secondaryWeapon.rules.damage + 1) * Math.sqrt(unitData.secondaryWeapon.rules.range + 1))) /
|
|
85
|
+
Math.max(unitData.secondaryWeapon.cooldownTicks, 1);
|
|
86
|
+
}
|
|
87
|
+
return Math.min(800, threat);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function calculateFirepowerForUnits(game: GameApi, unitIds: number[]) {
|
|
91
|
+
let threat = 0;
|
|
92
|
+
unitIds.forEach((unitId) => {
|
|
93
|
+
let unitData = game.getUnitData(unitId);
|
|
94
|
+
if (unitData) {
|
|
95
|
+
threat += calculateFirepowerForUnit(unitData);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return threat;
|
|
99
|
+
}
|
package/src/exampleBot.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cdapi } from "@chronodivide/game-api";
|
|
1
|
+
import { Agent, Bot, cdapi } from "@chronodivide/game-api";
|
|
2
2
|
import { SupalosaBot } from "./bot/bot.js";
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
@@ -26,14 +26,33 @@ async function main() {
|
|
|
26
26
|
console.log("Server URL: " + process.env.SERVER_URL!);
|
|
27
27
|
console.log("Client URL: " + process.env.CLIENT_URL!);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
/*
|
|
30
|
+
Countries:
|
|
31
|
+
0=Americans
|
|
32
|
+
1=Alliance -> Korea
|
|
33
|
+
2=French
|
|
34
|
+
3=Germans
|
|
35
|
+
4=British
|
|
36
|
+
|
|
37
|
+
5=Africans -> Libya
|
|
38
|
+
6=Arabs -> Iraq
|
|
39
|
+
7=Confederation -> Cuba
|
|
40
|
+
8=Russians
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const onlineSettings = {
|
|
44
|
+
online: true as true,
|
|
32
45
|
serverUrl: process.env.SERVER_URL!,
|
|
33
46
|
clientUrl: process.env.CLIENT_URL!,
|
|
34
|
-
agents: [new SupalosaBot(botName, "Americans"), { name: otherBotName, country: "French" }]
|
|
47
|
+
agents: [new SupalosaBot(botName, "Americans"), { name: otherBotName, country: "French" }] as [Bot, ...Agent[]],
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const offlineSettings = {
|
|
35
51
|
agents: [new SupalosaBot(botName, "French", false), new SupalosaBot(otherBotName, "French", true)],
|
|
36
|
-
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const game = await cdapi.createGame({
|
|
55
|
+
...offlineSettings,
|
|
37
56
|
buildOffAlly: false,
|
|
38
57
|
cratesAppear: false,
|
|
39
58
|
credits: 10000,
|
package/tsconfig.json
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "es2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
|
|
8
|
-
"module": "es2020" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
9
|
-
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
-
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
13
|
-
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
-
|
|
16
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
-
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
|
18
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
-
// "composite": true, /* Enable project compilation */
|
|
20
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
-
|
|
27
|
-
/* Strict Type-Checking Options */
|
|
28
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
29
|
-
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
-
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
-
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
-
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
|
|
36
|
-
|
|
37
|
-
/* Additional Checks */
|
|
38
|
-
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
-
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
-
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
43
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
|
44
|
-
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
45
|
-
|
|
46
|
-
/* Module Resolution Options */
|
|
47
|
-
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
48
|
-
//"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
|
|
49
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
50
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
51
|
-
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
52
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
53
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
54
|
-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
55
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
56
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
57
|
-
|
|
58
|
-
/* Source Map Options */
|
|
59
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
60
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
62
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
63
|
-
|
|
64
|
-
/* Experimental Options */
|
|
65
|
-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
66
|
-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
67
|
-
|
|
68
|
-
/* Advanced Options */
|
|
69
|
-
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
|
70
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
71
|
-
},
|
|
72
|
-
"include": ["src/**/*"]
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Basic Options */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
"target": "es2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
|
|
8
|
+
"module": "es2020" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
9
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
12
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
13
|
+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
|
+
"outDir": "./dist" /* Redirect output structure to the directory. */,
|
|
18
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
19
|
+
// "composite": true, /* Enable project compilation */
|
|
20
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
21
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
23
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
|
+
|
|
27
|
+
/* Strict Type-Checking Options */
|
|
28
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
29
|
+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
30
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
31
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
32
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
33
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
34
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
35
|
+
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
|
|
36
|
+
|
|
37
|
+
/* Additional Checks */
|
|
38
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
39
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
40
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
41
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
42
|
+
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
43
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
|
|
44
|
+
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
|
45
|
+
|
|
46
|
+
/* Module Resolution Options */
|
|
47
|
+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
48
|
+
//"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
|
|
49
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
50
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
51
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
52
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
53
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
54
|
+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
|
55
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
56
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
57
|
+
|
|
58
|
+
/* Source Map Options */
|
|
59
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
60
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
62
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
63
|
+
|
|
64
|
+
/* Experimental Options */
|
|
65
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
66
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
67
|
+
|
|
68
|
+
/* Advanced Options */
|
|
69
|
+
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
|
70
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
71
|
+
},
|
|
72
|
+
"include": ["src/**/*"]
|
|
73
|
+
}
|
|
@@ -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,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
|
-
}
|