@supalosa/chronodivide-bot 0.2.1 → 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 +3 -3
- package/dist/bot/bot.js +7 -3
- 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/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 +3 -2
- 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 +8 -7
- package/dist/bot/logic/mission/missions/attackMission.js.map +1 -0
- package/dist/bot/logic/mission/missions/defenceMission.js +11 -6
- 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 +19 -17
- package/dist/bot/logic/squad/behaviours/combatSquad.js.map +1 -0
- package/dist/bot/logic/squad/behaviours/common.js +20 -2
- 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 +1 -0
- 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 +58 -18
- 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 +7 -6
- package/dist/exampleBot.js.map +1 -0
- package/package.json +15 -7
- package/src/bot/bot.ts +10 -7
- package/src/bot/logic/awareness.ts +21 -4
- 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 +2 -3
- package/src/bot/logic/mission/missionFactories.ts +5 -0
- package/src/bot/logic/mission/missions/attackMission.ts +25 -20
- package/src/bot/logic/mission/missions/defenceMission.ts +34 -14
- 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 +21 -17
- package/src/bot/logic/squad/behaviours/common.ts +33 -2
- package/src/bot/logic/squad/behaviours/engineerSquad.ts +53 -0
- 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 +89 -44
- package/src/exampleBot.ts +6 -6
- package/tsconfig.json +73 -73
- package/src/bot/logic/building/ArtilleryUnit.ts +0 -43
- package/src/bot/logic/building/building.ts +0 -127
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,43 +0,0 @@
|
|
|
1
|
-
import { GameApi, PlayerData, TechnoRules } from "@chronodivide/game-api";
|
|
2
|
-
import { GlobalThreat } from "../threat/threat.js";
|
|
3
|
-
import { AiBuildingRules, getDefaultPlacementLocation, numBuildingsOwnedOfType } from "./building.js";
|
|
4
|
-
|
|
5
|
-
export class ArtilleryUnit implements AiBuildingRules {
|
|
6
|
-
constructor(private basePriority: number, private baseAmount: number) {}
|
|
7
|
-
|
|
8
|
-
getPlacementLocation(
|
|
9
|
-
game: GameApi,
|
|
10
|
-
playerData: PlayerData,
|
|
11
|
-
technoRules: TechnoRules
|
|
12
|
-
): { rx: number; ry: number } | undefined {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getPriority(
|
|
17
|
-
game: GameApi,
|
|
18
|
-
playerData: PlayerData,
|
|
19
|
-
technoRules: TechnoRules,
|
|
20
|
-
threatCache: GlobalThreat | null
|
|
21
|
-
): number {
|
|
22
|
-
// If the enemy's defensive power is increasing we will start to build these.
|
|
23
|
-
if (threatCache) {
|
|
24
|
-
if (threatCache.totalDefensivePower > threatCache.totalAvailableAntiGroundFirepower) {
|
|
25
|
-
return (
|
|
26
|
-
this.basePriority *
|
|
27
|
-
(threatCache.totalAvailableAntiGroundFirepower / Math.max(1, threatCache.totalDefensivePower))
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const numOwned = numBuildingsOwnedOfType(game, playerData, technoRules);
|
|
32
|
-
return this.basePriority * (1.0 - numOwned / this.baseAmount);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getMaxCount(
|
|
36
|
-
game: GameApi,
|
|
37
|
-
playerData: PlayerData,
|
|
38
|
-
technoRules: TechnoRules,
|
|
39
|
-
threatCache: GlobalThreat | null
|
|
40
|
-
): number | null {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { BuildingPlacementData, GameApi, PlayerData, Point2D, TechnoRules } from "@chronodivide/game-api";
|
|
2
|
-
import { GlobalThreat } from "../threat/threat.js";
|
|
3
|
-
import { AntiGroundStaticDefence } from "./antiGroundStaticDefence.js";
|
|
4
|
-
import { ArtilleryUnit } from "./ArtilleryUnit.js";
|
|
5
|
-
import { BasicAirUnit } from "./basicAirUnit.js";
|
|
6
|
-
import { BasicBuilding } from "./basicBuilding.js";
|
|
7
|
-
import { BasicGroundUnit } from "./basicGroundUnit.js";
|
|
8
|
-
import { PowerPlant } from "./powerPlant.js";
|
|
9
|
-
import { ResourceCollectionBuilding } from "./resourceCollectionBuilding.js";
|
|
10
|
-
import { Harvester } from "./harvester.js";
|
|
11
|
-
|
|
12
|
-
export interface AiBuildingRules {
|
|
13
|
-
getPriority(
|
|
14
|
-
game: GameApi,
|
|
15
|
-
playerData: PlayerData,
|
|
16
|
-
technoRules: TechnoRules,
|
|
17
|
-
threatCache: GlobalThreat | null,
|
|
18
|
-
): number;
|
|
19
|
-
|
|
20
|
-
getPlacementLocation(
|
|
21
|
-
game: GameApi,
|
|
22
|
-
playerData: PlayerData,
|
|
23
|
-
technoRules: TechnoRules,
|
|
24
|
-
): { rx: number; ry: number } | undefined;
|
|
25
|
-
|
|
26
|
-
getMaxCount(
|
|
27
|
-
game: GameApi,
|
|
28
|
-
playerData: PlayerData,
|
|
29
|
-
technoRules: TechnoRules,
|
|
30
|
-
threatCache: GlobalThreat | null,
|
|
31
|
-
): number | null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function numBuildingsOwnedOfType(game: GameApi, playerData: PlayerData, technoRules: TechnoRules): number {
|
|
35
|
-
return game.getVisibleUnits(playerData.name, "self", (r) => r == technoRules).length;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function numBuildingsOwnedOfName(game: GameApi, playerData: PlayerData, name: string): number {
|
|
39
|
-
return game.getVisibleUnits(playerData.name, "self", (r) => r.name === name).length;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function getDefaultPlacementLocation(
|
|
43
|
-
game: GameApi,
|
|
44
|
-
playerData: PlayerData,
|
|
45
|
-
startPoint: Point2D,
|
|
46
|
-
technoRules: TechnoRules,
|
|
47
|
-
space: number = 1,
|
|
48
|
-
): { rx: number; ry: number } | undefined {
|
|
49
|
-
// Random location, preferably near start location.
|
|
50
|
-
let startX = startPoint.x;
|
|
51
|
-
let startY = startPoint.y;
|
|
52
|
-
let size: BuildingPlacementData = game.getBuildingPlacementData(technoRules.name);
|
|
53
|
-
if (!size) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
let largestSize = Math.max(size.foundation.height, size.foundation.width);
|
|
57
|
-
for (let searchRadius = largestSize; searchRadius < 25 + largestSize; ++searchRadius) {
|
|
58
|
-
for (let xx = startX - searchRadius; xx < startX + searchRadius; ++xx) {
|
|
59
|
-
for (let yy = startY - searchRadius; yy < startY + searchRadius; ++yy) {
|
|
60
|
-
let tile = game.mapApi.getTile(xx, yy);
|
|
61
|
-
if (tile && game.canPlaceBuilding(playerData.name, technoRules.name, tile)) {
|
|
62
|
-
return { rx: xx, ry: yy };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Priority 0 = don't build.
|
|
71
|
-
export type TechnoRulesWithPriority = { unit: TechnoRules; priority: number };
|
|
72
|
-
|
|
73
|
-
export const DEFAULT_BUILDING_PRIORITY = 1;
|
|
74
|
-
|
|
75
|
-
export const BUILDING_NAME_TO_RULES = new Map<string, AiBuildingRules>([
|
|
76
|
-
// Allied
|
|
77
|
-
["GAPOWR", new PowerPlant()],
|
|
78
|
-
["GAREFN", new ResourceCollectionBuilding(10, 3)], // Refinery
|
|
79
|
-
["GAWEAP", new BasicBuilding(15, 1)], // War Factory
|
|
80
|
-
["GAPILE", new BasicBuilding(12, 1)], // Barracks
|
|
81
|
-
["CMIN", new Harvester(15, 4, 2)], // Chrono Miner
|
|
82
|
-
["ENGINEER", new BasicBuilding(1, 1, 10000)], // Engineer
|
|
83
|
-
["GADEPT", new BasicBuilding(1, 1, 10000)], // Repair Depot
|
|
84
|
-
["GAAIRC", new BasicBuilding(8, 1, 6000)], // Airforce Command
|
|
85
|
-
|
|
86
|
-
["GATECH", new BasicBuilding(20, 1, 4000)], // Allied Battle Lab
|
|
87
|
-
["GAYARD", new BasicBuilding(0, 0, 0)], // Naval Yard, disabled
|
|
88
|
-
|
|
89
|
-
["GAPILL", new AntiGroundStaticDefence(5, 1, 5)], // Pillbox
|
|
90
|
-
["ATESLA", new AntiGroundStaticDefence(5, 1, 10)], // Prism Cannon
|
|
91
|
-
["GAWALL", new AntiGroundStaticDefence(0, 0, 0)], // Walls
|
|
92
|
-
|
|
93
|
-
["E1", new BasicGroundUnit(2, 3, 0.25, 0)], // GI
|
|
94
|
-
["MTNK", new BasicGroundUnit(10, 3, 2, 0)], // Grizzly Tank
|
|
95
|
-
["MGTK", new BasicGroundUnit(10, 1, 2.5, 0)], // Mirage Tank
|
|
96
|
-
["FV", new BasicGroundUnit(5, 2, 0.5, 1)], // IFV
|
|
97
|
-
["JUMPJET", new BasicAirUnit(10, 1, 1, 1)], // Rocketeer
|
|
98
|
-
["ORCA", new BasicAirUnit(7, 1, 2, 0)], // Rocketeer
|
|
99
|
-
["SREF", new ArtilleryUnit(9, 1)], // Prism Tank
|
|
100
|
-
["CLEG", new BasicGroundUnit(0, 0)], // Chrono Legionnaire (Disabled - we don't handle the warped out phase properly and it tends to bug both bots out)
|
|
101
|
-
["SHAD", new BasicGroundUnit(0, 0)], // Nighthawk (Disabled)
|
|
102
|
-
|
|
103
|
-
// Soviet
|
|
104
|
-
["NAPOWR", new PowerPlant()],
|
|
105
|
-
["NAREFN", new ResourceCollectionBuilding(10, 3)], // Refinery
|
|
106
|
-
["NAWEAP", new BasicBuilding(15, 1)], // War Factory
|
|
107
|
-
["NAHAND", new BasicBuilding(12, 1)], // Barracks
|
|
108
|
-
["HARV", new Harvester(15, 4, 2)], // War Miner
|
|
109
|
-
["SENGINEER", new BasicBuilding(1, 1, 10000)], // Soviet Engineer
|
|
110
|
-
["NADEPT", new BasicBuilding(1, 1, 10000)], // Repair Depot
|
|
111
|
-
["NARADR", new BasicBuilding(8, 1, 4000)], // Radar
|
|
112
|
-
["NANRCT", new PowerPlant()], // Nuclear Reactor
|
|
113
|
-
["NAYARD", new BasicBuilding(0, 0, 0)], // Naval Yard, disabled
|
|
114
|
-
|
|
115
|
-
["NATECH", new BasicBuilding(20, 1, 4000)], // Soviet Battle Lab
|
|
116
|
-
|
|
117
|
-
["NALASR", new AntiGroundStaticDefence(5, 1, 5)], // Sentry Gun
|
|
118
|
-
["TESLA", new AntiGroundStaticDefence(5, 1, 10)], // Tesla Coil
|
|
119
|
-
["NAWALL", new AntiGroundStaticDefence(0, 0, 0)], // Walls
|
|
120
|
-
|
|
121
|
-
["E2", new BasicGroundUnit(2, 3, 0.25, 0)], // Conscript
|
|
122
|
-
["HTNK", new BasicGroundUnit(10, 3, 3, 0)], // Rhino Tank
|
|
123
|
-
["APOC", new BasicGroundUnit(6, 1, 5, 0)], // Apocalypse Tank
|
|
124
|
-
["HTK", new BasicGroundUnit(5, 2, 0.33, 1.5)], // Flak Track
|
|
125
|
-
["ZEP", new BasicAirUnit(5, 1, 5, 1)], // Kirov
|
|
126
|
-
["V3", new ArtilleryUnit(9, 1)], // V3 Rocket Launcher
|
|
127
|
-
]);
|