diff --git a/Room.Phase1.js b/Room.Phase1.js index d549bfb..025002f 100644 --- a/Room.Phase1.js +++ b/Room.Phase1.js @@ -25,7 +25,7 @@ let Phase1 = { console.log(Game.rooms[room].energyAvailable + " of " + Game.rooms[room].energyCapacityAvailable) } if(Game.rooms[room].memory.minablepositions >= 3 ||Game.rooms[room].memory.minablepositions==undefined ){ - if((((creepcounts[workerrolename]< (Game.rooms[room].memory.minablepositions) || creepcounts[workerrolename]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && Game.rooms[room].energyAvailable>100)) { + if((((creepcounts[workerrolename]< (Game.rooms[room].memory.minablepositions + 1) || creepcounts[workerrolename]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && Game.rooms[room].energyAvailable>100)) { console.log('Spawning worker in ' + room) require('proc.spawning').spawnworker(room) } @@ -43,7 +43,7 @@ let Phase1 = { console.log("Spawning Mover in " + room) require('proc.spawning').spawnmover(room) } - if((Game.rooms[room].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_EXTRACTOR}}))&&(creepcounts["miner"] < 1 || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){ + if((Game.rooms[room].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_EXTRACTOR}}).length > 0)&&(creepcounts["miner"] < 1 || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){ console.log("Spawning Miner in " + room) require('proc.spawning').spawnminer(room) } diff --git a/RoomInit.js b/RoomInit.js index 82f1e7b..bcd5aa6 100644 --- a/RoomInit.js +++ b/RoomInit.js @@ -17,6 +17,7 @@ let initroom = { minablepositions = minablepositions + this.computeSourceAccessPoints(Game.rooms[name],srcs[i]) //minablepositions = minablepositions + this.checkminablepositions(srcs[i]) } + //todo - create array of minable positions in the room and assign a screep to them, rather than having them constantly try to find the nearest one. Game.rooms[name].memory.minablepositions = minablepositions }, computeSourceAccessPoints: function(room, source){ diff --git a/role.miner.js b/role.miner.js index ecd7fc7..9c70e20 100644 --- a/role.miner.js +++ b/role.miner.js @@ -17,7 +17,7 @@ let roleMiner = { creep.travelTo(mysource); } } else { - let storagetargets = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_TERMINAL ) && _.sum(s.store) < s.storeCapacity) ;}}); + let storagetargets = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_TERMINAL || s.structureType == STRUCTURE_FACTORY ) && _.sum(s.store) < s.storeCapacity) ;}}); if(storagetargets){ if(this.transferAll(creep,storagetargets) == ERR_NOT_IN_RANGE) { creep.moveTo(storagetargets,{ignoreCreeps:ignorecreeps}) diff --git a/todos.js b/todos.js new file mode 100644 index 0000000..92d0be1 --- /dev/null +++ b/todos.js @@ -0,0 +1 @@ +//todo - create array of minable positions in the room and assign a screep to them, rather than having them constantly try to find the nearest one.