Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKoutpost directive and overload: improvements and fixes #134

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fa85104
fix handleDrone, if there is no container, then miner should transfer…
May 18, 2019
1725754
fix handleDrone, if there is no container, then miner should transfer…
May 18, 2019
458220b
check for max carry capacity
May 18, 2019
0419b12
pushed container constuction site to workers
May 18, 2019
d98ceda
pushed container constuction site to workers
May 18, 2019
5064107
drone transferAll instead of transfer, target changed from storage to…
May 18, 2019
2235352
drone transferAll instead of transfer, target changed from storage to…
May 18, 2019
92fcb30
drone transferAll instead of transfer, target changed from storage to…
May 18, 2019
0d8ab06
Game.rooms[this.pos.roomName];
May 18, 2019
5c1ee27
added containers to worker repair list in SK room
May 19, 2019
ae83f31
only spawn miner in own room when there is a terminal/strorage
May 21, 2019
863fd3f
SKroom directive cleanup
Jun 7, 2019
2371f0e
safe SK room = no reaper
Jun 7, 2019
e72592d
centerRoom in memory now
Jun 8, 2019
709231c
reaper invaders in range of 10 > 2)
Jun 8, 2019
b28e28e
CPU optimization
Jun 9, 2019
7cd05ee
package.json!
Jun 13, 2019
ba13e30
lint comment fix
Jun 14, 2019
6821128
uninstall lint
Jun 14, 2019
fab0e98
uninstall lint
Jun 14, 2019
507a351
uninstall lint
Jun 14, 2019
e059b48
Merge branch 'master' into fixHandleDrone
Jun 18, 2019
f55d19f
limit SKroom drones to 1
Jun 19, 2019
11604c9
transfer home if no container
Jun 19, 2019
4a35d8d
transfer home if no container
Jun 19, 2019
0a9ae07
done build and repair containers now
Jun 19, 2019
c34a87b
only repair when mineral > 0
Jun 21, 2019
6989120
do not spawn harvester/miners under heavy invasion
Jun 21, 2019
a928988
fix
Jun 21, 2019
9bb8fb9
adjust reaper amount
Jun 22, 2019
6d6b4a5
fixed major introcuded bug
Jun 23, 2019
54645a4
drone pick up energy from tombstomes
Jun 23, 2019
4a5e2b6
drone pick up energy from tombstomes
Jun 23, 2019
e432131
drone pick up energy from tombstomes
Jun 23, 2019
edff4be
remove drone pick up energy from tombstomes
Jun 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
"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",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to make changes to dependencies, as it can break the checksum generation process. Is there a reason you are updating the rollup plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, check latest PR

"tslint": "^5.16.0",
"typedoc": "^0.14.2",
"typescript": "2.9.2"
},
"dependencies": {
"@tensorflow/tfjs": "^1.1.2",
"columnify": "1.5.4",
"lint": "^0.7.0",
"onnxjs": "^0.1.6",
"source-map": "0.7.3"
}
Expand Down
64 changes: 60 additions & 4 deletions src/directives/colony/outpostSK.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {SourceReaperOverlord} from '../../overlords/mining/sourceKeeperReeper';
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
*/
Expand All @@ -12,21 +15,74 @@ export class DirectiveSKOutpost extends Directive {
static directiveName = 'outpostSK';
static color = COLOR_PURPLE;
static secondaryColor = COLOR_YELLOW;
static containerRepairTheshold = 0.5;

memory: DirectiveSKOutpostMemory;

constructor(flag: Flag) {
super(flag, colony => colony.level >= 7);
}

isCenterRoom(): boolean {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unnecessary; use something like const isCenterRoom = Cartographer.roomType(this.pos.roomName) == ROOMTYPE_CORE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, check latest PR

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() {
this.overlords.sourceReaper = new SourceReaperOverlord(this);
if(this.memory.isCenterRoom == undefined){
this.memory.isCenterRoom = this.isCenterRoom();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't store isCenterRoom in memory. it's inexpensive to calculate and can be stuck directly in the DirectiveSKOutpost constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, it is now checked in constructor.
existing Overmind users that already have the directive flag in place will not benefit from this, would you suggest to add it under init() too?

}
//skip sourceReapoers for safe SKrooms
if(!this.memory.isCenterRoom){
this.overlords.sourceReaper = new SourceReaperOverlord(this);
}
}

getContainerConstructionSites(): ConstructionSite | undefined {
if (!this.pos.isVisible) {
return;
}
const ContainerConstructionSites = _.filter(this.room!.constructionSites, s => s.structureType == STRUCTURE_CONTAINER);

if(ContainerConstructionSites.length > 0){
return ContainerConstructionSites[0];
}
return;
}

getContainersToRepair(): Structure | undefined {
if (!this.pos.isVisible) {
return;
}
const containersTorepair = _.filter(this.room!.structures, s => s.structureType == STRUCTURE_CONTAINER && s.hits < DirectiveSKOutpost.containerRepairTheshold * s.hitsMax);

if(containersTorepair.length > 0){
return containersTorepair[0];
}
return;
}

init(): void {
// Add this structure/CS to worker overlord's build/repair list
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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sk miners already build and repair their own containers -- why do you want to offload this to the colony workers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drones that harvest minerals do not repair their containers like the drones harvesting energy.
I have noticed in replays, that mineral containers always decays out without repair.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes does not have a filter for mineral container only, the worker will repair all containers in SKroom below 50%, which will most probably apply to mineral container being below the threshold

return;
}

const containerToBuild = this.getContainerConstructionSites();
if (containerToBuild && !this.colony.overlords.work.constructionSites.includes(containerToBuild)) {
this.colony.overlords.work.constructionSites.push(containerToBuild);
return;
}
}
}

run(): void {

}
}

}
7 changes: 5 additions & 2 deletions src/directives/resource/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class DirectiveExtract extends Directive {
}

spawnMoarOverlords() {
let priority: number;
let priority: number;
if (this.room && this.room.my) {
if (this.colony.level == 8) {
priority = OverlordPriority.ownedRoom.mineralRCL8;
Expand All @@ -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){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

this.overlords.extract = new ExtractorOverlord(this, priority);
}
}

init() {
Expand Down
10 changes: 10 additions & 0 deletions src/overlords/mining/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ 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 ){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably just shouldn't spawn any extractors unless there is a container

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea,
what about changing the amount to zero in wishlist if there is no container, something like this:
const amount = this.mineral && this.mineral.mineralAmount > 0 && this.container ? this.mineral.pos.availableNeighbors().length : 0;

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) {
Expand Down
2 changes: 1 addition & 1 deletion src/overlords/mining/sourceKeeperReeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will revert this one back.

reaper.kite(_.filter(this.room.hostiles, hostile => hostile.getActiveBodyparts(RANGED_ATTACK) > 0));
reaper.healSelfIfPossible();
}
Expand Down