Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. Famine
    3. Posts
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    Posts made by Famine

    • I think I'm having heap issues

      So I'm calling a method recursively. I do it 6 times

      Inside the method, I do a console.log of the object I'm passing back to main. It comes out fine. The next line after calling the method in main, it comes out as undefined.

      The first 5 times I do this, it works perfectly. The 6th time, it comes back undefined.

      So I change the loop...I do 5 times on one tick, and once on the next tick...works perfectly.

      Can this be a heap issue?

      posted in Help
      Famine
    • RE: Is there a way to detect enemies in a room i don't own?

      I just set a "flag" in the memory of my base room.

      so room.memory.remoteHostilesFlag = invaderCreep.ticksToLive + Game.time;

      if(Game.time > room.memory.remoteHostilesFlag) delete room.memory.remoteHostilesFlag;

      posted in Help
      Famine
    • RE: dismantle energy recovery?

      @frop ugh this reminds me of the first time I encountered my "dismantle all buildings in the room" bug

      posted in Help
      Famine
    • RE: Need some help improving my CPU usage

      I tried looking through the code, but with no comments I honestly don't know much about what's going on.

      My rooms do about 3-5 CPU per, with remote harvesting about 1 CPU per room. What I did is I went and put Game.cpu.getUsed(); everywhere...I would get the amount before the command or method and then get the CPU afterwords to find out where all my CPU was going.

      For instance, I found out that _.filter commands took more cpu than just room.find() commands. I also would fill up a spawnQueue with everything I needed, but my spawns could only do one at a time, so now my spawnQueue calculations end as soon as I've found one creep that needs to be spawned and it can be spawned.

      my Creeps were taking up the mass majority of my CPU though. Harvesters would try to harvest if there was no energy or it wasn't in range. Carts would attempt to transfer if they weren't in range. All my creeps now use if(creep.pos.inRangeTo(source, 1)) creep.harvest(source) instead of the error checking it did before that would call the command everytime.

      Good luck!

      posted in Help
      Famine
    • RE: Inter room move sequence description

      I've never used a portal, but from what I've seen watching other creeps, it works the same as the room method.

      If you land on a room edge, you're transported the next tick to the other room edge at the same x/y coordinate you were when you left. If you were on the east room edge at (49,24), you would appear at (0,24) on the next tick. If you don't move off the map edge, you will go back to (49,24). You can also move along the edge. If you were at (0,24), you can move to (0,23), but it will transport you to (49,23) in the next room after you moved.

      posted in Help
      Famine
    • RE: Harvesting from multiple sources within a room

      @nanocraft in your else, your if(creep.carry.energy = creep.carryCapacity) is incorrect. It needs to be 2 or 3 equal signs, otherwise you're attempting to assign your carryCapacity to creep.carry.energy.

      You're also placing error code of your move command into targets and prospects, but not using that error code.

      As for why it's not working, I think your var sources = creep.room.find(FIND_SOURCES); command is limited by scope. It's under the if statement, and I believe that the var will become undefined after that if statement executes. I'm unsure, because I don't use var, I use let, so maybe var is global?

      Another thing is that if you call room.find(FIND_SOURCES), sometimes the order in which the sources appear in the array is not always the same...sometimes the source you receive might be rearranged.

      posted in Help
      Famine
    • RE: findClosestByPath/Range from a list of items in memory

      if you store all your objects in memory, you can use findPath for arrays.

      So let's say you do targets = room.find(FIND_CONSTRUCTION_SITES);

      targets is now an array. You can do findClosestByPath(targets) instead of doing the call again, because findClosestByPath also works for arrays

      posted in Help
      Famine
    • RE: Transferring energy to storage

      The reason that containers/storage/terminals are different is because they can store minerals. Extensions and spawns and towers can only store energy, so there's no need for the store object.

      For store, store[RESOURCE_ENERGY] is always defined, 0 if it's empty. If the other minerals/compounds aren't present, those values are undefined. So if there's no lemergium, then store[RESOURCE_LEMERGIUM] would be undefined

      posted in Help
      Famine
    • RE: Harvesting from multiple sources within a room

      It's better not to worry about assigning sources directly with your code.

      My code will filter an array based on the source id. The miners will have the source id in their memory.

      so you have an array of miners myMiners = []; You place your miner creeps in them, filtering Game.creeps for the source id.

      For my code, I just have one miner per source...so if there isn't a miner, it'll spawn one.

          for(let sourceIndex in Game.rooms[homebase].memory.sources){
              myMiners = _.filter(Game.creeps, i => i.memory.sourceId === sourceIndex);
              if(myMiners.length < 1){
                  Game.spawns[0].spawnCreep(minerBody, randomName, memory: {sourceId: 
                           sourceIndex})
              }
          }
      
      posted in Help
      Famine