@supalosa/chronodivide-bot 0.5.4 → 0.6.6-beta.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.
Files changed (124) hide show
  1. package/.env.template +4 -4
  2. package/.github/workflows/npm-publish.yml +24 -0
  3. package/README.md +108 -103
  4. package/dist/bot/bot.js +105 -105
  5. package/dist/bot/logic/awareness.js +136 -136
  6. package/dist/bot/logic/building/antiAirStaticDefence.js +42 -42
  7. package/dist/bot/logic/building/antiGroundStaticDefence.js +34 -34
  8. package/dist/bot/logic/building/{ArtilleryUnit.js → artilleryUnit.js} +18 -18
  9. package/dist/bot/logic/building/basicAirUnit.js +19 -19
  10. package/dist/bot/logic/building/basicBuilding.js +26 -26
  11. package/dist/bot/logic/building/basicGroundUnit.js +19 -19
  12. package/dist/bot/logic/building/buildingRules.js +175 -175
  13. package/dist/bot/logic/building/common.js +19 -19
  14. package/dist/bot/logic/building/harvester.js +16 -16
  15. package/dist/bot/logic/building/powerPlant.js +20 -20
  16. package/dist/bot/logic/building/queueController.js +183 -183
  17. package/dist/bot/logic/building/resourceCollectionBuilding.js +36 -36
  18. package/dist/bot/logic/common/scout.js +126 -126
  19. package/dist/bot/logic/common/utils.js +95 -95
  20. package/dist/bot/logic/composition/alliedCompositions.js +12 -12
  21. package/dist/bot/logic/composition/common.js +1 -1
  22. package/dist/bot/logic/composition/sovietCompositions.js +12 -12
  23. package/dist/bot/logic/map/map.js +44 -44
  24. package/dist/bot/logic/map/sector.js +137 -137
  25. package/dist/bot/logic/mission/actionBatcher.js +91 -91
  26. package/dist/bot/logic/mission/mission.js +122 -122
  27. package/dist/bot/logic/mission/missionController.js +321 -321
  28. package/dist/bot/logic/mission/missionFactories.js +12 -12
  29. package/dist/bot/logic/mission/missions/attackMission.js +214 -214
  30. package/dist/bot/logic/mission/missions/defenceMission.js +82 -82
  31. package/dist/bot/logic/mission/missions/engineerMission.js +63 -63
  32. package/dist/bot/logic/mission/missions/expansionMission.js +60 -60
  33. package/dist/bot/logic/mission/missions/retreatMission.js +33 -33
  34. package/dist/bot/logic/mission/missions/scoutingMission.js +133 -133
  35. package/dist/bot/logic/mission/missions/squads/combatSquad.js +115 -115
  36. package/dist/bot/logic/mission/missions/squads/common.js +57 -57
  37. package/dist/bot/logic/mission/missions/squads/squad.js +1 -1
  38. package/dist/bot/logic/threat/threat.js +22 -22
  39. package/dist/bot/logic/threat/threatCalculator.js +73 -73
  40. package/dist/exampleBot.js +100 -100
  41. package/package.json +32 -29
  42. package/src/bot/bot.ts +161 -161
  43. package/src/bot/logic/awareness.ts +245 -245
  44. package/src/bot/logic/building/antiAirStaticDefence.ts +64 -64
  45. package/src/bot/logic/building/antiGroundStaticDefence.ts +55 -55
  46. package/src/bot/logic/building/artilleryUnit.ts +39 -39
  47. package/src/bot/logic/building/basicAirUnit.ts +39 -39
  48. package/src/bot/logic/building/basicBuilding.ts +49 -49
  49. package/src/bot/logic/building/basicGroundUnit.ts +39 -39
  50. package/src/bot/logic/building/buildingRules.ts +250 -250
  51. package/src/bot/logic/building/common.ts +21 -21
  52. package/src/bot/logic/building/harvester.ts +31 -31
  53. package/src/bot/logic/building/powerPlant.ts +32 -32
  54. package/src/bot/logic/building/queueController.ts +297 -297
  55. package/src/bot/logic/building/resourceCollectionBuilding.ts +52 -52
  56. package/src/bot/logic/common/scout.ts +183 -183
  57. package/src/bot/logic/common/utils.ts +120 -120
  58. package/src/bot/logic/composition/alliedCompositions.ts +22 -22
  59. package/src/bot/logic/composition/common.ts +3 -3
  60. package/src/bot/logic/composition/sovietCompositions.ts +21 -21
  61. package/src/bot/logic/map/map.ts +66 -66
  62. package/src/bot/logic/map/sector.ts +174 -174
  63. package/src/bot/logic/mission/actionBatcher.ts +124 -124
  64. package/src/bot/logic/mission/mission.ts +232 -232
  65. package/src/bot/logic/mission/missionController.ts +413 -413
  66. package/src/bot/logic/mission/missionFactories.ts +51 -51
  67. package/src/bot/logic/mission/missions/attackMission.ts +336 -336
  68. package/src/bot/logic/mission/missions/defenceMission.ts +151 -151
  69. package/src/bot/logic/mission/missions/engineerMission.ts +113 -113
  70. package/src/bot/logic/mission/missions/expansionMission.ts +104 -104
  71. package/src/bot/logic/mission/missions/retreatMission.ts +54 -54
  72. package/src/bot/logic/mission/missions/scoutingMission.ts +186 -186
  73. package/src/bot/logic/mission/missions/squads/combatSquad.ts +160 -160
  74. package/src/bot/logic/mission/missions/squads/common.ts +63 -63
  75. package/src/bot/logic/mission/missions/squads/squad.ts +19 -19
  76. package/src/bot/logic/threat/threat.ts +15 -15
  77. package/src/bot/logic/threat/threatCalculator.ts +100 -100
  78. package/src/exampleBot.ts +111 -111
  79. package/tsconfig.json +73 -73
  80. package/dist/bot/logic/awarenessImpl.js +0 -132
  81. package/dist/bot/logic/awarenessImpl.js.map +0 -1
  82. package/dist/bot/logic/building/building.js +0 -126
  83. package/dist/bot/logic/building/building.js.map +0 -1
  84. package/dist/bot/logic/mission/behaviours/combatSquad.js +0 -124
  85. package/dist/bot/logic/mission/behaviours/combatSquad.js.map +0 -1
  86. package/dist/bot/logic/mission/behaviours/common.js +0 -58
  87. package/dist/bot/logic/mission/behaviours/common.js.map +0 -1
  88. package/dist/bot/logic/mission/behaviours/engineerSquad.js +0 -39
  89. package/dist/bot/logic/mission/behaviours/engineerSquad.js.map +0 -1
  90. package/dist/bot/logic/mission/behaviours/expansionSquad.js +0 -46
  91. package/dist/bot/logic/mission/behaviours/expansionSquad.js.map +0 -1
  92. package/dist/bot/logic/mission/behaviours/retreatSquad.js +0 -31
  93. package/dist/bot/logic/mission/behaviours/retreatSquad.js.map +0 -1
  94. package/dist/bot/logic/mission/behaviours/scoutingSquad.js +0 -94
  95. package/dist/bot/logic/mission/behaviours/scoutingSquad.js.map +0 -1
  96. package/dist/bot/logic/mission/missions/basicMission.js +0 -13
  97. package/dist/bot/logic/mission/missions/basicMission.js.map +0 -1
  98. package/dist/bot/logic/mission/missions/missionBehaviour.js +0 -2
  99. package/dist/bot/logic/mission/missions/missionBehaviour.js.map +0 -1
  100. package/dist/bot/logic/mission/missions/oneTimeMission.js +0 -27
  101. package/dist/bot/logic/mission/missions/oneTimeMission.js.map +0 -1
  102. package/dist/bot/logic/squad/behaviours/attackSquad.js +0 -89
  103. package/dist/bot/logic/squad/behaviours/combatSquad.js +0 -102
  104. package/dist/bot/logic/squad/behaviours/combatSquad.js.map +0 -1
  105. package/dist/bot/logic/squad/behaviours/common.js +0 -40
  106. package/dist/bot/logic/squad/behaviours/common.js.map +0 -1
  107. package/dist/bot/logic/squad/behaviours/defenceSquad.js +0 -61
  108. package/dist/bot/logic/squad/behaviours/engineerSquad.js +0 -36
  109. package/dist/bot/logic/squad/behaviours/engineerSquad.js.map +0 -1
  110. package/dist/bot/logic/squad/behaviours/expansionSquad.js +0 -43
  111. package/dist/bot/logic/squad/behaviours/expansionSquad.js.map +0 -1
  112. package/dist/bot/logic/squad/behaviours/retreatSquad.js +0 -28
  113. package/dist/bot/logic/squad/behaviours/retreatSquad.js.map +0 -1
  114. package/dist/bot/logic/squad/behaviours/scoutingSquad.js +0 -86
  115. package/dist/bot/logic/squad/behaviours/scoutingSquad.js.map +0 -1
  116. package/dist/bot/logic/squad/squad.js +0 -126
  117. package/dist/bot/logic/squad/squad.js.map +0 -1
  118. package/dist/bot/logic/squad/squadBehaviour.js +0 -6
  119. package/dist/bot/logic/squad/squadBehaviour.js.map +0 -1
  120. package/dist/bot/logic/squad/squadBehaviours.js +0 -7
  121. package/dist/bot/logic/squad/squadBehaviours.js.map +0 -1
  122. package/dist/bot/logic/squad/squadController.js +0 -199
  123. package/dist/bot/logic/squad/squadController.js.map +0 -1
  124. /package/dist/bot/logic/building/{ArtilleryUnit.js.map → artilleryUnit.js.map} +0 -0
@@ -1,100 +1,100 @@
1
- import { GameApi, GameMath, 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
- "enemy",
8
- (r) => r.type == ObjectType.Vehicle || r.type == ObjectType.Infantry,
9
- );
10
- let airUnits = game.getVisibleUnits(playerData.name, "enemy", (r) => r.movementZone == MovementZone.Fly);
11
- let groundDefence = game
12
- .getVisibleUnits(playerData.name, "enemy", (r) => r.type == ObjectType.Building)
13
- .filter((unitId) => isAntiGround(game, unitId));
14
- let antiAirPower = game
15
- .getVisibleUnits(playerData.name, "enemy", (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 || r.type === ObjectType.Building)
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,
49
- ourGroundDefencePower,
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) * GameMath.sqrt(unitData.primaryWeapon.rules.range + 1))) /
79
- Math.max(unitData.primaryWeapon.rules.rof, 1);
80
- }
81
- if (unitData.secondaryWeapon) {
82
- threat +=
83
- (hpRatio *
84
- ((unitData.secondaryWeapon.rules.damage + 1) *
85
- GameMath.sqrt(unitData.secondaryWeapon.rules.range + 1))) /
86
- Math.max(unitData.secondaryWeapon.rules.rof, 1);
87
- }
88
- return Math.min(800, threat);
89
- }
90
-
91
- function calculateFirepowerForUnits(game: GameApi, unitIds: number[]) {
92
- let threat = 0;
93
- unitIds.forEach((unitId) => {
94
- let unitData = game.getUnitData(unitId);
95
- if (unitData) {
96
- threat += calculateFirepowerForUnit(unitData);
97
- }
98
- });
99
- return threat;
100
- }
1
+ import { GameApi, GameMath, 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
+ "enemy",
8
+ (r) => r.type == ObjectType.Vehicle || r.type == ObjectType.Infantry,
9
+ );
10
+ let airUnits = game.getVisibleUnits(playerData.name, "enemy", (r) => r.movementZone == MovementZone.Fly);
11
+ let groundDefence = game
12
+ .getVisibleUnits(playerData.name, "enemy", (r) => r.type == ObjectType.Building)
13
+ .filter((unitId) => isAntiGround(game, unitId));
14
+ let antiAirPower = game
15
+ .getVisibleUnits(playerData.name, "enemy", (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 || r.type === ObjectType.Building)
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,
49
+ ourGroundDefencePower,
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) * GameMath.sqrt(unitData.primaryWeapon.rules.range + 1))) /
79
+ Math.max(unitData.primaryWeapon.rules.rof, 1);
80
+ }
81
+ if (unitData.secondaryWeapon) {
82
+ threat +=
83
+ (hpRatio *
84
+ ((unitData.secondaryWeapon.rules.damage + 1) *
85
+ GameMath.sqrt(unitData.secondaryWeapon.rules.range + 1))) /
86
+ Math.max(unitData.secondaryWeapon.rules.rof, 1);
87
+ }
88
+ return Math.min(800, threat);
89
+ }
90
+
91
+ function calculateFirepowerForUnits(game: GameApi, unitIds: number[]) {
92
+ let threat = 0;
93
+ unitIds.forEach((unitId) => {
94
+ let unitData = game.getUnitData(unitId);
95
+ if (unitData) {
96
+ threat += calculateFirepowerForUnit(unitData);
97
+ }
98
+ });
99
+ return threat;
100
+ }
package/src/exampleBot.ts CHANGED
@@ -1,111 +1,111 @@
1
- import "dotenv/config";
2
- import { Agent, Bot, CreateBaseOpts, CreateOfflineOpts, CreateOnlineOpts, cdapi } from "@chronodivide/game-api";
3
- import { SupalosaBot } from "./bot/bot.js";
4
- import { Countries } from "./bot/logic/common/utils.js";
5
-
6
- // The game will automatically end after this time. This is to handle stalemates.
7
- const MAX_GAME_LENGTH_SECONDS: number | null = 7200; // 7200 = two hours
8
-
9
- async function main() {
10
- /*
11
- Ladder maps:
12
- CDR2 1v1 2_malibu_cliffs_le.map
13
- CDR2 1v1 4_country_swing_le_v2.map
14
- CDR2 1v1 mp01t4.map, large map, oil derricks
15
- CDR2 1v1 tn04t2.map, small map
16
- CDR2 1v1 mp10s4.map <- depth charge, naval map (not supported). Cramped in position 1.
17
- CDR2 1v1 heckcorners.map
18
- CDR2 1v1 4_montana_dmz_le.map
19
- CDR2 1v1 barrel.map
20
-
21
- Other maps:
22
- mp03t4 large map, no oil derricks
23
- 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,
24
- 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,
25
- 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,
26
- 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,
27
- 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,
28
- 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,
29
- 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,
30
- 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,
31
- 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,
32
- 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,
33
- 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,
34
- 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,
35
- offensedefense.map,ore2_startfixed.map,rekoool_fast_6players.mpr,rekoool_fast_8players.mpr,riverram.map,tourofegypt.map,unrepent.map,sinkswim_yr_port.map
36
- */
37
- const mapName = "heckcorners_b.map";
38
- // Bot names must be unique in online mode
39
- const timestamp = String(Date.now()).substr(-6);
40
- const firstBotName = `Joe${timestamp}`;
41
- const secondBotName = `Bob${timestamp}`;
42
- const thirdBotName = `Mike${timestamp}`;
43
- const fourthBotName = `Charlie${timestamp}`;
44
-
45
- await cdapi.init(process.env.MIX_DIR || "./");
46
-
47
- console.log("Server URL: " + process.env.SERVER_URL!);
48
- console.log("Client URL: " + process.env.CLIENT_URL!);
49
-
50
- const baseSettings: CreateBaseOpts = {
51
- buildOffAlly: false,
52
- cratesAppear: false,
53
- credits: 10000,
54
- gameMode: cdapi.getAvailableGameModes(mapName)[0],
55
- gameSpeed: 6,
56
- mapName,
57
- mcvRepacks: true,
58
- shortGame: true,
59
- superWeapons: false,
60
- unitCount: 0,
61
- };
62
-
63
- const onlineSettings: CreateOnlineOpts = {
64
- ...baseSettings,
65
- online: true,
66
- serverUrl: process.env.SERVER_URL!,
67
- clientUrl: process.env.CLIENT_URL!,
68
- agents: [
69
- new SupalosaBot(process.env.ONLINE_BOT_NAME ?? firstBotName, Countries.USA),
70
- { name: process.env.PLAYER_NAME ?? secondBotName, country: Countries.FRANCE },
71
- ] as [Bot, ...Agent[]],
72
- botPassword: process.env.ONLINE_BOT_PASSWORD ?? "default",
73
- };
74
-
75
- const offlineSettings1v1: CreateOfflineOpts = {
76
- ...baseSettings,
77
- online: false,
78
- agents: [
79
- new SupalosaBot(firstBotName, Countries.FRANCE, [], false),
80
- new SupalosaBot(secondBotName, Countries.RUSSIA, [], true).setDebugMode(true),
81
- ],
82
- };
83
-
84
- const offlineSettings2v2: CreateOfflineOpts = {
85
- ...baseSettings,
86
- online: false,
87
- agents: [
88
- new SupalosaBot(firstBotName, Countries.FRANCE, [firstBotName], false),
89
- new SupalosaBot(secondBotName, Countries.RUSSIA, [firstBotName], true).setDebugMode(true),
90
- new SupalosaBot(thirdBotName, Countries.RUSSIA, [fourthBotName], false),
91
- new SupalosaBot(fourthBotName, Countries.FRANCE, [thirdBotName], false),
92
- ],
93
- };
94
-
95
- const game = await cdapi.createGame(process.env.ONLINE_MATCH ? onlineSettings : offlineSettings1v1);
96
- while (!game.isFinished()) {
97
- if (!!MAX_GAME_LENGTH_SECONDS && game.getCurrentTick() / 15 > MAX_GAME_LENGTH_SECONDS) {
98
- console.log(`Game forced to end due to timeout`);
99
- break;
100
- }
101
- await game.update();
102
- }
103
-
104
- game.saveReplay();
105
- game.dispose();
106
- }
107
-
108
- main().catch((e) => {
109
- console.error(e);
110
- process.exit(1);
111
- });
1
+ import "dotenv/config";
2
+ import { Agent, Bot, CreateBaseOpts, CreateOfflineOpts, CreateOnlineOpts, cdapi } from "@chronodivide/game-api";
3
+ import { SupalosaBot } from "./bot/bot.js";
4
+ import { Countries } from "./bot/logic/common/utils.js";
5
+
6
+ // The game will automatically end after this time. This is to handle stalemates.
7
+ const MAX_GAME_LENGTH_SECONDS: number | null = 7200; // 7200 = two hours
8
+
9
+ async function main() {
10
+ /*
11
+ Ladder maps:
12
+ CDR2 1v1 2_malibu_cliffs_le.map
13
+ CDR2 1v1 4_country_swing_le_v2.map
14
+ CDR2 1v1 mp01t4.map, large map, oil derricks
15
+ CDR2 1v1 tn04t2.map, small map
16
+ CDR2 1v1 mp10s4.map <- depth charge, naval map (not supported). Cramped in position 1.
17
+ CDR2 1v1 heckcorners.map
18
+ CDR2 1v1 4_montana_dmz_le.map
19
+ CDR2 1v1 barrel.map
20
+
21
+ Other maps:
22
+ mp03t4 large map, no oil derricks
23
+ 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,
24
+ 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,
25
+ 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,
26
+ 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,
27
+ 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,
28
+ 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,
29
+ 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,
30
+ 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,
31
+ 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,
32
+ 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,
33
+ 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,
34
+ 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,
35
+ offensedefense.map,ore2_startfixed.map,rekoool_fast_6players.mpr,rekoool_fast_8players.mpr,riverram.map,tourofegypt.map,unrepent.map,sinkswim_yr_port.map
36
+ */
37
+ const mapName = "heckcorners_b.map";
38
+ // Bot names must be unique in online mode
39
+ const timestamp = String(Date.now()).substr(-6);
40
+ const firstBotName = `Joe${timestamp}`;
41
+ const secondBotName = `Bob${timestamp}`;
42
+ const thirdBotName = `Mike${timestamp}`;
43
+ const fourthBotName = `Charlie${timestamp}`;
44
+
45
+ await cdapi.init(process.env.MIX_DIR || "./");
46
+
47
+ console.log("Server URL: " + process.env.SERVER_URL!);
48
+ console.log("Client URL: " + process.env.CLIENT_URL!);
49
+
50
+ const baseSettings: CreateBaseOpts = {
51
+ buildOffAlly: false,
52
+ cratesAppear: false,
53
+ credits: 10000,
54
+ gameMode: cdapi.getAvailableGameModes(mapName)[0],
55
+ gameSpeed: 6,
56
+ mapName,
57
+ mcvRepacks: true,
58
+ shortGame: true,
59
+ superWeapons: false,
60
+ unitCount: 0,
61
+ };
62
+
63
+ const onlineSettings: CreateOnlineOpts = {
64
+ ...baseSettings,
65
+ online: true,
66
+ serverUrl: process.env.SERVER_URL!,
67
+ clientUrl: process.env.CLIENT_URL!,
68
+ agents: [
69
+ new SupalosaBot(process.env.ONLINE_BOT_NAME ?? firstBotName, Countries.USA),
70
+ { name: process.env.PLAYER_NAME ?? secondBotName, country: Countries.FRANCE },
71
+ ] as [Bot, ...Agent[]],
72
+ botPassword: process.env.ONLINE_BOT_PASSWORD ?? "default",
73
+ };
74
+
75
+ const offlineSettings1v1: CreateOfflineOpts = {
76
+ ...baseSettings,
77
+ online: false,
78
+ agents: [
79
+ new SupalosaBot(firstBotName, Countries.FRANCE, [], false),
80
+ new SupalosaBot(secondBotName, Countries.RUSSIA, [], true).setDebugMode(true),
81
+ ],
82
+ };
83
+
84
+ const offlineSettings2v2: CreateOfflineOpts = {
85
+ ...baseSettings,
86
+ online: false,
87
+ agents: [
88
+ new SupalosaBot(firstBotName, Countries.FRANCE, [firstBotName], false),
89
+ new SupalosaBot(secondBotName, Countries.RUSSIA, [firstBotName], true).setDebugMode(true),
90
+ new SupalosaBot(thirdBotName, Countries.RUSSIA, [fourthBotName], false),
91
+ new SupalosaBot(fourthBotName, Countries.FRANCE, [thirdBotName], false),
92
+ ],
93
+ };
94
+
95
+ const game = await cdapi.createGame(process.env.ONLINE_MATCH ? onlineSettings : offlineSettings1v1);
96
+ while (!game.isFinished()) {
97
+ if (!!MAX_GAME_LENGTH_SECONDS && game.getCurrentTick() / 15 > MAX_GAME_LENGTH_SECONDS) {
98
+ console.log(`Game forced to end due to timeout`);
99
+ break;
100
+ }
101
+ await game.update();
102
+ }
103
+
104
+ game.saveReplay();
105
+ game.dispose();
106
+ }
107
+
108
+ main().catch((e) => {
109
+ console.error(e);
110
+ process.exit(1);
111
+ });
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
- "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
+ {
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
+ }