mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-28 19:54:01 -06:00
Fix miner spawn bug and add check for how many positions are usable when mining.
increase miner spawns to match this number, add Empire function to init all rooms with this data.
This commit is contained in:
parent
c525c49b74
commit
e4831aa8e8
14
Empire.js
14
Empire.js
@ -96,6 +96,20 @@ module.exports = {
|
||||
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){
|
||||
const roomTerrain = room.getTerrain();
|
||||
var accessPoints = 0;
|
||||
|
@ -43,8 +43,8 @@ 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}}).length > 0)&&(creepcounts["miner"] < 1 || 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_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 == undefined || Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration < 1000 ){
|
||||
console.log("Spawning Miner in " + 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")}}
|
||||
|
@ -10,6 +10,15 @@ let initroom = {
|
||||
Game.rooms[name].memory.tickssofar=0
|
||||
Game.rooms[name].memory.maphits={}
|
||||
//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 srcs = Game.rooms[name].find(FIND_SOURCES);
|
||||
for(let i = 0;i<srcs.length;i++)
|
||||
|
Loading…
Reference in New Issue
Block a user