From 6ede729aedfaa36c7cac9d1c8b0065f16ec07c9e Mon Sep 17 00:00:00 2001 From: paradizelost Date: Thu, 13 Jul 2017 23:24:42 -0500 Subject: [PATCH] Catch-Up Commit --- Empire.js | 7 +++ NOTES.js | 2 +- bodypartbuilder.js | 20 +++---- initroom.js | 35 ++++++++++++ main.js | 125 +++++++++++-------------------------------- mineralprocessing.js | 4 +- proc.sales.js | 14 +++++ role.builder.js | 2 +- role.claimer.js | 2 +- role.nrbuilder.js | 2 +- role.nrminer.js | 7 +-- sourceprocessing.js | 4 +- spawnprocessing.js | 32 +++++++++++ sproc.js | 4 +- tower.js | 8 ++- 15 files changed, 153 insertions(+), 115 deletions(-) create mode 100644 initroom.js create mode 100644 proc.sales.js diff --git a/Empire.js b/Empire.js index bf33ddd..ca4cdb7 100644 --- a/Empire.js +++ b/Empire.js @@ -46,6 +46,13 @@ module.exports = { let newmax = Game.rooms[roomname].memory[rolename] return 'Old Max:'+currentmax+' New Max:'+newmax }, + setmax: function(role,roomname,count){ + let rolename = 'max' + role + 's' + let currentmax = Game.rooms[roomname].memory[rolename] + Game.rooms[roomname].memory[rolename] = count + let newmax = Game.rooms[roomname].memory[rolename] + return 'Old Max:'+currentmax+' New Max:'+newmax + }, increase: function(role,roomname){ let rolename = 'max' + role + 's' let currentmax = Game.rooms[roomname].memory[rolename] diff --git a/NOTES.js b/NOTES.js index 9a380e3..1e07589 100644 --- a/NOTES.js +++ b/NOTES.js @@ -1,5 +1,5 @@ if(containers.count==0 && structure_extensions.count==0 && storage.count==0 && miners.count==0){spawn harvester} else { spawn miners and haulers} - +require('role.' + creep.memory.role).run(creep) _.forEach(Game.creeps, creep => creep.suicide()) _.forEach(Game.rooms[roomname].constructionSites, cs=>cs.remove()) serializePos: function(pos) { diff --git a/bodypartbuilder.js b/bodypartbuilder.js index f33db5a..04bbea5 100644 --- a/bodypartbuilder.js +++ b/bodypartbuilder.js @@ -40,6 +40,8 @@ let buildparts = { for(let spawn of myspawns){ if(!spawn.spawning){ for(let totry of [ + [MOVE,MOVE,MOVE,MOVE,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY], + [MOVE,MOVE,MOVE,WORK,WORK,WORK,CARRY,CARRY,CARRY], [MOVE,MOVE,WORK,WORK,CARRY,CARRY], [MOVE,WORK,CARRY] @@ -236,16 +238,14 @@ let buildparts = { for(let spawn of myspawns){ if(!spawn.spawning){ for(let totry of [ - [WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [WORK,WORK,WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [WORK,WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [WORK,WORK,WORK,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE], - [MOVE,MOVE,WORK,WORK,WORK,CARRY,CARRY,CARRY], - [MOVE,MOVE,WORK,WORK,CARRY,CARRY], - [MOVE,WORK,CARRY] + [MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL8 + [MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL7 + [MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL6 + [MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL5 + [MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL4 + [MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL3 + [MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL2 + [MOVE,WORK,CARRY]//RCL1 ]){ let ispossible = spawn.canCreateCreep(totry) if(ispossible==OK){ diff --git a/initroom.js b/initroom.js new file mode 100644 index 0000000..be90560 --- /dev/null +++ b/initroom.js @@ -0,0 +1,35 @@ +let initroom = { + run: function(name) { + console.log('Initing room ' + name) + if(Game.rooms[name].memory.CreepNum == undefined){Game.rooms[name].memory.CreepNum=0} + if(Game.rooms[name].memory.minbuildpct == undefined){Game.rooms[name].memory.minbuildpct=-1} + if(Game.rooms[name].memory.minupgradepct == undefined){Game.rooms[name].memory.minupgradepct=.5} + if(Game.rooms[name].memory.minrepairpct == undefined){Game.rooms[name].memory.minrepairpct=.5} + if(Game.rooms[name].memory.maxbuilders == undefined){ Game.rooms[name].memory.maxbuilders =1 } + if(Game.rooms[name].memory.maxnrbuilders == undefined){ Game.rooms[name].memory.maxnrbuilders =0 } + if(Game.rooms[name].memory.maxclaimers == undefined){ Game.rooms[name].memory.maxclaimers =0 } + if(Game.rooms[name].memory.maxupgraders == undefined){ Game.rooms[name].memory.maxupgraders = 2 } + if(Game.rooms[name].memory.maxminers == undefined){ Game.rooms[name].memory.maxminers = 2 } + if(Game.rooms[name].memory.maxminer2s == undefined){ Game.rooms[name].memory.maxminer2s = 0 } + if(Game.rooms[name].memory.maxnrminers == undefined){ Game.rooms[name].memory.maxnrminers = 0 } + if(Game.rooms[name].memory.maxhaulers == undefined){ Game.rooms[name].memory.maxhaulers = 2 } + if(Game.rooms[name].memory.maxhauler2s == undefined){ Game.rooms[name].memory.maxhauler2s = 1 } + if(Game.rooms[name].memory.maxhauler3s == undefined){ Game.rooms[name].memory.maxhauler3s = 0 } + if(Game.rooms[name].memory.maxwarriors == undefined){ Game.rooms[name].memory.maxwarriors = 0 } + if(Game.rooms[name].memory.maxtowerrechargers == undefined){ Game.rooms[name].memory.maxtowerrechargers = 0 } + if(Game.rooms[name].memory.maxharvesters == undefined){ Game.rooms[name].memory.maxharvesters = 0 } + if(Game.rooms[name].memory.maxharvester2s == undefined){ Game.rooms[name].memory.maxharvester2s = 0 } + if(Game.rooms[name].memory.maxrepairbots == undefined){ Game.rooms[name].memory.maxrepairbots = 1 } + if(Game.rooms[name].memory.minworkenergypct == undefined){ Game.rooms[name].memory.minworkenergypct = 0.3 } + if(Game.rooms[name].memory.builderparkx==undefined){Game.rooms[name].memory.builderparkx=24} + if(Game.rooms[name].memory.builderparky==undefined){Game.rooms[name].memory.builderparky=24} + if(Game.rooms[name].memory.hauler2parkx==undefined){Game.rooms[name].memory.hauler2parkx=24} + if(Game.rooms[name].memory.hauler2parky==undefined){Game.rooms[name].memory.hauler2parky=24} + if(Game.rooms[name].memory.upgraderparkx==undefined){Game.rooms[name].memory.upgraderparkx=24} + if(Game.rooms[name].memory.upgraderparky==undefined){Game.rooms[name].memory.upgraderparky=24} + if(Game.rooms[name].memory.warriorparkx==undefined){Game.rooms[name].memory.warriorparkx=15} + if(Game.rooms[name].memory.warriorparky==undefined){Game.rooms[name].memory.warriorparky=34} + Game.rooms[name].memory.hasbeeninited=1 + } +} +module.exports = initroom \ No newline at end of file diff --git a/main.js b/main.js index 7391a89..ea352d5 100644 --- a/main.js +++ b/main.js @@ -1,39 +1,37 @@ 'use strict'; global.Empire = require("Empire") -let roleBuilder=require('role.builder'); -let roleClaimer=require('role.claimer'); -let roleMiner=require('role.miner'); -let roleHauler=require('role.hauler') -let roleHauler2=require('role.hauler2') -let roleUpgrader=require('role.upgrader') -let roleTowerrecharger=require('role.recharger') -let runSources=require('sourceprocessing') -let roleRepairbot=require('role.repairbot') -let runTower = require('tower'); -let assignMiners=require('sproc') -let roleWarrior=require('role.warrior') -let rolenrBuilder=require('role.nrbuilder') -let rolenrMiner=require('role.nrminer') -let processSpawns=require('spawnprocessing') -let minerals=require('mineralprocessing') -let roleMiner2=require('role.miner2') -let roleHauler3=require('role.mineralhauler') -let minedproc = require('MinedMineralProc') +//let runTower = require('tower'); +//let assignMiners=require('sproc') +//let processSpawns=require('spawnprocessing') +//let minerals=require('mineralprocessing') +//let minedproc = require('MinedMineralProc') +//let runSources=require('sourceprocessing') +global.verbosity=0 module.exports.loop = function () { - console.log('---START---') + if(global.verbosity>0){ + console.log('---START---') + } for(let name in Memory.creeps) { if(!Game.creeps[name]) { delete Memory.creeps[name]; + if(global.verbosity>0){ console.log('Clearing non-existing creep memory:', name); + } } } for(let myroom of _.filter(Game.rooms, 'controller.my')) { let name = myroom.name + if(global.verbosity>0){ console.log('---'+name+'---') - runTower.tick(name); - assignMiners.tick(name) - runSources.tick(name) - minedproc.tick(name) + } + if(Game.rooms[name].memory.hasbeeninited==undefined){ + console.log('initing') + require('initroom').run(name) + } + require('tower').tick(name); + require('sproc').tick(name) // assignMiners + require('sourceprocessing').tick(name) + require('MinedMineralProc').tick(name) try{ let roomenergy = Game.rooms[name].energyAvailable let allstorage = Game.rooms[name].find(FIND_STRUCTURES, {filter: (s) => {return ( s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_STORAGE)}}) @@ -53,87 +51,26 @@ module.exports.loop = function () { Game.rooms[name].memory.storagepercent = usedstorage/mycapacity Game.rooms[name].memory.containerstoragepercent = containerusedstorage/containercapacity if(!(Game.rooms[name].memory.containerstoragepercent >-.1)){Game.rooms[name].memory.containerstoragepercent=0} + + if(global.verbosity>0){ console.log('-------') console.log('Room "'+name+'" has '+roomenergy+' energy : Using ' + usedstorage + ' of ' + mycapacity + ', ' + Game.rooms[name].memory.storagepercent * 100 + '% Storage, ' + containerusedstorage + ' of ' + containercapacity + ':' + Game.rooms[name].memory.containerstoragepercent *100+ '% in containers') + } } catch(e){} - if(Game.rooms[name].memory.CreepNum == undefined){Game.rooms[name].memory.CreepNum=0} - if(Game.rooms[name].memory.minbuildpct == undefined){Game.rooms[name].memory.minbuildpct=.5} - if(Game.rooms[name].memory.minupgradepct == undefined){Game.rooms[name].memory.minupgradepct=.5} - if(Game.rooms[name].memory.minrepairpct == undefined){Game.rooms[name].memory.minrepairpct=.5} - if(Game.rooms[name].memory.maxbuilders == undefined){ Game.rooms[name].memory.maxbuilders =1 } - if(Game.rooms[name].memory.maxnrbuilders == undefined){ Game.rooms[name].memory.maxnrbuilders =0 } - if(Game.rooms[name].memory.maxclaimers == undefined){ Game.rooms[name].memory.maxclaimers =0 } - if(Game.rooms[name].memory.maxupgraders == undefined){ Game.rooms[name].memory.maxupgraders = 2 } - if(Game.rooms[name].memory.maxminers == undefined){ Game.rooms[name].memory.maxminers = 2 } - if(Game.rooms[name].memory.maxminer2s == undefined){ Game.rooms[name].memory.maxminer2s = 0 } - if(Game.rooms[name].memory.maxnrminers == undefined){ Game.rooms[name].memory.maxnrminers = 0 } - if(Game.rooms[name].memory.maxhaulers == undefined){ Game.rooms[name].memory.maxhaulers = 2 } - if(Game.rooms[name].memory.maxhauler2s == undefined){ Game.rooms[name].memory.maxhauler2s = 1 } - if(Game.rooms[name].memory.maxhauler3s == undefined){ Game.rooms[name].memory.maxhauler3s = 0 } - if(Game.rooms[name].memory.maxwarriors == undefined){ Game.rooms[name].memory.maxwarriors = 0 } - if(Game.rooms[name].memory.maxtowerrechargers == undefined){ Game.rooms[name].memory.maxtowerrechargers = 0 } - if(Game.rooms[name].memory.maxharvesters == undefined){ Game.rooms[name].memory.maxharvesters = 0 } - if(Game.rooms[name].memory.maxharvester2s == undefined){ Game.rooms[name].memory.maxharvester2s = 0 } - if(Game.rooms[name].memory.maxrepairbots == undefined){ Game.rooms[name].memory.maxrepairbots = 0 } - if(Game.rooms[name].memory.minworkenergypct == undefined){ Game.rooms[name].memory.minworkenergypct = 0.3 } - if(Game.rooms[name].memory.builderparkx==undefined){Game.rooms[name].memory.builderparkx=24} - if(Game.rooms[name].memory.builderparky==undefined){Game.rooms[name].memory.builderparky=24} - if(Game.rooms[name].memory.hauler2parkx==undefined){Game.rooms[name].memory.hauler2parkx=24} - if(Game.rooms[name].memory.hauler2parky==undefined){Game.rooms[name].memory.hauler2parky=24} - if(Game.rooms[name].memory.upgraderparkx==undefined){Game.rooms[name].memory.upgraderparkx=24} - if(Game.rooms[name].memory.upgraderparky==undefined){Game.rooms[name].memory.upgraderparky=24} - if(Game.rooms[name].memory.warriorparkx==undefined){Game.rooms[name].memory.warriorparkx=15} - if(Game.rooms[name].memory.warriorparky==undefined){Game.rooms[name].memory.warriorparky=34} - processSpawns.tick(name) - minerals.tick(name) + require('spawnprocessing').tick(name) + require('mineralprocessing').tick(name) } let mycreeps = Game.creeps for(let mycreep in mycreeps){ try{ let creep = mycreeps[mycreep] - if(creep.memory.role == 'miner'){ - roleMiner.run(creep) - } - if(creep.memory.role=='miner2'){ - roleMiner2.run(creep) - } - if(creep.memory.role == 'claimer'){ - roleClaimer.run(creep) - } - if(creep.memory.role == 'hauler'){ - roleHauler.run(creep) - } - if(creep.memory.role == 'hauler2'){ - roleHauler2.run(creep) - } - if(creep.memory.role == 'hauler3'){ - roleHauler3.run(creep) - } - if(creep.memory.role == 'builder'){ - roleBuilder.run(creep) - } - if(creep.memory.role == 'upgrader'){ - roleUpgrader.run(creep) - } - if(creep.memory.role=='towerrecharger'){ - roleTowerrecharger.run(creep) - } - if(creep.memory.role == 'repairbot'){ - roleRepairbot.run(creep) - } - if(creep.memory.role=='warrior'){ - roleWarrior.run(creep) - } - if(creep.memory.role=='nrbuilder'){ - rolenrBuilder.run(creep) - } - if(creep.memory.role=='nrminer'){ - rolenrMiner.run(creep) - } + require('role.' + creep.memory.role).run(creep) } catch (e) { //console.log(e.toString) } } - console.log('----END---') + if(global.verbosity>0){ + console.log('----END---') + } } \ No newline at end of file diff --git a/mineralprocessing.js b/mineralprocessing.js index 2064ba9..dff8349 100644 --- a/mineralprocessing.js +++ b/mineralprocessing.js @@ -8,7 +8,9 @@ let assignMiner2s = { let myminers = _.filter(allminers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='miner')); let sourcecount = sources.length let persrc = allminers.length / sourcecount - console.log('My Assigned miner2s: ' +myminers.length + ' Max per source:' + persrc + ' Total Miner2s:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length) + if(global.verbosity>0){ + console.log('My Assigned miner2s: ' +myminers.length + ' Max per source:' + persrc + ' Total Miner2s:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length) + } if(unassignedminers.length > 0){ if(myminers.length >= persrc){ //break; diff --git a/proc.sales.js b/proc.sales.js new file mode 100644 index 0000000..179bd25 --- /dev/null +++ b/proc.sales.js @@ -0,0 +1,14 @@ +/* +Create order for energy and set price, store order id in room +if terminal has more than X in it, extend the sell order +if energy cost is below X buy it, and resell it at higher price + +Game.market.createOrder(ORDER_SELL,RESOURCE_ENERGY,PRICE,AMOUNT,ROOM) +Game.market.createOrder(ORDER_SELL,RESOURCE_ENERGY,.03,10000,'W53N52') +Game.market.extendOrder('5953e604f605574924e58ec0',10000) + + */ + +module.exports = { + +}; \ No newline at end of file diff --git a/role.builder.js b/role.builder.js index 6c2f885..ba07c58 100644 --- a/role.builder.js +++ b/role.builder.js @@ -16,7 +16,7 @@ let roleBuilder = { if(creep.memory.building) { if(creep.memory.buildsite==undefined|| Game.getObjectById(creep.memory.buildsite.id) == undefined){ - creep.memory.buildsite = Game.rooms[creep.memory.originroom].find(FIND_CONSTRUCTION_SITES)[0]; + creep.memory.buildsite = creep.pos.findClosestByRange(FIND_CONSTRUCTION_SITES); } let target = Game.getObjectById(creep.memory.buildsite.id) if(target) { diff --git a/role.claimer.js b/role.claimer.js index ab97272..ee3811b 100644 --- a/role.claimer.js +++ b/role.claimer.js @@ -18,4 +18,4 @@ let roleClaimer = { } } }; -module.exports = roleClaimer; \ No newline at end of file +module.exports = roleClaimer; diff --git a/role.nrbuilder.js b/role.nrbuilder.js index cb941ef..b946c8d 100644 --- a/role.nrbuilder.js +++ b/role.nrbuilder.js @@ -9,7 +9,7 @@ let rolenrBuilder = { creep.memory.building = true; creep.say('building'); } - if(Game.flags.nrbuild.room == creep.room){ + if(Game.flags.nrbuild.pos.isEqualTo(creep.pos) && creep.room == Game.flags.nrbuild.room){ if(creep.memory.originroom === undefined){ creep.memory.originroom = creep.room.name creep.memory.role = 'builder' diff --git a/role.nrminer.js b/role.nrminer.js index 7058015..86e4e92 100644 --- a/role.nrminer.js +++ b/role.nrminer.js @@ -1,9 +1,10 @@ let assignMiners=require('sproc') let rolenrMiner = { run: function(creep) { - if(Game.flags.nrbuild.room == creep.room){ - - if(creep.memory.destsource==undefined){ + + if(Game.flags.nrbuild.pos.isEqualTo(creep.pos) && creep.room == Game.flags.nrbuild.room){ + if(creep.memory.destsource===undefined){ + console.log("changing role from nrminer to miner") creep.memory.role='miner' assignMiners(creep.roomName) } diff --git a/sourceprocessing.js b/sourceprocessing.js index 04865d1..89819f7 100644 --- a/sourceprocessing.js +++ b/sourceprocessing.js @@ -12,7 +12,9 @@ let runSources = { let myhaulers = _.filter(allhaulers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='hauler')); let sourcecount = sources.length let persrc = allhaulers.length / sourcecount - console.log('My Assigned Haulers: ' +myhaulers.length + ' Max per source:' + persrc + ' Total Haulers:' + allhaulers.length + ' Total Sources:' + sourcecount + ' Unassigned Haulers:' + unassignedhaulers.length) + if(global.verbosity>0){ + console.log('My Assigned Haulers: ' +myhaulers.length + ' Max per source:' + persrc + ' Total Haulers:' + allhaulers.length + ' Total Sources:' + sourcecount + ' Unassigned Haulers:' + unassignedhaulers.length) + } if(unassignedhaulers.length > 0){ if(myhaulers.length < persrc){ unassignedhaulers[0].memory.destsource = source diff --git a/spawnprocessing.js b/spawnprocessing.js index 9914a56..e7ee337 100644 --- a/spawnprocessing.js +++ b/spawnprocessing.js @@ -7,8 +7,10 @@ let processSpawns = { } let energyready = Game.rooms[roomname].energyAvailable let energymax = Game.rooms[roomname].energyCapacityAvailable + if(global.verbosity>0){ console.log(Game.rooms[roomname].memory.tickssincespawn) console.log(energyready / energymax) + } if(energyready==energymax || energyready / energymax > .5 ||Game.rooms[roomname].memory.tickssincespawn>50){ Game.rooms[roomname].memory.tickssincespawn=0 let allcreeps = _.filter(Game.rooms[roomname].find(FIND_MY_CREEPS)); @@ -29,62 +31,92 @@ let processSpawns = { //console.log(allcreeps.length + " " + allbuilders.length + " " + allminers.length + " " + allhaulers.length + " " + allhauler2s.length + " " + alltowerrechargers.length + " " + allrepairbots.length + " " + allupgraders.length + " " + allwarriors.length) for(let spawn of myspawns){ if(!spawn.spawning && !spawn.memory.spawnqueued){ + if(global.verbosity>0){ console.log('WOULD SPAWN AT '+ spawn.name) + } //spawn.memory.spawnqueued=true if(Game.rooms[roomname].memory.maxminers > allminers.length){ + if(global.verbosity>0){ console.log('spawn miner') + } buildparts.tick(roomname,'miner') spawn.memory.spawnqueued=true } else if(Game.rooms[roomname].memory.maxminer2s > allminer2s.length){ + if(global.verbosity>0){ console.log('spawn miner2s') + } buildparts.tick(roomname,'miner2') spawn.memory.spawnqueued=true } else if(Game.rooms[roomname].memory.maxhaulers > allhaulers.length){ + if(global.verbosity>0){ console.log('spawn hauler') + } buildparts.tick(roomname,'hauler') spawn.memory.spawnqueued=true }else if(Game.rooms[roomname].memory.maxhauler3s > allhauler3s.length){ + if(global.verbosity>0){ console.log('spawn hauler3') + } buildparts.tick(roomname,'hauler3') spawn.memory.spawnqueued=true }else if(Game.rooms[roomname].memory.maxupgraders > allupgraders.length){ + if(global.verbosity>0){ console.log('spawn upgrader') + } buildparts.tick(roomname,'upgrader') spawn.memory.spawnqueued=true } else if(Game.rooms[roomname].memory.maxhauler2s > allhauler2s.length){ + if(global.verbosity>0){ console.log('spawn hauler2') + } buildparts.tick(roomname,'hauler2') spawn.memory.spawnqueued=true } else if(Game.rooms[roomname].memory.maxtowerrechargers > alltowerrechargers.length){ + if(global.verbosity>0){ console.log('spawn towerrecharger') + } buildparts.tick(roomname,'towerrecharger') spawn.memory.spawnqueued=true } else if(Game.rooms[roomname].memory.maxrepairbots > allrepairbots.length){ + if(global.verbosity>0){ console.log('spawn repairbot') + } buildparts.tick(roomname,'repairbot') spawn.memory.spawnqueued=true }else if(Game.rooms[roomname].memory.maxbuilders > allbuilders.length){ + if(global.verbosity>0){ console.log('spawn builder') + } buildparts.tick(roomname,'builder') spawn.memory.spawnqueued=true } else if (Game.rooms[roomname].memory.maxwarriors > allwarriors.length){ + if(global.verbosity>0){ console.log('spawn warrior') + } buildparts.tick(roomname,'warrior') } else if(Game.rooms[roomname].memory.maxclaimers > allclaimers.length){ + if(global.verbosity>0){ console.log('spawn claimer') + } buildparts.tick(roomname,'claimer') } else if(Game.rooms[roomname].memory.maxnrbuilders > allnrbuilders.length){ + if(global.verbosity>0){ console.log('spawn nrbuilder') + } buildparts.tick(roomname,'nrbuilder') } else if(Game.rooms[roomname].memory.maxnrminers > allnrminers.length){ + if(global.verbosity>0){ console.log('spawn nrminer') + } buildparts.tick(roomname,'nrminer') } else {} } else if (!spawn.spawning && spawn.memory.spawnqueued) { spawn.memory.spawnqueued=false + if(global.verbosity>0){ console.log('clearing spawn queue') + } } else if (spawn.spawning && !spawn.memory.spawnqueued){ spawn.memory.spawnqueued=true } diff --git a/sproc.js b/sproc.js index d4bf202..f052268 100644 --- a/sproc.js +++ b/sproc.js @@ -8,7 +8,9 @@ let assignMiners = { let myminers = _.filter(allminers, (creep) => (creep.memory.destsource != undefined && creep.memory.destsource.id==source.id && creep.memory.role=='miner')); let sourcecount = sources.length let persrc = allminers.length / sourcecount - console.log('My Assigned Miners: ' +myminers.length + ' Max per source:' + persrc + ' Total Miners:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length) + if(global.verbosity>0){ + console.log('My Assigned Miners: ' +myminers.length + ' Max per source:' + persrc + ' Total Miners:' + allminers.length + ' Total Sources:' + sourcecount + ' Unassigned Miners:' + unassignedminers.length) + } if(unassignedminers.length > 0){ if(myminers.length >= persrc){ //break; diff --git a/tower.js b/tower.js index 454ce26..561cbd1 100644 --- a/tower.js +++ b/tower.js @@ -34,9 +34,15 @@ var towers = { { if(closestDamagedStructure) { if(Game.rooms[roomname].memory.containerstoragepercent > .8){ + if(global.verbosity>0){ console.log("tower repairing. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent) + } tower.repair(closestDamagedStructure); - } else { console.log("tower waiting for more storage. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent)} + } else { + if(global.verbosity>0){ + console.log("tower waiting for more storage. Currently at: " + Game.rooms[roomname].memory.containerstoragepercent) + } + } } }