mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
Changes to use recharge
This commit is contained in:
parent
f2ed90049b
commit
c8d3293dde
@ -25,7 +25,7 @@ let Phase1 = {
|
|||||||
console.log(Game.rooms[room].energyAvailable + " of " + Game.rooms[room].energyCapacityAvailable)
|
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(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)
|
console.log('Spawning worker in ' + room)
|
||||||
require('proc.spawning').spawnworker(room)
|
require('proc.spawning').spawnworker(room)
|
||||||
}
|
}
|
||||||
@ -43,9 +43,11 @@ 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}}))&&(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)){
|
||||||
|
if(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")}}
|
||||||
}
|
}
|
||||||
//require('proc.market').sellEnergy(room)
|
//require('proc.market').sellEnergy(room)
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ let initroom = {
|
|||||||
minablepositions = minablepositions + this.computeSourceAccessPoints(Game.rooms[name],srcs[i])
|
minablepositions = minablepositions + this.computeSourceAccessPoints(Game.rooms[name],srcs[i])
|
||||||
//minablepositions = minablepositions + this.checkminablepositions(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
|
Game.rooms[name].memory.minablepositions = minablepositions
|
||||||
},
|
},
|
||||||
computeSourceAccessPoints: function(room, source){
|
computeSourceAccessPoints: function(room, source){
|
||||||
|
4
main.js
4
main.js
@ -3,6 +3,7 @@ global.Empire = require("Empire")
|
|||||||
let Traveler = require("Traveler")
|
let Traveler = require("Traveler")
|
||||||
global.verbosity=0
|
global.verbosity=0
|
||||||
module.exports.loop = function () {
|
module.exports.loop = function () {
|
||||||
|
console.log("----Start loop for "+ Game.time + '----')
|
||||||
let decrementcounter = Game.time % 30
|
let decrementcounter = Game.time % 30
|
||||||
for(let name in Game.rooms){
|
for(let name in Game.rooms){
|
||||||
let myroom=Game.rooms[name]
|
let myroom=Game.rooms[name]
|
||||||
@ -76,5 +77,6 @@ module.exports.loop = function () {
|
|||||||
let myroom = Game.rooms[name]
|
let myroom = Game.rooms[name]
|
||||||
if(!Game.rooms[name]){delete Memory.rooms[name]}
|
if(!Game.rooms[name]){delete Memory.rooms[name]}
|
||||||
}
|
}
|
||||||
|
console.log("----End loop for "+ Game.time +'----')
|
||||||
}
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ let buildparts = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'miner'})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time, role:'miner'})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -43,7 +43,7 @@ let buildparts = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'sourceminer'})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:'sourceminer'})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -67,7 +67,7 @@ let buildparts = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'warrior'})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:'warrior'})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -94,7 +94,7 @@ let buildparts = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:"phase" + Game.rooms[roomname].memory.phase +"worker"})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"phase" + Game.rooms[roomname].memory.phase +"worker"})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -121,7 +121,7 @@ let buildparts = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:"mover"})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"mover"})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -149,7 +149,7 @@ let buildparts = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:"nrworker"})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"nrworker"})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -171,7 +171,7 @@ let buildparts = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(roomname + ' ' + tobuild)
|
console.log(roomname + ' ' + tobuild)
|
||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'claimer'})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:'claimer'})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,23 @@ let roleMiner = {
|
|||||||
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE) {
|
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE) {
|
||||||
creep.travelTo(mysource);
|
creep.travelTo(mysource);
|
||||||
}
|
}
|
||||||
|
} else if ((creep.ticksToLive < 300 || creep.ticksToLive <= creep.memory.renewto) && (Game.rooms[creep.room.name].find(FIND_MY_SPAWNS, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>1)}})) ) {
|
||||||
|
if(creep.memory.renewto == undefined){
|
||||||
|
creep.memory.renewto = 1200
|
||||||
} else {
|
} 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) ;}});
|
if(creep.ticksToLive >= creep.memory.renewto){
|
||||||
|
delete creep.memory.renewto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
||||||
|
creep.say('renewing')
|
||||||
|
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
||||||
|
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE)
|
||||||
|
{
|
||||||
|
creep.moveTo(spawn);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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(storagetargets){
|
||||||
if(this.transferAll(creep,storagetargets) == ERR_NOT_IN_RANGE) {
|
if(this.transferAll(creep,storagetargets) == ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(storagetargets,{ignoreCreeps:ignorecreeps})
|
creep.moveTo(storagetargets,{ignoreCreeps:ignorecreeps})
|
||||||
|
@ -27,8 +27,8 @@ let mover={
|
|||||||
}
|
}
|
||||||
if(creep.memory.working){
|
if(creep.memory.working){
|
||||||
let terminaltarget = creep.room.terminal
|
let terminaltarget = creep.room.terminal
|
||||||
if(creep.pos.findClosestByPath(FIND_STRUCTURES, {filter: (s) => {return ((([STRUCTURE_SPAWN, STRUCTURE_EXTENSION, STRUCTURE_TOWER].includes(s.structureType)) && s.energy < s.energyCapacity))}})){
|
if(creep.pos.findClosestByPath(FIND_STRUCTURES, {filter: (s) => {return ((([STRUCTURE_SPAWN, STRUCTURE_EXTENSION, STRUCTURE_TOWER, STRUCTURE_LAB].includes(s.structureType)) && s.energy < s.energyCapacity))}})){
|
||||||
let spawntarget = creep.pos.findClosestByPath(FIND_STRUCTURES, {filter: (s) => {return (((s.structureType == STRUCTURE_EXTENSION || s.structureType == STRUCTURE_SPAWN || s.structureType == STRUCTURE_TOWER) && s.energy < s.energyCapacity))}});
|
let spawntarget = creep.pos.findClosestByPath(FIND_STRUCTURES, {filter: (s) => {return (((s.structureType == STRUCTURE_EXTENSION || s.structureType == STRUCTURE_SPAWN || s.structureType == STRUCTURE_TOWER|| s.structureType == STRUCTURE_LAB) && s.energy < s.energyCapacity))}});
|
||||||
if(creep.transfer(spawntarget, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
if(creep.transfer(spawntarget, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(spawntarget,{ignoreCreeps:ignorecreeps})
|
creep.moveTo(spawntarget,{ignoreCreeps:ignorecreeps})
|
||||||
}
|
}
|
||||||
@ -36,9 +36,24 @@ let mover={
|
|||||||
creep.say('Putting Energy')
|
creep.say('Putting Energy')
|
||||||
creep.travelTo(terminaltarget);
|
creep.travelTo(terminaltarget);
|
||||||
}
|
}
|
||||||
|
} else if ((creep.ticksToLive < 300 || creep.ticksToLive <= creep.memory.renewto) && (Game.rooms[creep.room.name].find(FIND_MY_SPAWNS, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>1)}})) ) {
|
||||||
|
if(creep.memory.renewto == undefined){
|
||||||
|
creep.memory.renewto = 1200
|
||||||
|
} else {
|
||||||
|
if(creep.ticksToLive >= creep.memory.renewto){
|
||||||
|
delete creep.memory.renewto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
||||||
|
creep.say('renewing')
|
||||||
|
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
||||||
|
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE)
|
||||||
|
{
|
||||||
|
creep.moveTo(spawn);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if(filllevel < creep.carryCapacity){
|
if(filllevel < creep.carryCapacity){
|
||||||
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER ) && _.sum(s.store) >= 500) ;}});
|
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER) && _.sum(s.store) >= 500) ;}});
|
||||||
if(creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
|
if(creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
|
||||||
creep.say('Getting Energy')
|
creep.say('Getting Energy')
|
||||||
creep.travelTo(storagetarget);
|
creep.travelTo(storagetarget);
|
||||||
|
@ -68,6 +68,22 @@ let Phase1Worker = {
|
|||||||
creep.moveTo(Game.rooms[creep.memory.assignedroom].controller,{ignoreCreeps:ignorecreeps})
|
creep.moveTo(Game.rooms[creep.memory.assignedroom].controller,{ignoreCreeps:ignorecreeps})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if ((creep.ticksToLive < 300 || creep.ticksToLive <= creep.memory.renewto) && (Game.rooms[creep.room.name].find(FIND_MY_SPAWNS, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>1)}})) ) {
|
||||||
|
|
||||||
|
if(creep.memory.renewto == undefined){
|
||||||
|
creep.memory.renewto = 1200
|
||||||
|
} else {
|
||||||
|
if(creep.ticksToLive >= creep.memory.renewto){
|
||||||
|
delete creep.memory.renewto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
creep.say('renewing')
|
||||||
|
console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
||||||
|
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
||||||
|
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE)
|
||||||
|
{
|
||||||
|
creep.moveTo(spawn);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>200)}});
|
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>200)}});
|
||||||
let tombstone = creep.pos.findClosestByRange(FIND_TOMBSTONES, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}});
|
let tombstone = creep.pos.findClosestByRange(FIND_TOMBSTONES, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}});
|
||||||
|
Loading…
Reference in New Issue
Block a user