Navigation

    forum

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

    4nytime

    @4nytime

    18
    Posts
    1820
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    4nytime Follow

    Posts made by 4nytime

    • RE: How to determine CPU usage

      So I ran the profiler and I find the result quite interesting. Most of the CPU usage is indeed pathfinding and creep.moveTo(). Seems I will start working on caching paths in memory now. Thanks for the help!

      0_1706386475800_profiler_data.JPG

      posted in Help
      4nytime
    • RE: Bug Report: Creeps going to wrong room through creeps.moveTo

      So basically you are saying that the path rout via the other room has cheaper movement cost? It kind of looks like the creep is unable to make a decision where to move. Ironically it just stops in the other room and doesn't move anymore, not finding any correct route. In the second case the swamp movement cost hast to be blocking the creep movement. I will try maxRooms: 1 and see if it solves the problem. I also included the fix for the creep to go back to its target room when it enters an incorrect room. Maybe a pathfinding cost matrix could be of further help..

      posted in Technical Issues and Bugs
      4nytime
    • RE: Bug Report: Creeps going to wrong room through creeps.moveTo

      Found some more cases in which this issue arises. Again I made a screenshot. This time the way was blocked by a swamp, so the creep just decided to go to the next room instead of crossing the swamp, lol. It's really tedious watching something like this happen so frequently.

      0_1706317717393_screeps_swamp.JPG

      posted in Technical Issues and Bugs
      4nytime
    • How to determine CPU usage

      I just recently started playing screeps and now I am running into the problem of CPU limit. I expanded to a second room and now the CPU sometimes hits over 30, even 40 per tick. Probably there are a lot more creeps to process being around ~30 Creeps in total. What I understand is that pathfinding and maybe also filtering use a lot of CPU. Probably that's quite high CPU cost filtering multiple times through all the creeps to determine which Creep lives in which room... and so on. Does anybody have a solution how to identify where a high CPU usage actually comes from, so I can improve the code.

      posted in Help
      4nytime
    • RE: How to modify Objects in memory

      It seems I found a solution. Now I am just directly accessing memory at a specific index. It's possible to simply write memory.roomData[index] = some_data; and it will create a new object index at that position.

      posted in Help
      4nytime
    • Bug Report: Creeps going to wrong room through creeps.moveTo

      I was trying to introduce some remote harvesting as this issue occured: the creeps were going into a wrong room other than specified in the creep.moveTo function. I immediately thought this might have to do something with wrong indexing as the room is exactly one coordinate off the original target room.

      Another possibility could be that the creeps pathfinding led it onto the exit field because the neighboring room has a very thin connection leading along the room exit.

      • The creep was moving to a room different to what was given in the MoveTo function
      • happened on shard 3 room W54 S48, neighbor room W54 S59
       run: function(creep) {      
              
              if (creep.room.name != creep.memory.home) {
                  if (creep.pos.x == 0 || creep.pos.x == 49 || creep.pos.y == 0 || creep.pos.y == 49) {
                      creep.moveTo(new RoomPosition(25, 25, creep.room.name));
                  }
                  var distantSources = creep.room.find(FIND_SOURCES);
                  if (distantSources.length > 0) {
                      if(creep.harvest(distantSources[0]) == ERR_NOT_IN_RANGE) {
                          creep.moveTo(distantSources[0], {visualizePathStyle: {stroke: '#ffaa00'}});
                      }
                      else {
                          creep.drop(RESOURCE_ENERGY, creep.store.getUsedCapacity(RESOURCE_ENERGY));
                          creep.say('⛏️');
                      }
                  }    
              }
              else {
                  creep.moveTo(new RoomPosition(25, 25, creep.memory.roomId), {visualizePathStyle: {stroke: '#ffaa00'}});        
              }
      } 
      

      0_1706026144394_screeps01.JPG

      posted in Technical Issues and Bugs
      4nytime
    • RE: How to modify Objects in memory

      Thanks Xenofix for the reply. Yeah, as you can see I was working on a script form a scout unit that goes into neighboring rooms to store their room names and sources. So the initial problem was how to combine the existing stored data with the newly accquired data from a new room and I had some trouble figuring that out. Maybe that could use some reworking to only store source Ids as an array. Actually I wanted to store the room data as an array containing arrays (Array of Arrays) so I can access roomData[index].sources[index].id and so on.

      posted in Help
      4nytime
    • How to modify Objects in memory

      I am trying to add data to an existing memory Object but can't get it to work. From what I know screeps stores objects in memory rather than arrays.However, also the normal object methods like .push() don't work for adding new entries to the object. Now I am trying to assign the existing memory to an object variable, maybe that will work. Does anyone know how this is supposed to be done? Code:

      if (creep.room.memory.isVisited == false){
                  console.log("in new room");
                  var roomSources = creep.room.find(FIND_SOURCES);
                  var roomData = {remoteRoom: creep.room.name, sources: roomSources};
                  var existingData = Object.assign(Game.rooms[creep.memory.home].memory.roomData);
                  existingData.push(roomData);
                  Game.rooms[creep.room.home].memory.roomData = existingData;
      }
      posted in Help
      4nytime