This commit is contained in:
dan 2020-11-18 09:04:34 -06:00
commit 6f6535faf1
3 changed files with 25 additions and 2 deletions

View File

@ -96,6 +96,20 @@ module.exports = {
Game.rooms[name].memory.minablepositions = minablepositions Game.rooms[name].memory.minablepositions = minablepositions
} }
}, },
computeMineralAccess: function(){
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name
let mineralminablepositions = 0
let minerals = Game.rooms[name].find(FIND_MINERALS);
for(let i = 0;i<minerals.length;i++)
{
mineralminablepositions = mineralminablepositions + this.computeSourceAccessPoints(Game.rooms[name],minerals[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.mineralminablepositions = mineralminablepositions
}
},
computeSourceAccessPoints: function(room, source){ computeSourceAccessPoints: function(room, source){
const roomTerrain = room.getTerrain(); const roomTerrain = room.getTerrain();
var accessPoints = 0; var accessPoints = 0;

View File

@ -43,8 +43,8 @@ let Phase1 = {
console.log("Spawning Mover in " + room) console.log("Spawning Mover in " + room)
require('proc.spawning').spawnmover(room) require('proc.spawning').spawnmover(room)
} }
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)){ if((Game.rooms[room].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_EXTRACTOR}}).length > 0)&&(creepcounts["miner"] < Game.rooms[room].memory.mineralminablepositions || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){
if(Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration < 1000){ if(Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration == undefined || Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration < 1000 ){
console.log("Spawning Miner in " + room) console.log("Spawning Miner in " + room)
require('proc.spawning').spawnminer(room) require('proc.spawning').spawnminer(room)
} else { if(Game.flags.debug && Game.flags.debug.room == Game.rooms[room]){console.log("Not spawning miner in " + room + ", waiting for regen")}} } else { if(Game.flags.debug && Game.flags.debug.room == Game.rooms[room]){console.log("Not spawning miner in " + room + ", waiting for regen")}}

View File

@ -10,6 +10,15 @@ let initroom = {
Game.rooms[name].memory.tickssofar=0 Game.rooms[name].memory.tickssofar=0
Game.rooms[name].memory.maphits={} Game.rooms[name].memory.maphits={}
//Game.rooms[name].memory.minablepositions= this.checkminablepositions(name) //Game.rooms[name].memory.minablepositions= this.checkminablepositions(name)
let mineralminablepositions = 0
let minerals = Game.rooms[name].find(FIND_MINERALS);
for(let i = 0;i<minerals.length;i++)
{
mineralminablepositions = mineralminablepositions + this.computeSourceAccessPoints(Game.rooms[name],minerals[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.mineralminablepositions = mineralminablepositions
let minablepositions = 0 let minablepositions = 0
let srcs = Game.rooms[name].find(FIND_SOURCES); let srcs = Game.rooms[name].find(FIND_SOURCES);
for(let i = 0;i<srcs.length;i++) for(let i = 0;i<srcs.length;i++)