Compare commits
5 Commits
restructur
...
restructur
| Author | SHA1 | Date | |
|---|---|---|---|
|
952d274c53
|
|||
|
230153403f
|
|||
|
6ebf591d64
|
|||
|
2c93b65b3d
|
|||
|
6e8c8ae428
|
@@ -12,4 +12,7 @@ build({
|
|||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
minify: false,
|
minify: false,
|
||||||
keepNames: true, // optional: keeps function/class names
|
keepNames: true, // optional: keeps function/class names
|
||||||
|
banner: {
|
||||||
|
js: `// Vitor Hideyoshi <vitor.h.n.batista@gmail.com> - ${new Date().toISOString()}\n`
|
||||||
|
},
|
||||||
}).catch(() => process.exit(1));
|
}).catch(() => process.exit(1));
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ module.exports = defineConfig([{
|
|||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-namespace": "off",
|
"@typescript-eslint/no-namespace": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"argsIgnorePattern": "^_",
|
||||||
|
"varsIgnorePattern": "^_",
|
||||||
|
"caughtErrorsIgnorePattern": "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
@@ -50,4 +58,4 @@ module.exports = defineConfig([{
|
|||||||
},
|
},
|
||||||
|
|
||||||
files: ["**/.eslintrc.{js,cjs}"],
|
files: ["**/.eslintrc.{js,cjs}"],
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { CreepRequisition, CreepRole, CreepRoles, RoleDefinition } from "types/creeps";
|
import { CreepRequisition, CreepRole, CreepRoles, RoleDefinition } from "types/creeps";
|
||||||
import { DEFAULT_GAME_CONFIG } from "types/gameConfig";
|
import { DEFAULT_GAME_CONFIG } from "types/gameConfig";
|
||||||
import { createSourcePositionMatrix, forEachMatrixSpot, getPositionWithDelta, setSpotStatus, SourceSpotStatus } from "types/source";
|
import { checkPositionWalkable } from "utils/funcs/checkPosition";
|
||||||
import { checkPositionWalkable } from "utils/funcs/check_position";
|
import { get_role_cost as get_role_cost } from "utils/funcs/getRoleCost";
|
||||||
import { get_role_const as get_role_cost } from "utils/funcs/get_role_const";
|
import {
|
||||||
|
createSourcePositionMatrix,
|
||||||
|
forEachMatrixSpot,
|
||||||
|
getPositionWithDelta,
|
||||||
|
PositionSpotStatus,
|
||||||
|
setSpotStatus
|
||||||
|
} from "utils/positions";
|
||||||
|
|
||||||
class SpawnHandler {
|
class RoomRunner {
|
||||||
constructor(private spawn: StructureSpawn) {}
|
public static run(room: Room, state: GameState): GameState {
|
||||||
|
this.updateSpawnState(room, state);
|
||||||
|
|
||||||
public get spawnName(): string {
|
for (const name in this.getRoomCreeps(room)) {
|
||||||
return this.spawn.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public run(state: GameState): GameState {
|
|
||||||
this.updateSpawnState(state);
|
|
||||||
|
|
||||||
for(const name in Memory.creeps) {
|
|
||||||
if (!Game.creeps[name]) {
|
if (!Game.creeps[name]) {
|
||||||
console.log(`Creep ${name} is dead, cleaning up memory.`);
|
console.log(`Creep ${name} is dead, cleaning up memory.`);
|
||||||
|
|
||||||
@@ -35,90 +35,99 @@ class SpawnHandler {
|
|||||||
state = roleDefinition.handler.run(creep, state);
|
state = roleDefinition.handler.run(creep, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.validateSpawnState();
|
for (const spawn of room.find(FIND_MY_SPAWNS)) {
|
||||||
|
this.validateSpawnState(spawn, state);
|
||||||
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateSpawnState(state: GameState) {
|
private static getRoomCreeps(room: Room): Record<string, CreepMemory> {
|
||||||
const sources = this.spawn.room.find(FIND_SOURCES);
|
return Object.keys(Memory.creeps)
|
||||||
|
.filter(name => Memory.creeps[name].room === room.name)
|
||||||
|
.reduce((creeps: Record<string, CreepMemory>, creepName: string) => {
|
||||||
|
creeps[creepName] = Memory.creeps[creepName];
|
||||||
|
return creeps;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static updateSpawnState(room: Room, state: GameState) {
|
||||||
|
const sources = room.find(FIND_SOURCES);
|
||||||
if (!state.sourcesStates) {
|
if (!state.sourcesStates) {
|
||||||
state.sourcesStates = {};
|
state.sourcesStates = {};
|
||||||
state.maxHarvesters = 0
|
state.maxHarvesters = 0;
|
||||||
}
|
}
|
||||||
for (const source of sources) {
|
for (const source of sources) {
|
||||||
const sourceId = source.id.toString();
|
const sourceId = source.id.toString();
|
||||||
|
|
||||||
if (!state.sourcesStates[sourceId]) {
|
if (!state.sourcesStates[sourceId]) {
|
||||||
state.sourcesStates[sourceId] = {
|
state.sourcesStates[sourceId] = {
|
||||||
"id": sourceId,
|
id: sourceId,
|
||||||
"pos": source.pos,
|
pos: source.pos,
|
||||||
"spots": createSourcePositionMatrix(),
|
spots: createSourcePositionMatrix()
|
||||||
};
|
};
|
||||||
forEachMatrixSpot(state.sourcesStates[sourceId].spots, (delta, status) => {
|
forEachMatrixSpot(state.sourcesStates[sourceId].spots, (delta, status) => {
|
||||||
if (status !== SourceSpotStatus.UNKNOWN) {
|
if (status !== PositionSpotStatus.UNKNOWN) {
|
||||||
return; // Skip known spots
|
return; // Skip known spots
|
||||||
}
|
}
|
||||||
const pos = getPositionWithDelta(source.pos, delta);
|
const pos = getPositionWithDelta(source.pos, delta);
|
||||||
if (checkPositionWalkable(pos)) {
|
if (checkPositionWalkable(pos)) {
|
||||||
setSpotStatus(state.sourcesStates[sourceId].spots, delta, SourceSpotStatus.EMPTY);
|
setSpotStatus(state.sourcesStates[sourceId].spots, delta, PositionSpotStatus.EMPTY);
|
||||||
state.maxHarvesters = state.maxHarvesters + 1;
|
state.maxHarvesters = state.maxHarvesters + 1;
|
||||||
} else {
|
} else {
|
||||||
setSpotStatus(state.sourcesStates[sourceId].spots, delta, SourceSpotStatus.INVALID);
|
setSpotStatus(state.sourcesStates[sourceId].spots, delta, PositionSpotStatus.INVALID);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private validateSpawnState() {
|
private static validateSpawnState(spawn: StructureSpawn, state: GameState) {
|
||||||
if (this.spawn.spawning) {
|
if (spawn.spawning) {
|
||||||
// console.log(`Spawn ${this.spawn.name} is currently spawning a creep.`);
|
// console.log(`Spawn ${this.spawn.name} is currently spawning a creep.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const creepRequisition = this.checksNeedsCreeps();
|
const creepRequisition = this.checksNeedsCreeps(spawn.room);
|
||||||
if (Object.values(creepRequisition).every(count => count <= 0)) {
|
if (Object.values(creepRequisition).every(count => count <= 0)) {
|
||||||
// console.log(`Spawn ${this.spawn.name} has no creep needs.`);
|
// console.log(`Spawn ${this.spawn.name} has no creep needs.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalCreeps = Object.values(Game.creeps).length;
|
const totalCreeps = Object.values(Game.creeps).length;
|
||||||
if (totalCreeps >= DEFAULT_GAME_CONFIG.maxCreeps) {
|
if (totalCreeps >= state.maxHarvesters) {
|
||||||
// console.log(`Spawn ${this.spawn.name} cannot spawn more creeps, limit reached.`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rolesToSpawn = this.sortCreepRolesByPriority(creepRequisition);
|
const rolesToSpawn = this.sortCreepRolesByPriority(creepRequisition);
|
||||||
|
|
||||||
for (const role of rolesToSpawn) {
|
for (const role of rolesToSpawn) {
|
||||||
if (this.spawn.store[RESOURCE_ENERGY] < get_role_cost(role)) {
|
if (spawn.store[RESOURCE_ENERGY] < get_role_cost(role)) {
|
||||||
// console.log(`Spawn ${this.spawn.name} does not have enough energy to spawn a ${role.name}.`);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newName = `${role.name}_${Game.time}`;
|
const newName = `${role.name}_${Game.time}`;
|
||||||
const spawnResult = this.spawn.spawnCreep(role.body, newName, {
|
const spawnResult = spawn.spawnCreep(role.body, newName, {
|
||||||
memory: {
|
memory: {
|
||||||
role: role.name,
|
role: role.name,
|
||||||
room: this.spawn.room.name,
|
room: spawn.room.name,
|
||||||
spawnId: this.spawn.id,
|
spawnId: spawn.id,
|
||||||
working: false
|
working: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (spawnResult === OK) {
|
if (spawnResult === OK) {
|
||||||
console.log(`Spawn ${this.spawn.name} successfully spawned a new ${role.name}: ${newName}.`);
|
console.log(`Spawn ${spawn.name} successfully spawned a new ${role.name}: ${newName}.`);
|
||||||
return; // Exit after spawning one creep
|
return; // Exit after spawning one creep
|
||||||
} else {
|
} else {
|
||||||
console.error(`Spawn ${this.spawn.name} failed to spawn a new ${role.name}: ${spawnResult}`);
|
console.error(`Spawn ${spawn.name} failed to spawn a new ${role.name}: ${spawnResult}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private checksNeedsCreeps(): CreepRequisition {
|
private static checksNeedsCreeps(room: Room): CreepRequisition {
|
||||||
const creepCounts: Record<string, number> = {};
|
const creepCounts: Record<string, number> = {};
|
||||||
for (const creep of Object.values(Game.creeps)) {
|
for (const creepMemory of Object.values(this.getRoomCreeps(room))) {
|
||||||
const role = creep.memory.role;
|
const role = creepMemory.role;
|
||||||
creepCounts[role] = (creepCounts[role] || 0) + 1;
|
creepCounts[role] = (creepCounts[role] || 0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +152,7 @@ class SpawnHandler {
|
|||||||
return requisition;
|
return requisition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private sortCreepRolesByPriority(requisition: CreepRequisition): RoleDefinition[] {
|
private static sortCreepRolesByPriority(requisition: CreepRequisition): RoleDefinition[] {
|
||||||
return Object.keys(requisition)
|
return Object.keys(requisition)
|
||||||
.filter(role => requisition[role as CreepRole] > 0)
|
.filter(role => requisition[role as CreepRole] > 0)
|
||||||
.map(role => CreepRoles[role as CreepRole])
|
.map(role => CreepRoles[role as CreepRole])
|
||||||
@@ -151,4 +160,4 @@ class SpawnHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SpawnHandler;
|
export default RoomRunner;
|
||||||
22
src/main.ts
22
src/main.ts
@@ -1,6 +1,6 @@
|
|||||||
import { CreepDestination } from "types/creeps";
|
import { CreepDestination } from "types/creeps";
|
||||||
import { SourcePositionMatrix, SourceSpotStatus } from "./types/source";
|
import RoomRunner from "RoomRunner";
|
||||||
import SpawnHandler from "spawnHandler";
|
import { PositionMatrix } from "utils/positions";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
/*
|
/*
|
||||||
@@ -13,7 +13,7 @@ declare global {
|
|||||||
*/
|
*/
|
||||||
interface SourceState {
|
interface SourceState {
|
||||||
id: string;
|
id: string;
|
||||||
spots: SourcePositionMatrix;
|
spots: PositionMatrix;
|
||||||
pos: RoomPosition;
|
pos: RoomPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ declare global {
|
|||||||
interface Memory {
|
interface Memory {
|
||||||
uuid: number;
|
uuid: number;
|
||||||
log: any;
|
log: any;
|
||||||
spawnStates: { [name: string]: GameState };
|
roomStateRegistry: { [name: string]: GameState };
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CreepMemory {
|
interface CreepMemory {
|
||||||
@@ -46,15 +46,13 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const loop = () => {
|
export const loop = () => {
|
||||||
Memory.spawnStates = Memory.spawnStates || {};
|
Memory.roomStateRegistry = Memory.roomStateRegistry || {};
|
||||||
|
|
||||||
for (const spawnName of Object.keys(Game.spawns)) {
|
for (const roomName of Object.keys(Game.rooms)) {
|
||||||
const spawnState = Memory.spawnStates[spawnName] || {};
|
Memory.roomStateRegistry[roomName] = RoomRunner.run(
|
||||||
|
Game.rooms[roomName],
|
||||||
const spawnHandler = new SpawnHandler(Game.spawns[spawnName]);
|
Memory.roomStateRegistry[roomName] || {}
|
||||||
|
);
|
||||||
Memory.spawnStates[spawnName] = spawnHandler.run(spawnState);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
12
src/roleHandlers/BaseHandler.interface.ts
Normal file
12
src/roleHandlers/BaseHandler.interface.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export abstract class RoleHandler {
|
||||||
|
public static destroy(_creepMemory: CreepMemory, _state: GameState): void {
|
||||||
|
// Default implementation does nothing
|
||||||
|
// Subclasses should override this method
|
||||||
|
}
|
||||||
|
|
||||||
|
public static run(_creep: Creep, state: GameState): GameState {
|
||||||
|
// Default implementation returns state unchanged
|
||||||
|
// Subclasses should override this method
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export abstract class RoleHandler {
|
|
||||||
static destroy(creepMemory: CreepMemory, state: GameState): void {};
|
|
||||||
static run(creep: Creep, state: GameState): GameState {};
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
import { getSourceById, getSpawnById } from "utils/funcs/get_by_id";
|
import { getSourceById, getSpawnById } from "utils/funcs/getById";
|
||||||
import { RoleHandler } from "./base.handler.interface";
|
import { RoleHandler } from "./BaseHandler.interface";
|
||||||
import { getNextEmptySpot, getPositionWithDelta, setSpotStatus, SourceSpotStatus } from "types/source";
|
|
||||||
import { SourceDestination } from "types/creeps";
|
import { SourceDestination } from "types/creeps";
|
||||||
|
import { getNextEmptySpot, getPositionWithDelta, PositionSpotStatus, setSpotStatus } from "utils/positions";
|
||||||
|
|
||||||
|
|
||||||
class HarvesterHandler extends RoleHandler {
|
class HarvesterHandler extends RoleHandler {
|
||||||
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
||||||
@@ -40,7 +38,7 @@ class HarvesterHandler extends RoleHandler {
|
|||||||
setSpotStatus(
|
setSpotStatus(
|
||||||
state.sourcesStates[creep.memory.previousDestination.id].spots,
|
state.sourcesStates[creep.memory.previousDestination.id].spots,
|
||||||
creep.memory.previousDestination.sourceSpot,
|
creep.memory.previousDestination.sourceSpot,
|
||||||
SourceSpotStatus.EMPTY
|
PositionSpotStatus.EMPTY
|
||||||
);
|
);
|
||||||
delete creep.memory.previousDestination;
|
delete creep.memory.previousDestination;
|
||||||
}
|
}
|
||||||
@@ -80,23 +78,19 @@ class HarvesterHandler extends RoleHandler {
|
|||||||
continue; // No empty spots available, skip to next source
|
continue; // No empty spots available, skip to next source
|
||||||
}
|
}
|
||||||
|
|
||||||
setSpotStatus(
|
setSpotStatus(sourceState.spots, emptySpot, PositionSpotStatus.OCCUPIED);
|
||||||
sourceState.spots,
|
|
||||||
emptySpot,
|
|
||||||
SourceSpotStatus.OCCUPIED
|
|
||||||
);
|
|
||||||
creep.memory.destination = {
|
creep.memory.destination = {
|
||||||
id: source.id,
|
id: source.id,
|
||||||
type: "source",
|
type: "source",
|
||||||
sourceSpot: emptySpot
|
sourceSpot: emptySpot
|
||||||
};
|
};
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Creep ${creep.name} could not find a valid source.`);
|
console.log(`Creep ${creep.name} could not find a valid source.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static onSourceDestination(creep: Creep, state: GameState) {
|
private static onSourceDestination(creep: Creep, _state: GameState) {
|
||||||
if (!creep.memory.destination || creep.memory.destination.type !== "source") {
|
if (!creep.memory.destination || creep.memory.destination.type !== "source") {
|
||||||
console.log(`Creep ${creep.name} has no valid destination set.`);
|
console.log(`Creep ${creep.name} has no valid destination set.`);
|
||||||
delete creep.memory.destination;
|
delete creep.memory.destination;
|
||||||
@@ -110,19 +104,20 @@ class HarvesterHandler extends RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (creep.harvest(source) === ERR_NOT_IN_RANGE) {
|
if (creep.harvest(source) === ERR_NOT_IN_RANGE) {
|
||||||
const sourceSpotPosition = getPositionWithDelta(
|
const sourceSpotPosition = getPositionWithDelta(source.pos, creep.memory.destination.sourceSpot);
|
||||||
source.pos, creep.memory.destination.sourceSpot
|
creep.moveTo(sourceSpotPosition, {
|
||||||
)
|
reusePath: 10,
|
||||||
creep.moveTo(sourceSpotPosition, { reusePath: 10, visualizePathStyle: { stroke: '#ffffff', lineStyle: 'dashed', strokeWidth: 0.1 } });
|
visualizePathStyle: { stroke: "#ffffff", lineStyle: "dashed", strokeWidth: 0.1 }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static onSpawnDestination(creep: Creep, state: GameState) {
|
private static onSpawnDestination(creep: Creep, _state: GameState) {
|
||||||
if (creep.memory.destination === undefined) {
|
if (creep.memory.destination === undefined) {
|
||||||
creep.memory.destination = {
|
creep.memory.destination = {
|
||||||
id: creep.memory.spawnId,
|
id: creep.memory.spawnId,
|
||||||
type: "spawn"
|
type: "spawn"
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const spawn = getSpawnById(creep.memory.destination.id);
|
const spawn = getSpawnById(creep.memory.destination.id);
|
||||||
@@ -132,12 +127,13 @@ class HarvesterHandler extends RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (creep.transfer(spawn, RESOURCE_ENERGY) === ERR_NOT_IN_RANGE) {
|
if (creep.transfer(spawn, RESOURCE_ENERGY) === ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(spawn, { reusePath: 10, visualizePathStyle: { stroke: '#ffffff', lineStyle: 'dashed', strokeWidth: 0.1 } });
|
creep.moveTo(spawn, {
|
||||||
|
reusePath: 10,
|
||||||
|
visualizePathStyle: { stroke: "#ffffff", lineStyle: "dashed", strokeWidth: 0.1 }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static findClosestSource(creep: Creep, state: GameState): Source[] {
|
private static findClosestSource(creep: Creep, state: GameState): Source[] {
|
||||||
const sources = Object.keys(state.sourcesStates)
|
const sources = Object.keys(state.sourcesStates)
|
||||||
.map(sourceId => getSourceById(sourceId))
|
.map(sourceId => getSourceById(sourceId))
|
||||||
@@ -158,16 +154,8 @@ class HarvesterHandler extends RoleHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSpotStatus(
|
setSpotStatus(sourceState.spots, destination.sourceSpot, PositionSpotStatus.EMPTY);
|
||||||
sourceState.spots,
|
|
||||||
destination.sourceSpot,
|
|
||||||
SourceSpotStatus.EMPTY
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default HarvesterHandler;
|
export default HarvesterHandler;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { RoleHandler } from "./base.handler.interface";
|
import { RoleHandler } from "./BaseHandler.interface";
|
||||||
|
|
||||||
import HarvesterHandler from "./harvester.handler";
|
import HarvesterHandler from "./harvester.handler";
|
||||||
import UpgraderHandler from "./upgrader.handler";
|
import UpgraderHandler from "./upgrader.handler";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export { RoleHandler, HarvesterHandler, UpgraderHandler };
|
export { RoleHandler, HarvesterHandler, UpgraderHandler };
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { getControllerById, getSourceById } from "utils/funcs/get_by_id";
|
import { getControllerById, getSourceById } from "utils/funcs/getById";
|
||||||
import { RoleHandler } from "./base.handler.interface";
|
import { RoleHandler } from "./BaseHandler.interface";
|
||||||
import { getNextEmptySpot, getPositionWithDelta, setSpotStatus, SourceSpotStatus } from "types/source";
|
import { getNextEmptySpot, PositionSpotStatus, setSpotStatus, getPositionWithDelta } from "utils/positions";
|
||||||
|
import { SourceDestination } from "types/creeps";
|
||||||
|
|
||||||
|
|
||||||
class UpgraderHandler extends RoleHandler {
|
class UpgraderHandler extends RoleHandler {
|
||||||
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
public static destroy(creepMemory: CreepMemory, state: GameState): void {
|
||||||
@@ -39,7 +38,7 @@ class UpgraderHandler extends RoleHandler {
|
|||||||
setSpotStatus(
|
setSpotStatus(
|
||||||
state.sourcesStates[creep.memory.previousDestination.id].spots,
|
state.sourcesStates[creep.memory.previousDestination.id].spots,
|
||||||
creep.memory.previousDestination.sourceSpot,
|
creep.memory.previousDestination.sourceSpot,
|
||||||
SourceSpotStatus.EMPTY
|
PositionSpotStatus.EMPTY
|
||||||
);
|
);
|
||||||
delete creep.memory.previousDestination;
|
delete creep.memory.previousDestination;
|
||||||
}
|
}
|
||||||
@@ -86,23 +85,19 @@ class UpgraderHandler extends RoleHandler {
|
|||||||
continue; // No empty spots available, skip to next source
|
continue; // No empty spots available, skip to next source
|
||||||
}
|
}
|
||||||
|
|
||||||
setSpotStatus(
|
setSpotStatus(sourceState.spots, emptySpot, PositionSpotStatus.OCCUPIED);
|
||||||
sourceState.spots,
|
|
||||||
emptySpot,
|
|
||||||
SourceSpotStatus.OCCUPIED
|
|
||||||
);
|
|
||||||
creep.memory.destination = {
|
creep.memory.destination = {
|
||||||
id: source.id,
|
id: source.id,
|
||||||
type: "source",
|
type: "source",
|
||||||
sourceSpot: emptySpot
|
sourceSpot: emptySpot
|
||||||
};
|
};
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Creep ${creep.name} could not find a valid source.`);
|
console.log(`Creep ${creep.name} could not find a valid source.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static onSourceDestination(creep: Creep, state: GameState) {
|
private static onSourceDestination(creep: Creep, _state: GameState) {
|
||||||
if (!creep.memory.destination || creep.memory.destination.type !== "source") {
|
if (!creep.memory.destination || creep.memory.destination.type !== "source") {
|
||||||
console.log(`Creep ${creep.name} has no valid destination set.`);
|
console.log(`Creep ${creep.name} has no valid destination set.`);
|
||||||
delete creep.memory.destination;
|
delete creep.memory.destination;
|
||||||
@@ -116,14 +111,15 @@ class UpgraderHandler extends RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (creep.harvest(source) === ERR_NOT_IN_RANGE) {
|
if (creep.harvest(source) === ERR_NOT_IN_RANGE) {
|
||||||
const sourceSpotPosition = getPositionWithDelta(
|
const sourceSpotPosition = getPositionWithDelta(source.pos, creep.memory.destination.sourceSpot);
|
||||||
source.pos, creep.memory.destination.sourceSpot
|
creep.moveTo(sourceSpotPosition, {
|
||||||
)
|
reusePath: 10,
|
||||||
creep.moveTo(sourceSpotPosition, { reusePath: 10, visualizePathStyle: { stroke: '#ffffff', lineStyle: 'dashed', strokeWidth: 0.1 } });
|
visualizePathStyle: { stroke: "#ffffff", lineStyle: "dashed", strokeWidth: 0.1 }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static onControllerDestination(creep: Creep, state: GameState) {
|
private static onControllerDestination(creep: Creep, _state: GameState) {
|
||||||
if (creep.memory.destination === undefined) {
|
if (creep.memory.destination === undefined) {
|
||||||
if (!creep.room.controller) {
|
if (!creep.room.controller) {
|
||||||
console.log(`Creep ${creep.name} has no valid controller to upgrade.`);
|
console.log(`Creep ${creep.name} has no valid controller to upgrade.`);
|
||||||
@@ -133,7 +129,7 @@ class UpgraderHandler extends RoleHandler {
|
|||||||
creep.memory.destination = {
|
creep.memory.destination = {
|
||||||
id: creep.room.controller.id,
|
id: creep.room.controller.id,
|
||||||
type: "controller"
|
type: "controller"
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const controller = getControllerById(creep.memory.destination.id);
|
const controller = getControllerById(creep.memory.destination.id);
|
||||||
@@ -143,12 +139,13 @@ class UpgraderHandler extends RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (creep.upgradeController(controller) === ERR_NOT_IN_RANGE) {
|
if (creep.upgradeController(controller) === ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(controller, { reusePath: 10, visualizePathStyle: { stroke: '#ffffff', lineStyle: 'dashed', strokeWidth: 0.1 } });
|
creep.moveTo(controller, {
|
||||||
|
reusePath: 10,
|
||||||
|
visualizePathStyle: { stroke: "#ffffff", lineStyle: "dashed", strokeWidth: 0.1 }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static findClosestSource(creep: Creep, state: GameState): Source[] {
|
private static findClosestSource(creep: Creep, state: GameState): Source[] {
|
||||||
const sources = Object.keys(state.sourcesStates)
|
const sources = Object.keys(state.sourcesStates)
|
||||||
.map(sourceId => getSourceById(sourceId))
|
.map(sourceId => getSourceById(sourceId))
|
||||||
@@ -169,16 +166,8 @@ class UpgraderHandler extends RoleHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSpotStatus(
|
setSpotStatus(sourceState.spots, destination.sourceSpot, PositionSpotStatus.EMPTY);
|
||||||
sourceState.spots,
|
|
||||||
destination.sourceSpot,
|
|
||||||
SourceSpotStatus.EMPTY
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default UpgraderHandler;
|
export default UpgraderHandler;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { HarvesterHandler, RoleHandler, UpgraderHandler } from "roleHandlers";
|
import { HarvesterHandler, RoleHandler, UpgraderHandler } from "roleHandlers";
|
||||||
import { PositionDelta } from "./source";
|
import { PositionDelta } from "utils/positions";
|
||||||
|
|
||||||
export type RoleDefinition = {
|
export type RoleDefinition = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -33,35 +33,29 @@ export type CreepRole = keyof typeof CreepRoles;
|
|||||||
|
|
||||||
export type CreepRequisition = Record<CreepRole, number>;
|
export type CreepRequisition = Record<CreepRole, number>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type SpawnDestination = {
|
export type SpawnDestination = {
|
||||||
id: string; // ID of the spawn
|
id: string; // ID of the spawn
|
||||||
type: "spawn";
|
type: "spawn";
|
||||||
}
|
};
|
||||||
|
|
||||||
export type SourceDestination = {
|
export type SourceDestination = {
|
||||||
id: string; // ID of the source
|
id: string; // ID of the source
|
||||||
type: "source";
|
type: "source";
|
||||||
sourceSpot: PositionDelta; // Position delta for the source spot
|
sourceSpot: PositionDelta; // Position delta for the source spot
|
||||||
}
|
};
|
||||||
|
|
||||||
export type ControllerDestination = {
|
export type ControllerDestination = {
|
||||||
id: string; // ID of the controller
|
id: string; // ID of the controller
|
||||||
type: "controller";
|
type: "controller";
|
||||||
}
|
};
|
||||||
|
|
||||||
export type ConstructionSiteDestination = {
|
export type ConstructionSiteDestination = {
|
||||||
id: string; // ID of the construction site
|
id: string; // ID of the construction site
|
||||||
type: "constructionSite";
|
type: "constructionSite";
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export type CreepDestination = (
|
|
||||||
SpawnDestination |
|
|
||||||
SourceDestination |
|
|
||||||
ControllerDestination |
|
|
||||||
ConstructionSiteDestination
|
|
||||||
);
|
|
||||||
|
|
||||||
|
export type CreepDestination =
|
||||||
|
| SpawnDestination
|
||||||
|
| SourceDestination
|
||||||
|
| ControllerDestination
|
||||||
|
| ConstructionSiteDestination;
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import { CreepRequisition } from "./creeps";
|
|||||||
* Used to manage the overall game state and ensure proper role distribution.
|
* Used to manage the overall game state and ensure proper role distribution.
|
||||||
*/
|
*/
|
||||||
export type GameConfig = {
|
export type GameConfig = {
|
||||||
/** The maximum number of creeps allowed in the game. */
|
|
||||||
maxCreeps: number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum number of creeps required for each role.
|
* The minimum number of creeps required for each role.
|
||||||
* Creeps will be spawned to meet these minimums before allocating new roles.
|
* Creeps will be spawned to meet these minimums before allocating new roles.
|
||||||
@@ -22,7 +19,6 @@ export type GameConfig = {
|
|||||||
* @type {GameConfig}
|
* @type {GameConfig}
|
||||||
*/
|
*/
|
||||||
export const DEFAULT_GAME_CONFIG: GameConfig = {
|
export const DEFAULT_GAME_CONFIG: GameConfig = {
|
||||||
maxCreeps: 10,
|
|
||||||
minCreepsPerRole: {
|
minCreepsPerRole: {
|
||||||
harvester: 3,
|
harvester: 3,
|
||||||
upgrader: 7,
|
upgrader: 7,
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
export const SourceSpotStatus = {
|
|
||||||
INVALID: "-2",
|
|
||||||
CENTER: "-1",
|
|
||||||
UNKNOWN: "0",
|
|
||||||
EMPTY: "1",
|
|
||||||
OCCUPIED: "2",
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
|
|
||||||
export type SourceSpotStatus = (typeof SourceSpotStatus)[keyof typeof SourceSpotStatus];
|
|
||||||
|
|
||||||
|
|
||||||
export type PositionDeltaValue = -1 | 0 | 1;
|
|
||||||
|
|
||||||
export type PositionDelta = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
||||||
|
|
||||||
export type SourcePositionMatrix = {
|
|
||||||
locked: boolean;
|
|
||||||
data: [
|
|
||||||
SourceSpotStatus, SourceSpotStatus, SourceSpotStatus,
|
|
||||||
SourceSpotStatus, SourceSpotStatus, SourceSpotStatus,
|
|
||||||
SourceSpotStatus, SourceSpotStatus, SourceSpotStatus
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
type MatrixPoint = {
|
|
||||||
x: PositionDeltaValue;
|
|
||||||
y: PositionDeltaValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const indexToMatrixPoint = (index: number): MatrixPoint => {
|
|
||||||
// where the 0,0 point is the center of the matrix and -1, -1 is the top-left corner
|
|
||||||
const x = ((index % 3) - 1) as PositionDeltaValue; // Convert index to x coordinate (-1, 0, 1)
|
|
||||||
const y = (Math.floor(index / 3) - 1) as PositionDeltaValue; // Convert index to y coordinate (-1, 0, 1)
|
|
||||||
return { x, y };
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createSourcePositionMatrix = () : SourcePositionMatrix => {
|
|
||||||
return {
|
|
||||||
locked: false,
|
|
||||||
data: [
|
|
||||||
SourceSpotStatus.UNKNOWN, SourceSpotStatus.UNKNOWN, SourceSpotStatus.UNKNOWN,
|
|
||||||
SourceSpotStatus.UNKNOWN, SourceSpotStatus.CENTER, SourceSpotStatus.UNKNOWN,
|
|
||||||
SourceSpotStatus.UNKNOWN, SourceSpotStatus.UNKNOWN, SourceSpotStatus.UNKNOWN
|
|
||||||
]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const getNextEmptySpot = (matrix: SourcePositionMatrix): PositionDelta | null => {
|
|
||||||
const index = matrix.data.findIndex( status => status === SourceSpotStatus.EMPTY);
|
|
||||||
|
|
||||||
if (index === -1) {
|
|
||||||
return null; // No empty spot found
|
|
||||||
}
|
|
||||||
|
|
||||||
return index as PositionDelta; // Convert index to PositionDelta
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export const setSpotStatus = (matrix: SourcePositionMatrix, delta: PositionDelta, status: SourceSpotStatus): void => {
|
|
||||||
matrix.data[delta as number] = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const getPositionWithDelta = (pos: RoomPosition, delta: PositionDelta): RoomPosition => {
|
|
||||||
const matrixPoint = indexToMatrixPoint(delta as number);
|
|
||||||
return new RoomPosition(
|
|
||||||
pos.x + matrixPoint.x,
|
|
||||||
pos.y + matrixPoint.y,
|
|
||||||
pos.roomName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const forEachMatrixSpot = (matrix: SourcePositionMatrix, callback: (delta: PositionDelta, status: SourceSpotStatus) => void): void => {
|
|
||||||
for (const index in matrix.data) {
|
|
||||||
callback(index as PositionDelta, matrix.data[index]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export const checkPositionWalkable = (pos: RoomPosition) => {
|
export const checkPositionWalkable = (pos: RoomPosition) => {
|
||||||
// Check if the position is not obstructed by a wall
|
// Check if the position is not obstructed by a wall
|
||||||
const terrain = pos.lookFor(LOOK_TERRAIN);
|
const terrain = pos.lookFor(LOOK_TERRAIN);
|
||||||
return terrain.length === 0 || terrain[0] !== 'wall'
|
return terrain.length === 0 || terrain[0] !== "wall";
|
||||||
}
|
};
|
||||||
@@ -11,8 +11,7 @@ export const getSourceById = (sourceId: string): Source | null => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const getSpawnById = (spawnId: string): StructureSpawn | null => {
|
export const getSpawnById = (spawnId: string): StructureSpawn | null => {
|
||||||
if (!spawnId) {
|
if (!spawnId) {
|
||||||
@@ -27,8 +26,7 @@ export const getSpawnById = (spawnId: string): StructureSpawn | null => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return spawn;
|
return spawn;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const getControllerById = (controllerId: string): StructureController | null => {
|
export const getControllerById = (controllerId: string): StructureController | null => {
|
||||||
if (!controllerId) {
|
if (!controllerId) {
|
||||||
@@ -43,4 +41,4 @@ export const getControllerById = (controllerId: string): StructureController | n
|
|||||||
}
|
}
|
||||||
|
|
||||||
return controller;
|
return controller;
|
||||||
}
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RoleDefinition } from "types/creeps";
|
import { RoleDefinition } from "types/creeps";
|
||||||
|
|
||||||
export const get_role_const = (role: RoleDefinition) => {
|
export const get_role_cost = (role: RoleDefinition) => {
|
||||||
return role.body.reduce((cost, part) => {
|
return role.body.reduce((cost, part) => {
|
||||||
cost += BODYPART_COST[part] || 0;
|
cost += BODYPART_COST[part] || 0;
|
||||||
return cost;
|
return cost;
|
||||||
21
src/utils/positions/index.ts
Normal file
21
src/utils/positions/index.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { PositionSpotStatus, PositionDeltaValue, PositionMatrix, PositionDelta } from "./position.types";
|
||||||
|
|
||||||
|
import {
|
||||||
|
createSourcePositionMatrix,
|
||||||
|
forEachMatrixSpot,
|
||||||
|
getNextEmptySpot,
|
||||||
|
setSpotStatus,
|
||||||
|
getPositionWithDelta
|
||||||
|
} from "./position.funcs";
|
||||||
|
|
||||||
|
export {
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionDeltaValue,
|
||||||
|
PositionMatrix,
|
||||||
|
PositionDelta,
|
||||||
|
createSourcePositionMatrix,
|
||||||
|
forEachMatrixSpot,
|
||||||
|
getNextEmptySpot,
|
||||||
|
setSpotStatus,
|
||||||
|
getPositionWithDelta
|
||||||
|
};
|
||||||
88
src/utils/positions/position.funcs.ts
Normal file
88
src/utils/positions/position.funcs.ts
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
import { PositionDelta, PositionDeltaValue, PositionMatrix, PositionSpotStatus } from "./position.types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a point in the matrix with x and y coordinates.
|
||||||
|
*/
|
||||||
|
type MatrixPoint = {
|
||||||
|
x: PositionDeltaValue;
|
||||||
|
y: PositionDeltaValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a matrix index to a matrix point.
|
||||||
|
*/
|
||||||
|
const indexToMatrixPoint = (index: number): MatrixPoint => {
|
||||||
|
// where the 0,0 point is the center of the matrix and -1, -1 is the top-left corner
|
||||||
|
const x = ((index % 3) - 1) as PositionDeltaValue; // Convert index to x coordinate (-1, 0, 1)
|
||||||
|
const y = (Math.floor(index / 3) - 1) as PositionDeltaValue; // Convert index to y coordinate (-1, 0, 1)
|
||||||
|
return { x, y };
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a source position matrix with a default value.
|
||||||
|
* The center of the matrix is always `PositionSpotStatus.CENTER`.
|
||||||
|
* The default value is used for all other spots.
|
||||||
|
*/
|
||||||
|
export const createSourcePositionMatrix = (default_value?: PositionSpotStatus): PositionMatrix => {
|
||||||
|
const center_value = PositionSpotStatus.CENTER;
|
||||||
|
|
||||||
|
default_value = default_value || PositionSpotStatus.UNKNOWN;
|
||||||
|
|
||||||
|
return [
|
||||||
|
default_value,
|
||||||
|
default_value,
|
||||||
|
default_value,
|
||||||
|
default_value,
|
||||||
|
center_value,
|
||||||
|
default_value,
|
||||||
|
default_value,
|
||||||
|
default_value,
|
||||||
|
default_value
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the next empty spot in the matrix.
|
||||||
|
*/
|
||||||
|
export const getNextEmptySpot = (matrix: PositionMatrix): PositionDelta | null => {
|
||||||
|
const index = matrix.findIndex(status => status === PositionSpotStatus.EMPTY);
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
return null; // No empty spot found
|
||||||
|
}
|
||||||
|
|
||||||
|
return index as PositionDelta; // Convert index to PositionDelta
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the status of a spot in the matrix.
|
||||||
|
* Throws an error if the delta is out of bounds.
|
||||||
|
*/
|
||||||
|
export const setSpotStatus = (matrix: PositionMatrix, delta: PositionDelta, status: PositionSpotStatus): void => {
|
||||||
|
if (delta < 0 || delta >= matrix.length) {
|
||||||
|
throw new Error(`Invalid delta: ${delta}. Must be between 0 and ${matrix.length - 1}.`);
|
||||||
|
}
|
||||||
|
matrix[delta] = status;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the position with a delta applied to the given RoomPosition.
|
||||||
|
*/
|
||||||
|
export const getPositionWithDelta = (pos: RoomPosition, delta: PositionDelta): RoomPosition => {
|
||||||
|
const matrixPoint = indexToMatrixPoint(delta as number);
|
||||||
|
return new RoomPosition(pos.x + matrixPoint.x, pos.y + matrixPoint.y, pos.roomName);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterates over each spot in the matrix and applies the callback function.
|
||||||
|
* The callback receives the delta (index) and the status of the spot.
|
||||||
|
*/
|
||||||
|
export const forEachMatrixSpot = (
|
||||||
|
matrix: PositionMatrix,
|
||||||
|
callback: (delta: PositionDelta, status: PositionSpotStatus) => void
|
||||||
|
): void => {
|
||||||
|
for (const index in matrix) {
|
||||||
|
const positionIndex = Number(index);
|
||||||
|
callback(positionIndex as PositionDelta, matrix[positionIndex]);
|
||||||
|
}
|
||||||
|
};
|
||||||
37
src/utils/positions/position.types.ts
Normal file
37
src/utils/positions/position.types.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Represents the status of a position spot
|
||||||
|
*/
|
||||||
|
export const PositionSpotStatus = {
|
||||||
|
INVALID: "-2",
|
||||||
|
CENTER: "-1",
|
||||||
|
UNKNOWN: "0",
|
||||||
|
EMPTY: "1",
|
||||||
|
OCCUPIED: "2"
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type PositionSpotStatus = (typeof PositionSpotStatus)[keyof typeof PositionSpotStatus];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents dislocation to be applied a axis to a position relative to a source or a point of interest.
|
||||||
|
*/
|
||||||
|
export type PositionDeltaValue = -1 | 0 | 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a matrix of positions around a source or a point of interest.
|
||||||
|
* The matrix is a 3x3 grid where the center is the point of interest.
|
||||||
|
* The center should always be `PositionSpotStatus.CENTER`.
|
||||||
|
*/
|
||||||
|
export type PositionMatrix = [
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus,
|
||||||
|
PositionSpotStatus
|
||||||
|
];
|
||||||
|
|
||||||
|
// Valid indices for the 3x3 matrix (0-8)
|
||||||
|
export type PositionDelta = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES6",
|
"target": "ES6",
|
||||||
"lib": ["ES2015", "DOM"],
|
"lib": ["ES2017", "DOM"],
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
|
|||||||
Reference in New Issue
Block a user