fixed errors in state tracking and removed excess logging

This commit is contained in:
paradizelost 2016-09-15 01:40:56 -05:00
parent 52d492863d
commit d482d39d16
5 changed files with 27 additions and 8 deletions

View File

@ -13,8 +13,6 @@ var roleBuilder = {
usedstorage+=_.sum(allcontainers[i].store)
mycapacity+=allcontainers[i].storeCapacity
}
console.log(usedstorage + " " + mycapacity)
var storagepercent = usedstorage/mycapacity
var ttl = creep.ticksToLive

View File

@ -1,9 +1,21 @@
var roleHauler = {
run: function(creep) {
var sources = creep.room.find(FIND_DROPPED_ENERGY );
if(creep.pickup(sources[0]) == ERR_NOT_IN_RANGE && creep.carryCapacity/2 > creep.carry.energy) {
if(creep.memory.hauling == undefined){creep.memory.hauling=false}
if(creep.memory.hauling && creep.carry.energy == 0) {
creep.memory.hauling = false;
creep.say('gathering');
}
if(!creep.memory.hauling && creep.carry.energy == creep.carryCapacity) {
creep.memory.hauling = true;
creep.say('hauling');
}
var sources = creep.room.find(FIND_DROPPED_ENERGY );
if(creep.memory.hauling==false){
if(creep.pickup(sources[0]) == ERR_NOT_IN_RANGE && creep.carryCapacity/2 > creep.carry.energy) {
creep.moveTo(sources[0]);
} else if(sources != undefined )
}
}else {
if(sources != undefined )
{ var spawntargets = creep.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return ((structure.structureType == STRUCTURE_EXTENSION || structure.structureType == STRUCTURE_SPAWN) &&structure.energy < structure.energyCapacity)
@ -31,6 +43,7 @@ var roleHauler = {
creep.say("NS,NT")
creep.moveTo(Game.flags.Flag1);
}
}
},
spawn: function(){
var myrole='hauler';

View File

@ -2,6 +2,16 @@
/** @param {Creep} creep **/
run: function(creep) {
if(creep.memory.hauling == undefined){creep.memory.hauling=false}
if(creep.memory.hauling && creep.carry.energy == 0) {
creep.memory.hauling = false;
creep.say('gathering');
}
if(!creep.memory.hauling && creep.carry.energy == creep.carryCapacity) {
creep.memory.hauling = true;
creep.say('hauling');
}
if(creep.memory.hauling==false){
if(creep.carryCapacity > creep.carry.energy){
var container = creep.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => {
@ -27,6 +37,7 @@
creep.moveTo(Game.flags.Flag1);
}
}
}
},
spawn: function(){
var myrole='hauler2';

View File

@ -11,7 +11,6 @@ var roleRepairbot = {
creep.memory.repairing = true;
creep.say('repairing');
}
console.log(creep.name)
if(creep.memory.repairing==false){
var container = creep.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => {

View File

@ -25,8 +25,6 @@ var towers = {
usedstorage+=_.sum(allcontainers[i].store)
mycapacity+=allcontainers[i].storeCapacity
}
console.log(usedstorage + " " + mycapacity)
var storagepercent = usedstorage/mycapacity
var importantstructures = tower.room.find(FIND_STRUCTURES, {
filter: (structure) => {