From fa851044592d9e079e03338e85c996d843340a0f Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 04:01:01 +0300 Subject: [PATCH 01/34] fix handleDrone, if there is no container, then miner should transfer it instead of staying idle --- src/overlords/mining/extractor.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 835b11054..f36c31bcd 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -105,6 +105,17 @@ export class ExtractorOverlord extends Overlord { } private handleDrone(drone: Zerg): void { + //fix: if there is no container, then transfer the minerals yourself! + if(!this.container && _.sum(drone.carry) >0 ){ + drone.say('return home'); + const dropoffPoints = _.compact([this.colony.storage]); + const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); + if (bestDropoffPoint){ + drone.task = Tasks.transfer(bestDropoffPoint); + return; + } + } + // Ensure you are in the assigned room if (drone.room == this.room && !drone.pos.isEdge) { if (_.sum(drone.carry) == 0) { From 17257542b690bb22234994667ace90a34c6c743d Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 04:26:23 +0300 Subject: [PATCH 02/34] fix handleDrone, if there is no container, then miner should transfer it instead of staying idle --- src/overlords/mining/extractor.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index f36c31bcd..bcd03e4b3 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -106,14 +106,13 @@ export class ExtractorOverlord extends Overlord { private handleDrone(drone: Zerg): void { //fix: if there is no container, then transfer the minerals yourself! - if(!this.container && _.sum(drone.carry) >0 ){ - drone.say('return home'); - const dropoffPoints = _.compact([this.colony.storage]); - const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); - if (bestDropoffPoint){ - drone.task = Tasks.transfer(bestDropoffPoint); - return; - } + if(!this.container && _.sum(drone.carry) > 0 ){ + const dropoffPoints: (StructureTerminal | StructureStorage)[] = _.compact([this.colony.storage!]); + const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); + if (bestDropoffPoint) { + drone.task = Tasks.transfer(bestDropoffPoint); + return; + } } // Ensure you are in the assigned room From 458220b83f40aca4b61b2bb6cd1a0d79ced3b087 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 13:55:29 +0300 Subject: [PATCH 03/34] check for max carry capacity --- src/overlords/mining/extractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index bcd03e4b3..f81ad15a1 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -106,7 +106,7 @@ export class ExtractorOverlord extends Overlord { private handleDrone(drone: Zerg): void { //fix: if there is no container, then transfer the minerals yourself! - if(!this.container && _.sum(drone.carry) > 0 ){ + if(!this.container && _.sum(drone.carry) == drone.carryCapacity ){ const dropoffPoints: (StructureTerminal | StructureStorage)[] = _.compact([this.colony.storage!]); const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); if (bestDropoffPoint) { From 0419b12eae99d051b738ecf52716571f3a01d77f Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 14:52:35 +0300 Subject: [PATCH 04/34] pushed container constuction site to workers --- src/directives/colony/outpostSK.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 8aab6af4d..739299068 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -21,8 +21,21 @@ export class DirectiveSKOutpost extends Directive { this.overlords.sourceReaper = new SourceReaperOverlord(this); } - init(): void { + getTarget(): Structure | undefined { + if (!this.pos.isVisible) { + return; + } + const structure = _.find(this.pos.lookFor(LOOK_STRUCTURES), s => + s.structureType == STRUCTURE_CONTAINER) as StructureContainer; + return structure; + } + init(): void { + // Add this structure to worker overlord's build list + const target = this.getTarget(); + if (target && !this.colony.overlords.work.constructionSites.includes(target)) { + this.colony.overlords.work.constructionSites.push(target); + } } run(): void { From d98ceda4b3df735c485e64bc5f8ceb5ea2bda13a Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 15:16:26 +0300 Subject: [PATCH 05/34] pushed container constuction site to workers --- src/directives/colony/outpostSK.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 739299068..ad91d1ca1 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -21,13 +21,13 @@ export class DirectiveSKOutpost extends Directive { this.overlords.sourceReaper = new SourceReaperOverlord(this); } - getTarget(): Structure | undefined { + getTarget(): ConstructionSite | undefined { if (!this.pos.isVisible) { return; } - const structure = _.find(this.pos.lookFor(LOOK_STRUCTURES), s => - s.structureType == STRUCTURE_CONTAINER) as StructureContainer; - return structure; + const ConstructionSite = _.find(this.pos.lookFor(LOOK_CONSTRUCTION_SITES), s => + s.structureType == STRUCTURE_CONTAINER) as ConstructionSite; + return ConstructionSite; } init(): void { From 50641073182e0696d92262af6e9c2e95f2178d40 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 15:37:41 +0300 Subject: [PATCH 06/34] drone transferAll instead of transfer, target changed from storage to terminal --- src/overlords/mining/extractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index f81ad15a1..b8faeab03 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -110,7 +110,7 @@ export class ExtractorOverlord extends Overlord { const dropoffPoints: (StructureTerminal | StructureStorage)[] = _.compact([this.colony.storage!]); const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); if (bestDropoffPoint) { - drone.task = Tasks.transfer(bestDropoffPoint); + drone.task = Tasks.transferAll(bestDropoffPoint); return; } } From 22353528da4e898b28c46c1b7d0a7bc6f3ba693d Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 15:39:20 +0300 Subject: [PATCH 07/34] drone transferAll instead of transfer, target changed from storage to terminal --- src/overlords/mining/extractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index b8faeab03..d44b3779b 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -107,7 +107,7 @@ export class ExtractorOverlord extends Overlord { private handleDrone(drone: Zerg): void { //fix: if there is no container, then transfer the minerals yourself! if(!this.container && _.sum(drone.carry) == drone.carryCapacity ){ - const dropoffPoints: (StructureTerminal | StructureStorage)[] = _.compact([this.colony.storage!]); + const dropoffPoints: (StructureTerminal | StructureStorage)[] = _.compact([this.colony.terminal!]); const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); if (bestDropoffPoint) { drone.task = Tasks.transferAll(bestDropoffPoint); From 92fcb30195e252364f334cc4094868ed54539f10 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 16:30:50 +0300 Subject: [PATCH 08/34] drone transferAll instead of transfer, target changed from storage to terminal --- src/directives/colony/outpostSK.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index ad91d1ca1..7acc020c1 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -25,9 +25,13 @@ export class DirectiveSKOutpost extends Directive { if (!this.pos.isVisible) { return; } - const ConstructionSite = _.find(this.pos.lookFor(LOOK_CONSTRUCTION_SITES), s => - s.structureType == STRUCTURE_CONTAINER) as ConstructionSite; - return ConstructionSite; + const constructionSites = this.room.find(FIND_CONSTRUCTION_SITES); + const containersInConstructionSites = _.filter(constructionSites, s => s.structureType == STRUCTURE_CONTAINER); + + if(containersInConstructionSites.length > 0){ + return containersInConstructionSites[0]; + } + return; } init(): void { From 0d8ab062b61763426745193803373ad3253e970e Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 18 May 2019 16:37:59 +0300 Subject: [PATCH 09/34] Game.rooms[this.pos.roomName]; --- src/directives/colony/outpostSK.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 7acc020c1..886216fb8 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -25,7 +25,8 @@ export class DirectiveSKOutpost extends Directive { if (!this.pos.isVisible) { return; } - const constructionSites = this.room.find(FIND_CONSTRUCTION_SITES); + const room = Game.rooms[this.pos.roomName] + const constructionSites = room.find(FIND_CONSTRUCTION_SITES); const containersInConstructionSites = _.filter(constructionSites, s => s.structureType == STRUCTURE_CONTAINER); if(containersInConstructionSites.length > 0){ From 5c1ee27c145861343f3234a27f951b4b5f11d586 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sun, 19 May 2019 19:50:23 +0300 Subject: [PATCH 10/34] added containers to worker repair list in SK room --- src/Colony.ts | 1 + src/console/Console.ts | 11 ++++++++ src/directives/colony/outpostSK.ts | 30 ++++++++++++++++++---- src/overlords/mining/sourceKeeperReeper.ts | 1 + 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/Colony.ts b/src/Colony.ts index c23be5588..359ffbc51 100644 --- a/src/Colony.ts +++ b/src/Colony.ts @@ -311,6 +311,7 @@ export class Colony { $.set(this, 'sources', () => _.sortBy(_.flatten(_.map(this.rooms, room => room.sources)), source => source.pos.getMultiRoomRangeTo(this.pos))); for (const source of this.sources) { + //filter out sources kamal DirectiveHarvest.createIfNotPresent(source.pos, 'pos'); } $.set(this, 'extractors', () => diff --git a/src/console/Console.ts b/src/console/Console.ts index 69816c0ba..a309e128a 100644 --- a/src/console/Console.ts +++ b/src/console/Console.ts @@ -44,6 +44,7 @@ export class OvermindConsole { global.endRemoteDebugSession = this.endRemoteDebugSession; global.profileMemory = this.profileMemory; global.cancelMarketOrders = this.cancelMarketOrders; + global.SKoutpostFilter = this.SKoutpostFilter; } // Help, information, and operational changes ====================================================================== @@ -84,6 +85,7 @@ export class OvermindConsole { descr['profileMemory(depth=1)'] = 'scan through memory to get the size of various objects'; descr['startRemoteDebugSession()'] = 'enables the remote debugger so Muon can debug your code'; descr['cancelMarketOrders(filter?)'] = 'cancels all market orders matching filter (if provided)'; + descr['SKoutpostFilter(source.id|lair.id,add=true)'] = 'customise SKoutpost by filtering our source/lair id'; // Console list const descrMsg = toColumns(descr, {justify: true, padChar: '.'}); const maxLineLength = _.max(_.map(descrMsg, line => line.length)) + 2; @@ -486,4 +488,13 @@ export class OvermindConsole { return `Canceled ${_.values(ordersToCancel).length} orders.`; } + static SKoutpostFilter(id: string, add = true): string { + Memory.SKoutpostFilter + if(add){ + return `id ${id} added to SKoutpost exclusion list`; + } else { + return `id ${id} removed from SKoutpost exclusion list`; + } + } + } diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 886216fb8..7bcd06553 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -21,7 +21,7 @@ export class DirectiveSKOutpost extends Directive { this.overlords.sourceReaper = new SourceReaperOverlord(this); } - getTarget(): ConstructionSite | undefined { + getConstructionSites(): ConstructionSite | undefined { if (!this.pos.isVisible) { return; } @@ -35,16 +35,36 @@ export class DirectiveSKOutpost extends Directive { return; } + getContainersToRepair(): Structure | undefined { + if (!this.pos.isVisible) { + return; + } + const room = Game.rooms[this.pos.roomName] + const allStrcutures = room.find(FIND_STRUCTURES); + const containersTorepair = _.filter(allStrcutures, s => s.structureType == STRUCTURE_CONTAINER && s.hits < 0.5 * s.hitsMax); + + if(containersTorepair.length > 0){ + return containersTorepair[0]; + } + return; + } + init(): void { - // Add this structure to worker overlord's build list - const target = this.getTarget(); + // Add this structure/CS to worker overlord's build/repair list + const container = this.getContainersToRepair(); + if (container && !this.colony.overlords.work.repairStructures.includes(container)) { + this.colony.overlords.work.repairStructures.push(container); + return; + } + + const target = this.getConstructionSites(); if (target && !this.colony.overlords.work.constructionSites.includes(target)) { this.colony.overlords.work.constructionSites.push(target); + return; } } run(): void { } -} - +} \ No newline at end of file diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index 9d05cface..00937b547 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -65,6 +65,7 @@ export class SourceReaperOverlord extends CombatOverlord { private getNextTargetLair(): StructureKeeperLair | undefined { if (!this.room) return; // If any lairs have an active keeper, target that + //filter Lairs to skip //kamal const activeLair = _.find(this.room.keeperLairs, lair => lair.pos.findInRange(lair.room.sourceKeepers, 5).length > 0); if (activeLair) return activeLair; From ae83f312fd75caa4b2aff3f57e30a153ea2c9716 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Wed, 22 May 2019 02:59:09 +0300 Subject: [PATCH 11/34] only spawn miner in own room when there is a terminal/strorage --- src/directives/resource/extract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/directives/resource/extract.ts b/src/directives/resource/extract.ts index 7a75ba02a..ebab2c6e8 100644 --- a/src/directives/resource/extract.ts +++ b/src/directives/resource/extract.ts @@ -27,7 +27,7 @@ export class DirectiveExtract extends Directive { spawnMoarOverlords() { let priority: number; - if (this.room && this.room.my) { + if (this.room && this.room.my && (!!this.colony.terminal || !!this.colony.storage)) { if (this.colony.level == 8) { priority = OverlordPriority.ownedRoom.mineralRCL8; } else { From 863fd3fc190cbc97c28c4c343a5940971c7106a1 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Fri, 7 Jun 2019 07:57:53 +0300 Subject: [PATCH 12/34] SKroom directive cleanup --- src/Colony.ts | 2 +- src/console/Console.ts | 11 --------- src/directives/colony/outpostSK.ts | 28 ++++++++++------------ src/directives/resource/extract.ts | 9 ++++--- src/overlords/mining/sourceKeeperReeper.ts | 2 +- 5 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/Colony.ts b/src/Colony.ts index 359ffbc51..715e1a38f 100644 --- a/src/Colony.ts +++ b/src/Colony.ts @@ -311,7 +311,7 @@ export class Colony { $.set(this, 'sources', () => _.sortBy(_.flatten(_.map(this.rooms, room => room.sources)), source => source.pos.getMultiRoomRangeTo(this.pos))); for (const source of this.sources) { - //filter out sources kamal + //TODO: add a filter to enable selective/partial harvesting DirectiveHarvest.createIfNotPresent(source.pos, 'pos'); } $.set(this, 'extractors', () => diff --git a/src/console/Console.ts b/src/console/Console.ts index a309e128a..69816c0ba 100644 --- a/src/console/Console.ts +++ b/src/console/Console.ts @@ -44,7 +44,6 @@ export class OvermindConsole { global.endRemoteDebugSession = this.endRemoteDebugSession; global.profileMemory = this.profileMemory; global.cancelMarketOrders = this.cancelMarketOrders; - global.SKoutpostFilter = this.SKoutpostFilter; } // Help, information, and operational changes ====================================================================== @@ -85,7 +84,6 @@ export class OvermindConsole { descr['profileMemory(depth=1)'] = 'scan through memory to get the size of various objects'; descr['startRemoteDebugSession()'] = 'enables the remote debugger so Muon can debug your code'; descr['cancelMarketOrders(filter?)'] = 'cancels all market orders matching filter (if provided)'; - descr['SKoutpostFilter(source.id|lair.id,add=true)'] = 'customise SKoutpost by filtering our source/lair id'; // Console list const descrMsg = toColumns(descr, {justify: true, padChar: '.'}); const maxLineLength = _.max(_.map(descrMsg, line => line.length)) + 2; @@ -488,13 +486,4 @@ export class OvermindConsole { return `Canceled ${_.values(ordersToCancel).length} orders.`; } - static SKoutpostFilter(id: string, add = true): string { - Memory.SKoutpostFilter - if(add){ - return `id ${id} added to SKoutpost exclusion list`; - } else { - return `id ${id} removed from SKoutpost exclusion list`; - } - } - } diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 7bcd06553..79da56351 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -12,25 +12,25 @@ export class DirectiveSKOutpost extends Directive { static directiveName = 'outpostSK'; static color = COLOR_PURPLE; static secondaryColor = COLOR_YELLOW; + static containerRepairTheshold = 0.5; constructor(flag: Flag) { super(flag, colony => colony.level >= 7); } spawnMoarOverlords() { + //TODO: skip sourceReapoers for safe SKrooms this.overlords.sourceReaper = new SourceReaperOverlord(this); } - getConstructionSites(): ConstructionSite | undefined { + getContainerConstructionSites(): ConstructionSite | undefined { if (!this.pos.isVisible) { return; } - const room = Game.rooms[this.pos.roomName] - const constructionSites = room.find(FIND_CONSTRUCTION_SITES); - const containersInConstructionSites = _.filter(constructionSites, s => s.structureType == STRUCTURE_CONTAINER); + const ContainerConstructionSites = _.filter(this.room!.constructionSites, s => s.structureType == STRUCTURE_CONTAINER); - if(containersInConstructionSites.length > 0){ - return containersInConstructionSites[0]; + if(ContainerConstructionSites.length > 0){ + return ContainerConstructionSites[0]; } return; } @@ -39,9 +39,7 @@ export class DirectiveSKOutpost extends Directive { if (!this.pos.isVisible) { return; } - const room = Game.rooms[this.pos.roomName] - const allStrcutures = room.find(FIND_STRUCTURES); - const containersTorepair = _.filter(allStrcutures, s => s.structureType == STRUCTURE_CONTAINER && s.hits < 0.5 * s.hitsMax); + const containersTorepair = _.filter(this.room!.structures, s => s.structureType == STRUCTURE_CONTAINER && s.hits < DirectiveSKOutpost.containerRepairTheshold * s.hitsMax); if(containersTorepair.length > 0){ return containersTorepair[0]; @@ -51,15 +49,15 @@ export class DirectiveSKOutpost extends Directive { init(): void { // Add this structure/CS to worker overlord's build/repair list - const container = this.getContainersToRepair(); - if (container && !this.colony.overlords.work.repairStructures.includes(container)) { - this.colony.overlords.work.repairStructures.push(container); + const containerNeedRepair = this.getContainersToRepair(); + if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { + this.colony.overlords.work.repairStructures.push(containerNeedRepair); return; } - const target = this.getConstructionSites(); - if (target && !this.colony.overlords.work.constructionSites.includes(target)) { - this.colony.overlords.work.constructionSites.push(target); + const containerToBuild = this.getContainerConstructionSites(); + if (containerToBuild && !this.colony.overlords.work.constructionSites.includes(containerToBuild)) { + this.colony.overlords.work.constructionSites.push(containerToBuild); return; } } diff --git a/src/directives/resource/extract.ts b/src/directives/resource/extract.ts index ebab2c6e8..7efb330f8 100644 --- a/src/directives/resource/extract.ts +++ b/src/directives/resource/extract.ts @@ -26,8 +26,8 @@ export class DirectiveExtract extends Directive { } spawnMoarOverlords() { - let priority: number; - if (this.room && this.room.my && (!!this.colony.terminal || !!this.colony.storage)) { + let priority: number; + if (this.room && this.room.my) { if (this.colony.level == 8) { priority = OverlordPriority.ownedRoom.mineralRCL8; } else { @@ -36,7 +36,10 @@ export class DirectiveExtract extends Directive { } else { priority = OverlordPriority.remoteSKRoom.mineral; } - this.overlords.extract = new ExtractorOverlord(this, priority); + //Fix: Only spawn drones if there is a terminal or storage + if (!!this.colony.terminal || !!this.colony.storage){ + this.overlords.extract = new ExtractorOverlord(this, priority); + } } init() { diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index 00937b547..6f46c2462 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -65,7 +65,7 @@ export class SourceReaperOverlord extends CombatOverlord { private getNextTargetLair(): StructureKeeperLair | undefined { if (!this.room) return; // If any lairs have an active keeper, target that - //filter Lairs to skip //kamal + // TODO: Filter out Lair for sources/minerala that you do not want to harvest const activeLair = _.find(this.room.keeperLairs, lair => lair.pos.findInRange(lair.room.sourceKeepers, 5).length > 0); if (activeLair) return activeLair; From 2371f0e5b3cb6a9dd96f0dcae6f81270561a0bef Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Fri, 7 Jun 2019 08:45:09 +0300 Subject: [PATCH 13/34] safe SK room = no reaper --- src/directives/colony/outpostSK.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 79da56351..37a67ecfd 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -1,6 +1,7 @@ import {SourceReaperOverlord} from '../../overlords/mining/sourceKeeperReeper'; import {profile} from '../../profiler/decorator'; import {Directive} from '../Directive'; +import {Cartographer, ROOMTYPE_SOURCEKEEPER} from '../../utilities/Cartographer'; /** @@ -14,13 +15,25 @@ export class DirectiveSKOutpost extends Directive { static secondaryColor = COLOR_YELLOW; static containerRepairTheshold = 0.5; + SafeSKroom : boolean|undefined; + constructor(flag: Flag) { super(flag, colony => colony.level >= 7); } + + isSafeSKroom(): boolean { + const coords = Cartographer.getRoomCoordinates(this.pos.roomName); + if(coords.x % 10 != 0 && coords.x % 5 == 0 && coords.y % 10 != 0 && coords.y % 5== 0){ + return true; + } + return false; + } spawnMoarOverlords() { - //TODO: skip sourceReapoers for safe SKrooms - this.overlords.sourceReaper = new SourceReaperOverlord(this); + //skip sourceReapoers for safe SKrooms + if(!this.isSafeSKroom){ + this.overlords.sourceReaper = new SourceReaperOverlord(this); + } } getContainerConstructionSites(): ConstructionSite | undefined { @@ -48,6 +61,10 @@ export class DirectiveSKOutpost extends Directive { } init(): void { + if(this.SafeSKroom == undefined){ + this.SafeSKroom = this.isSafeSKroom(); + } + // Add this structure/CS to worker overlord's build/repair list const containerNeedRepair = this.getContainersToRepair(); if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { From e72592d1e6251c0ebef833c92f86a9cc6a9c4c05 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 8 Jun 2019 03:03:19 +0300 Subject: [PATCH 14/34] centerRoom in memory now --- src/directives/colony/outpostSK.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 37a67ecfd..ba5653741 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -3,7 +3,9 @@ import {profile} from '../../profiler/decorator'; import {Directive} from '../Directive'; import {Cartographer, ROOMTYPE_SOURCEKEEPER} from '../../utilities/Cartographer'; - +interface DirectiveSKOutpostMemory extends FlagMemory { + isCenterRoom?: boolean; +} /** * Remote mining directive for source keeper rooms */ @@ -15,13 +17,13 @@ export class DirectiveSKOutpost extends Directive { static secondaryColor = COLOR_YELLOW; static containerRepairTheshold = 0.5; - SafeSKroom : boolean|undefined; + memory: DirectiveSKOutpostMemory; constructor(flag: Flag) { super(flag, colony => colony.level >= 7); } - isSafeSKroom(): boolean { + isCenterRoom(): boolean { const coords = Cartographer.getRoomCoordinates(this.pos.roomName); if(coords.x % 10 != 0 && coords.x % 5 == 0 && coords.y % 10 != 0 && coords.y % 5== 0){ return true; @@ -30,8 +32,11 @@ export class DirectiveSKOutpost extends Directive { } spawnMoarOverlords() { + if(this.memory.isCenterRoom == undefined){ + this.memory.isCenterRoom = this.isCenterRoom(); + } //skip sourceReapoers for safe SKrooms - if(!this.isSafeSKroom){ + if(!this.memory.isCenterRoom){ this.overlords.sourceReaper = new SourceReaperOverlord(this); } } @@ -61,10 +66,6 @@ export class DirectiveSKOutpost extends Directive { } init(): void { - if(this.SafeSKroom == undefined){ - this.SafeSKroom = this.isSafeSKroom(); - } - // Add this structure/CS to worker overlord's build/repair list const containerNeedRepair = this.getContainersToRepair(); if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { From 709231c0b78bd4e13ef2c70ff22e7835e1880d1c Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 8 Jun 2019 07:40:07 +0300 Subject: [PATCH 15/34] reaper invaders in range of 10 > 2) --- src/overlords/mining/sourceKeeperReeper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index 6f46c2462..7e392dc91 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -96,7 +96,7 @@ export class SourceReaperOverlord extends CombatOverlord { reaper.healSelfIfPossible(); } // Kite around ranged invaders until a defender arrives - if (this.room.invaders.length > 2 && _.filter(this.defenders, def => def.room == this.room).length == 0) { + if (this.pos.findInRange(this.room.invaders,10).length > 2 && _.filter(this.defenders, def => def.room == this.room).length == 0) { reaper.kite(_.filter(this.room.hostiles, hostile => hostile.getActiveBodyparts(RANGED_ATTACK) > 0)); reaper.healSelfIfPossible(); } From b28e28e839ff7781d4dadaebb172d303268404e3 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sun, 9 Jun 2019 15:24:28 +0300 Subject: [PATCH 16/34] CPU optimization --- src/Colony.ts | 1 - src/directives/colony/outpostSK.ts | 20 +++++++++++--------- src/overlords/mining/sourceKeeperReeper.ts | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Colony.ts b/src/Colony.ts index 715e1a38f..c23be5588 100644 --- a/src/Colony.ts +++ b/src/Colony.ts @@ -311,7 +311,6 @@ export class Colony { $.set(this, 'sources', () => _.sortBy(_.flatten(_.map(this.rooms, room => room.sources)), source => source.pos.getMultiRoomRangeTo(this.pos))); for (const source of this.sources) { - //TODO: add a filter to enable selective/partial harvesting DirectiveHarvest.createIfNotPresent(source.pos, 'pos'); } $.set(this, 'extractors', () => diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index ba5653741..3cfad938e 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -67,16 +67,18 @@ export class DirectiveSKOutpost extends Directive { init(): void { // Add this structure/CS to worker overlord's build/repair list - const containerNeedRepair = this.getContainersToRepair(); - if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { - this.colony.overlords.work.repairStructures.push(containerNeedRepair); - return; - } + if(Game.time % 150 == 0){ + const containerNeedRepair = this.getContainersToRepair(); + if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { + this.colony.overlords.work.repairStructures.push(containerNeedRepair); + return; + } - const containerToBuild = this.getContainerConstructionSites(); - if (containerToBuild && !this.colony.overlords.work.constructionSites.includes(containerToBuild)) { - this.colony.overlords.work.constructionSites.push(containerToBuild); - return; + const containerToBuild = this.getContainerConstructionSites(); + if (containerToBuild && !this.colony.overlords.work.constructionSites.includes(containerToBuild)) { + this.colony.overlords.work.constructionSites.push(containerToBuild); + return; + } } } diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index 7e392dc91..45ae7a8ec 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -65,7 +65,6 @@ export class SourceReaperOverlord extends CombatOverlord { private getNextTargetLair(): StructureKeeperLair | undefined { if (!this.room) return; // If any lairs have an active keeper, target that - // TODO: Filter out Lair for sources/minerala that you do not want to harvest const activeLair = _.find(this.room.keeperLairs, lair => lair.pos.findInRange(lair.room.sourceKeepers, 5).length > 0); if (activeLair) return activeLair; From 7cd05ee11ec9ad1a2832945318a3cd1a17a32f3f Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Fri, 14 Jun 2019 00:38:58 +0300 Subject: [PATCH 17/34] package.json! --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 466554789..34dacef7a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "rollup-plugin-node-resolve": "3.3.0", "rollup-plugin-progress": "^0.4.0", "rollup-plugin-screeps": "0.1.2", - "rollup-plugin-typescript2": "0.16.1", + "rollup-plugin-typescript2": "^0.21.1", "tslint": "^5.16.0", "typedoc": "^0.14.2", "typescript": "2.9.2" @@ -39,6 +39,7 @@ "dependencies": { "@tensorflow/tfjs": "^1.1.2", "columnify": "1.5.4", + "lint": "^0.7.0", "onnxjs": "^0.1.6", "source-map": "0.7.3" } From ba13e306dc16992d4a8c7f09ba2a5213e08f273f Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 15 Jun 2019 00:54:34 +0300 Subject: [PATCH 18/34] lint comment fix --- src/directives/colony/outpostSK.ts | 39 ++++++++-------------- src/directives/resource/extract.ts | 4 +-- src/overlords/mining/extractor.ts | 13 ++------ src/overlords/mining/sourceKeeperReeper.ts | 2 +- 4 files changed, 19 insertions(+), 39 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 3cfad938e..ae8e03437 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -1,11 +1,9 @@ import {SourceReaperOverlord} from '../../overlords/mining/sourceKeeperReeper'; import {profile} from '../../profiler/decorator'; +import {Cartographer, ROOMTYPE_CORE} from '../../utilities/Cartographer'; import {Directive} from '../Directive'; -import {Cartographer, ROOMTYPE_SOURCEKEEPER} from '../../utilities/Cartographer'; -interface DirectiveSKOutpostMemory extends FlagMemory { - isCenterRoom?: boolean; -} + /** * Remote mining directive for source keeper rooms */ @@ -17,26 +15,16 @@ export class DirectiveSKOutpost extends Directive { static secondaryColor = COLOR_YELLOW; static containerRepairTheshold = 0.5; - memory: DirectiveSKOutpostMemory; + isCenterRoom: boolean; constructor(flag: Flag) { super(flag, colony => colony.level >= 7); - } - - isCenterRoom(): boolean { - const coords = Cartographer.getRoomCoordinates(this.pos.roomName); - if(coords.x % 10 != 0 && coords.x % 5 == 0 && coords.y % 10 != 0 && coords.y % 5== 0){ - return true; - } - return false; + this.isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE; } spawnMoarOverlords() { - if(this.memory.isCenterRoom == undefined){ - this.memory.isCenterRoom = this.isCenterRoom(); - } - //skip sourceReapoers for safe SKrooms - if(!this.memory.isCenterRoom){ + // skip sourceReapoers for safe SKrooms + if(!this.isCenterRoom) { this.overlords.sourceReaper = new SourceReaperOverlord(this); } } @@ -45,10 +33,10 @@ export class DirectiveSKOutpost extends Directive { if (!this.pos.isVisible) { return; } - const ContainerConstructionSites = _.filter(this.room!.constructionSites, s => s.structureType == STRUCTURE_CONTAINER); + const ContainerCSites = _.filter(this.room!.constructionSites, s => s.structureType == STRUCTURE_CONTAINER); - if(ContainerConstructionSites.length > 0){ - return ContainerConstructionSites[0]; + if(ContainerCSites.length > 0) { + return ContainerCSites[0]; } return; } @@ -57,9 +45,10 @@ export class DirectiveSKOutpost extends Directive { if (!this.pos.isVisible) { return; } - const containersTorepair = _.filter(this.room!.structures, s => s.structureType == STRUCTURE_CONTAINER && s.hits < DirectiveSKOutpost.containerRepairTheshold * s.hitsMax); + const containersTorepair = _.filter(this.room!.structures, s => s.structureType == STRUCTURE_CONTAINER && + s.hits < DirectiveSKOutpost.containerRepairTheshold * s.hitsMax); - if(containersTorepair.length > 0){ + if(containersTorepair.length > 0) { return containersTorepair[0]; } return; @@ -67,7 +56,7 @@ export class DirectiveSKOutpost extends Directive { init(): void { // Add this structure/CS to worker overlord's build/repair list - if(Game.time % 150 == 0){ + if(Game.time % 150 == 0) { const containerNeedRepair = this.getContainersToRepair(); if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { this.colony.overlords.work.repairStructures.push(containerNeedRepair); @@ -85,4 +74,4 @@ export class DirectiveSKOutpost extends Directive { run(): void { } -} \ No newline at end of file +} diff --git a/src/directives/resource/extract.ts b/src/directives/resource/extract.ts index 7efb330f8..6deba0e0f 100644 --- a/src/directives/resource/extract.ts +++ b/src/directives/resource/extract.ts @@ -36,8 +36,8 @@ export class DirectiveExtract extends Directive { } else { priority = OverlordPriority.remoteSKRoom.mineral; } - //Fix: Only spawn drones if there is a terminal or storage - if (!!this.colony.terminal || !!this.colony.storage){ + // Only spawn drones if there is a terminal or storage + if (!!this.colony.terminal || !!this.colony.storage) { this.overlords.extract = new ExtractorOverlord(this, priority); } } diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index d44b3779b..3f9882805 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -99,22 +99,13 @@ export class ExtractorOverlord extends Overlord { } init() { - const amount = this.mineral && this.mineral.mineralAmount > 0 ? this.mineral.pos.availableNeighbors().length : 0; + const amount = this.mineral && this.mineral.mineralAmount > 0 && this.container? + this.mineral.pos.availableNeighbors().length : 0; this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); this.registerOutputRequests(); } private handleDrone(drone: Zerg): void { - //fix: if there is no container, then transfer the minerals yourself! - if(!this.container && _.sum(drone.carry) == drone.carryCapacity ){ - const dropoffPoints: (StructureTerminal | StructureStorage)[] = _.compact([this.colony.terminal!]); - const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); - if (bestDropoffPoint) { - drone.task = Tasks.transferAll(bestDropoffPoint); - return; - } - } - // Ensure you are in the assigned room if (drone.room == this.room && !drone.pos.isEdge) { if (_.sum(drone.carry) == 0) { diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index 45ae7a8ec..9d05cface 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -95,7 +95,7 @@ export class SourceReaperOverlord extends CombatOverlord { reaper.healSelfIfPossible(); } // Kite around ranged invaders until a defender arrives - if (this.pos.findInRange(this.room.invaders,10).length > 2 && _.filter(this.defenders, def => def.room == this.room).length == 0) { + if (this.room.invaders.length > 2 && _.filter(this.defenders, def => def.room == this.room).length == 0) { reaper.kite(_.filter(this.room.hostiles, hostile => hostile.getActiveBodyparts(RANGED_ATTACK) > 0)); reaper.healSelfIfPossible(); } From 68211287668c6f926d0e98fbe05926ce424b616a Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 15 Jun 2019 00:59:37 +0300 Subject: [PATCH 19/34] uninstall lint --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 34dacef7a..1cd2bf7ca 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "dependencies": { "@tensorflow/tfjs": "^1.1.2", "columnify": "1.5.4", - "lint": "^0.7.0", "onnxjs": "^0.1.6", "source-map": "0.7.3" } From fab0e98ff4ae45d0235340cab942a4402841cda3 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 15 Jun 2019 01:00:16 +0300 Subject: [PATCH 20/34] uninstall lint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1cd2bf7ca..5541e145d 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "rollup-plugin-node-resolve": "3.3.0", "rollup-plugin-progress": "^0.4.0", "rollup-plugin-screeps": "0.1.2", - "rollup-plugin-typescript2": "^0.21.1", + "rollup-plugin-typescript2": "0.21.1", "tslint": "^5.16.0", "typedoc": "^0.14.2", "typescript": "2.9.2" From 507a351563cdff78b8637d7e068e0704ec9fd973 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 15 Jun 2019 01:02:25 +0300 Subject: [PATCH 21/34] uninstall lint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5541e145d..466554789 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "rollup-plugin-node-resolve": "3.3.0", "rollup-plugin-progress": "^0.4.0", "rollup-plugin-screeps": "0.1.2", - "rollup-plugin-typescript2": "0.21.1", + "rollup-plugin-typescript2": "0.16.1", "tslint": "^5.16.0", "typedoc": "^0.14.2", "typescript": "2.9.2" From f55d19f329b375d0bfe65efb5ec5376a972bef06 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Wed, 19 Jun 2019 17:17:21 +0300 Subject: [PATCH 22/34] limit SKroom drones to 1 --- src/overlords/mining/extractor.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 3f9882805..8e2bfdb7d 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -99,9 +99,15 @@ export class ExtractorOverlord extends Overlord { } init() { + const amount = this.mineral && this.mineral.mineralAmount > 0 && this.container? this.mineral.pos.availableNeighbors().length : 0; - this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); + //this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); + if(this.room && this.room.controller) { + this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); + } else { + this.wishlist(1, Setups.drones.extractor); // to address the issue of transporters not keeping up with SKrooms + } this.registerOutputRequests(); } From 11604c93e9568be48821bfe5f9415a4453b609f3 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Thu, 20 Jun 2019 01:28:52 +0300 Subject: [PATCH 23/34] transfer home if no container --- src/overlords/mining/extractor.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 8e2bfdb7d..1e08c6078 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -106,12 +106,21 @@ export class ExtractorOverlord extends Overlord { if(this.room && this.room.controller) { this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); } else { - this.wishlist(1, Setups.drones.extractor); // to address the issue of transporters not keeping up with SKrooms + this.wishlist(Math.min(amount, 1), Setups.drones.extractor); } this.registerOutputRequests(); } private handleDrone(drone: Zerg): void { + //fix: if there is no container, then transfer the minerals yourself! + if (!this.container && _.sum(drone.carry) == drone.carryCapacity) { + const dropoffPoints: (StructureLink | StructureStorage)[] = _.compact([this.colony.terminal!]); + const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); + if (bestDropoffPoint) { + if (bestDropoffPoint) drone.task = Tasks.transfer(bestDropoffPoint); + return; + } + } // Ensure you are in the assigned room if (drone.room == this.room && !drone.pos.isEdge) { if (_.sum(drone.carry) == 0) { From 4a35d8de100d0486483c837ef387ab4c67d2077d Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Thu, 20 Jun 2019 01:35:06 +0300 Subject: [PATCH 24/34] transfer home if no container --- src/directives/colony/outpostSK.ts | 2 +- src/overlords/mining/extractor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index ae8e03437..f2f7f8e69 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -13,7 +13,7 @@ export class DirectiveSKOutpost extends Directive { static directiveName = 'outpostSK'; static color = COLOR_PURPLE; static secondaryColor = COLOR_YELLOW; - static containerRepairTheshold = 0.5; + static containerRepairTheshold = 0.75; isCenterRoom: boolean; diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 1e08c6078..b58e20001 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -114,7 +114,7 @@ export class ExtractorOverlord extends Overlord { private handleDrone(drone: Zerg): void { //fix: if there is no container, then transfer the minerals yourself! if (!this.container && _.sum(drone.carry) == drone.carryCapacity) { - const dropoffPoints: (StructureLink | StructureStorage)[] = _.compact([this.colony.terminal!]); + const dropoffPoints: (StructureTerminal)[] = _.compact([this.colony.terminal!]); const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); if (bestDropoffPoint) { if (bestDropoffPoint) drone.task = Tasks.transfer(bestDropoffPoint); From 0a9ae07741c8e0ece7137d38b252f8b0351bd96b Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Thu, 20 Jun 2019 02:40:28 +0300 Subject: [PATCH 25/34] done build and repair containers now --- src/directives/colony/outpostSK.ts | 2 +- src/overlords/mining/extractor.ts | 39 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index f2f7f8e69..9618397bc 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -56,7 +56,7 @@ export class DirectiveSKOutpost extends Directive { init(): void { // Add this structure/CS to worker overlord's build/repair list - if(Game.time % 150 == 0) { + if(Game.time % 25 == 0) { const containerNeedRepair = this.getContainersToRepair(); if (containerNeedRepair && !this.colony.overlords.work.repairStructures.includes(containerNeedRepair)) { this.colony.overlords.work.repairStructures.push(containerNeedRepair); diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index b58e20001..91fb18cbc 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -55,7 +55,7 @@ export class ExtractorOverlord extends Overlord { private registerOutputRequests(): void { if (this.container) { - if (_.sum(this.container.store) > 0.5 * this.container.storeCapacity || + if (_.sum(this.container.store) > 0.3 * this.container.storeCapacity || (_.sum(this.container.store) > 0 && this.drones.length == 0)) { this.colony.logisticsNetwork.requestOutput(this.container, {resourceType: 'all'}); } @@ -100,9 +100,9 @@ export class ExtractorOverlord extends Overlord { init() { - const amount = this.mineral && this.mineral.mineralAmount > 0 && this.container? + const amount = this.mineral && this.mineral.mineralAmount > 0 ? this.mineral.pos.availableNeighbors().length : 0; - //this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); + // this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); if(this.room && this.room.controller) { this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); } else { @@ -112,15 +112,30 @@ export class ExtractorOverlord extends Overlord { } private handleDrone(drone: Zerg): void { - //fix: if there is no container, then transfer the minerals yourself! - if (!this.container && _.sum(drone.carry) == drone.carryCapacity) { - const dropoffPoints: (StructureTerminal)[] = _.compact([this.colony.terminal!]); - const bestDropoffPoint = drone.pos.findClosestByMultiRoomRange(dropoffPoints); - if (bestDropoffPoint) { - if (bestDropoffPoint) drone.task = Tasks.transfer(bestDropoffPoint); - return; - } - } + // fix: Build container + if (drone.room == this.room && !this.container) { + const containerCsites = _.filter(this.room.constructionSites,csite => csite.structureType == STRUCTURE_CONTAINER); + const containerCsite = this.pos.findClosestByLimitedRange(containerCsites, 1); + if (containerCsite && _.sum(drone.carry) == 0) { + drone.task = Tasks.recharge(); + return; + } + if (containerCsite && drone.carry.energy > 0) { + drone.task = Tasks.build(containerCsite); + return; + } + } + // fix: repair container + if (drone.room == this.room && this.container && this.container.hits/this.container.hitsMax < 0.5) { + if (_.sum(drone.carry) == 0) { + drone.task = Tasks.recharge(); + return; + } + if (drone.carry.energy > 0) { + drone.task = Tasks.repair(this.container); + return; + } + } // Ensure you are in the assigned room if (drone.room == this.room && !drone.pos.isEdge) { if (_.sum(drone.carry) == 0) { From c34a87b54d86c1818e8950f0141ad1747dff0418 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Fri, 21 Jun 2019 17:49:10 +0300 Subject: [PATCH 26/34] only repair when mineral > 0 --- src/directives/colony/outpostSK.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 9618397bc..43e5d82f2 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -30,7 +30,7 @@ export class DirectiveSKOutpost extends Directive { } getContainerConstructionSites(): ConstructionSite | undefined { - if (!this.pos.isVisible) { + if (!this.pos.isVisible || (this.room && this.room.mineral && this.room.mineral.mineralAmount == 0)) { return; } const ContainerCSites = _.filter(this.room!.constructionSites, s => s.structureType == STRUCTURE_CONTAINER); @@ -42,7 +42,7 @@ export class DirectiveSKOutpost extends Directive { } getContainersToRepair(): Structure | undefined { - if (!this.pos.isVisible) { + if (!this.pos.isVisible || (this.room && this.room.mineral && this.room.mineral.mineralAmount == 0)) { return; } const containersTorepair = _.filter(this.room!.structures, s => s.structureType == STRUCTURE_CONTAINER && From 698912099ba6ff53ed7c5e8456668fc4f87e4df8 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 22 Jun 2019 01:11:15 +0300 Subject: [PATCH 27/34] do not spawn harvester/miners under heavy invasion --- src/directives/colony/outpostSK.ts | 3 --- src/overlords/mining/extractor.ts | 4 +++- src/overlords/mining/miner.ts | 7 +++++-- src/overlords/mining/sourceKeeperReeper.ts | 7 ++++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/directives/colony/outpostSK.ts b/src/directives/colony/outpostSK.ts index 43e5d82f2..a83649c7f 100644 --- a/src/directives/colony/outpostSK.ts +++ b/src/directives/colony/outpostSK.ts @@ -23,10 +23,7 @@ export class DirectiveSKOutpost extends Directive { } spawnMoarOverlords() { - // skip sourceReapoers for safe SKrooms - if(!this.isCenterRoom) { this.overlords.sourceReaper = new SourceReaperOverlord(this); - } } getContainerConstructionSites(): ConstructionSite | undefined { diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 91fb18cbc..c3605b4d5 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -99,7 +99,9 @@ export class ExtractorOverlord extends Overlord { } init() { - + if(this.room && !this.room.my && this.room.invaders.length == 4) { + return; + } const amount = this.mineral && this.mineral.mineralAmount > 0 ? this.mineral.pos.availableNeighbors().length : 0; // this.wishlist(Math.min(amount, ExtractorOverlord.settings.maxDrones), Setups.drones.extractor); diff --git a/src/overlords/mining/miner.ts b/src/overlords/mining/miner.ts index 866cb7552..8c9f1c230 100644 --- a/src/overlords/mining/miner.ts +++ b/src/overlords/mining/miner.ts @@ -200,8 +200,11 @@ export class MiningOverlord extends Overlord { } init() { - this.wishlist(this.minersNeeded, this.setup); - this.registerEnergyRequests(); + if(this.room && !this.room.my && this.room.invaders.length == 4) { + return; + } + this.wishlist(this.minersNeeded, this.setup); + this.registerEnergyRequests(); } /** diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index 9d05cface..d6597c668 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -7,6 +7,7 @@ import {Movement} from '../../movement/Movement'; import {OverlordPriority} from '../../priorities/priorities_overlords'; import {profile} from '../../profiler/decorator'; import {CombatTargeting} from '../../targeting/CombatTargeting'; +import {Cartographer, ROOMTYPE_CORE} from '../../utilities/Cartographer'; import {minBy} from '../../utilities/utils'; import {Visualizer} from '../../visuals/Visualizer'; import {CombatZerg} from '../../zerg/CombatZerg'; @@ -28,6 +29,7 @@ export class SourceReaperOverlord extends CombatOverlord { directive: DirectiveSKOutpost; memory: SourceReaperOverlordMemory; targetLair: StructureKeeperLair | undefined; + isCenterRoom: boolean; reapers: CombatZerg[]; defenders: CombatZerg[]; @@ -40,6 +42,7 @@ export class SourceReaperOverlord extends CombatOverlord { this.defenders = this.combatZerg(Roles.ranged); this.memory = Mem.wrap(this.directive.memory, 'sourceReaper'); this.computeTargetLair(); + this.isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE; } private computeTargetLair() { @@ -58,7 +61,9 @@ export class SourceReaperOverlord extends CombatOverlord { init() { const defenderAmount = this.room && (this.room.invaders.length > 0 || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0; - this.wishlist(1, CombatSetups.zerglings.sourceKeeper); + const reaperAmount = this.isCenterRoom? 0 : 1 ; + + this.wishlist(reaperAmount, CombatSetups.zerglings.sourceKeeper); this.wishlist(defenderAmount, CombatSetups.hydralisks.sourceKeeper); } From a9289883072b206bee462be802d6ebf7f999203d Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 22 Jun 2019 01:25:49 +0300 Subject: [PATCH 28/34] fix --- src/overlords/mining/extractor.ts | 2 +- src/overlords/mining/miner.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index c3605b4d5..645c0fb35 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -99,7 +99,7 @@ export class ExtractorOverlord extends Overlord { } init() { - if(this.room && !this.room.my && this.room.invaders.length == 4) { + if(this.room && !this.room.my && (this.room.invaders.length == 4 || this.room.dangerousPlayerHostiles.length > 0)) { return; } const amount = this.mineral && this.mineral.mineralAmount > 0 ? diff --git a/src/overlords/mining/miner.ts b/src/overlords/mining/miner.ts index 8c9f1c230..983d80045 100644 --- a/src/overlords/mining/miner.ts +++ b/src/overlords/mining/miner.ts @@ -200,9 +200,9 @@ export class MiningOverlord extends Overlord { } init() { - if(this.room && !this.room.my && this.room.invaders.length == 4) { + if(this.room && !this.room.my && (this.room.invaders.length == 4 || this.room.dangerousPlayerHostiles.length > 0)) { return; - } + } this.wishlist(this.minersNeeded, this.setup); this.registerEnergyRequests(); } From 9bb8fb982ab61dd5fefe902f75ea431700299462 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sat, 22 Jun 2019 20:23:54 +0300 Subject: [PATCH 29/34] adjust reaper amount --- src/overlords/mining/sourceKeeperReeper.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index d6597c668..f1e5962eb 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -29,7 +29,7 @@ export class SourceReaperOverlord extends CombatOverlord { directive: DirectiveSKOutpost; memory: SourceReaperOverlordMemory; targetLair: StructureKeeperLair | undefined; - isCenterRoom: boolean; + // isCenterRoom: boolean; reapers: CombatZerg[]; defenders: CombatZerg[]; @@ -42,7 +42,7 @@ export class SourceReaperOverlord extends CombatOverlord { this.defenders = this.combatZerg(Roles.ranged); this.memory = Mem.wrap(this.directive.memory, 'sourceReaper'); this.computeTargetLair(); - this.isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE; + // this.isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE; } private computeTargetLair() { @@ -59,12 +59,12 @@ export class SourceReaperOverlord extends CombatOverlord { } init() { - const defenderAmount = this.room && (this.room.invaders.length > 0 + const amount = this.room && (this.room.invaders.length > 0 || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0; - const reaperAmount = this.isCenterRoom? 0 : 1 ; + // const reaperAmount = this.isCenterRoom? 0 : 1 ; - this.wishlist(reaperAmount, CombatSetups.zerglings.sourceKeeper); - this.wishlist(defenderAmount, CombatSetups.hydralisks.sourceKeeper); + this.wishlist(amount, CombatSetups.zerglings.sourceKeeper); + this.wishlist(amount, CombatSetups.hydralisks.sourceKeeper); } private getNextTargetLair(): StructureKeeperLair | undefined { From 6d6b4a5b2ca9caa06b9c3539ed7d8ab05bcaad4a Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sun, 23 Jun 2019 03:41:37 +0300 Subject: [PATCH 30/34] fixed major introcuded bug --- src/overlords/mining/sourceKeeperReeper.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/overlords/mining/sourceKeeperReeper.ts b/src/overlords/mining/sourceKeeperReeper.ts index f1e5962eb..7ad21bbe1 100644 --- a/src/overlords/mining/sourceKeeperReeper.ts +++ b/src/overlords/mining/sourceKeeperReeper.ts @@ -29,7 +29,7 @@ export class SourceReaperOverlord extends CombatOverlord { directive: DirectiveSKOutpost; memory: SourceReaperOverlordMemory; targetLair: StructureKeeperLair | undefined; - // isCenterRoom: boolean; + isCenterRoom: boolean; reapers: CombatZerg[]; defenders: CombatZerg[]; @@ -42,7 +42,7 @@ export class SourceReaperOverlord extends CombatOverlord { this.defenders = this.combatZerg(Roles.ranged); this.memory = Mem.wrap(this.directive.memory, 'sourceReaper'); this.computeTargetLair(); - // this.isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE; + this.isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE; } private computeTargetLair() { @@ -59,12 +59,12 @@ export class SourceReaperOverlord extends CombatOverlord { } init() { - const amount = this.room && (this.room.invaders.length > 0 + const defenderAmount = this.room && (this.room.invaders.length > 0 || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0; - // const reaperAmount = this.isCenterRoom? 0 : 1 ; + const reaperAmount = (defenderAmount || !this.isCenterRoom)? 1 : 0 ; - this.wishlist(amount, CombatSetups.zerglings.sourceKeeper); - this.wishlist(amount, CombatSetups.hydralisks.sourceKeeper); + this.wishlist(reaperAmount, CombatSetups.zerglings.sourceKeeper); + this.wishlist(defenderAmount, CombatSetups.hydralisks.sourceKeeper); } private getNextTargetLair(): StructureKeeperLair | undefined { From 54645a40c0b05991ed85bc7ef2356096470f6560 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sun, 23 Jun 2019 08:33:05 +0300 Subject: [PATCH 31/34] drone pick up energy from tombstomes --- src/overlords/mining/extractor.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 645c0fb35..e9449e27c 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -128,10 +128,19 @@ export class ExtractorOverlord extends Overlord { } } // fix: repair container - if (drone.room == this.room && this.container && this.container.hits/this.container.hitsMax < 0.5) { - if (_.sum(drone.carry) == 0) { - drone.task = Tasks.recharge(); - return; + if (drone.room == this.room && this.container) { + if(this.container.hits/this.container.hitsMax < 0.5) { + if (_.sum(drone.carry) == 0) { + drone.task = Tasks.recharge(); + return; + } + } + if(drone.carry.energy < _.sum(drone.carry)/2) { + const tombsStone = _.first(_.filter(this.room.tombstones,tombstone => tombstone.pos.inRangeTo(drone,5))); + if(tombsStone && tombsStone.energy) { + drone.task = Tasks.withdraw(tombsStone,RESOURCE_ENERGY); + return; + } } if (drone.carry.energy > 0) { drone.task = Tasks.repair(this.container); From 4a5e2b6cadd954c65609f576bb04ca640478d642 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sun, 23 Jun 2019 08:40:08 +0300 Subject: [PATCH 32/34] drone pick up energy from tombstomes --- src/overlords/mining/extractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index e9449e27c..5c80a0334 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -135,7 +135,7 @@ export class ExtractorOverlord extends Overlord { return; } } - if(drone.carry.energy < _.sum(drone.carry)/2) { + if(_.sum(drone.carry) < _.sum(drone.carry)/2) { const tombsStone = _.first(_.filter(this.room.tombstones,tombstone => tombstone.pos.inRangeTo(drone,5))); if(tombsStone && tombsStone.energy) { drone.task = Tasks.withdraw(tombsStone,RESOURCE_ENERGY); From e432131b81ad9a66a1f70354f968a8cc97c8ba89 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Sun, 23 Jun 2019 08:44:03 +0300 Subject: [PATCH 33/34] drone pick up energy from tombstomes --- src/overlords/mining/extractor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 5c80a0334..9959c7d4c 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -135,7 +135,7 @@ export class ExtractorOverlord extends Overlord { return; } } - if(_.sum(drone.carry) < _.sum(drone.carry)/2) { + if(_.sum(drone.carry) < drone.carryCapacity/2) { const tombsStone = _.first(_.filter(this.room.tombstones,tombstone => tombstone.pos.inRangeTo(drone,5))); if(tombsStone && tombsStone.energy) { drone.task = Tasks.withdraw(tombsStone,RESOURCE_ENERGY); From edff4be4d25cd5409d1d3c9c926733262d6d6861 Mon Sep 17 00:00:00 2001 From: hasoon hasoon Date: Mon, 24 Jun 2019 01:46:25 +0300 Subject: [PATCH 34/34] remove drone pick up energy from tombstomes --- src/overlords/mining/extractor.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/overlords/mining/extractor.ts b/src/overlords/mining/extractor.ts index 9959c7d4c..a0f11ae25 100644 --- a/src/overlords/mining/extractor.ts +++ b/src/overlords/mining/extractor.ts @@ -135,6 +135,7 @@ export class ExtractorOverlord extends Overlord { return; } } + /* if(_.sum(drone.carry) < drone.carryCapacity/2) { const tombsStone = _.first(_.filter(this.room.tombstones,tombstone => tombstone.pos.inRangeTo(drone,5))); if(tombsStone && tombsStone.energy) { @@ -142,6 +143,7 @@ export class ExtractorOverlord extends Overlord { return; } } + */ if (drone.carry.energy > 0) { drone.task = Tasks.repair(this.container); return;