access points



  • Hi guys,

     

    Very new to the game but haven't had any luck finding it on the forums.

    Is there a method that tells you how many access points there are for a source/mineral and if so, if there's anything blocking it? By access points i mean how many creeps can harvest a source at the exact same time.

    Thanks,

    Primoz

     

    bonus question: Is there a function to get pathing distance between two targets?



  • Access points: there is no function that does that, but I'm sure playing around with the Map API you can get that info yourself. But tbh, that info isn't that useful lateron anyway since you'll mostly just send one creep with 5 WORK to a source and be done with it. And there is always at least one access point, ofc..

    Pathing distance: again, no function that does just that, but you can just do PathFinder.search and then look at the results .path property, counting it's elements.

     



  • This is what I have been using for sources. Can be important at low controller level.

     

    accessPoints: function (room, pos)
    {
    var accessPoints = 0;
    if (room.lookForAt(LOOK_TERRAIN, pos.x+1, pos.y) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x+1, pos.y+1) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x+1, pos.y-1) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x-1, pos.y) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x-1, pos.y+1) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x-1, pos.y-1) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x, pos.y+1) != "wall") {
    accessPoints = accessPoints+1;
    }
    if (room.lookForAt(LOOK_TERRAIN, pos.x, pos.y-1) != "wall") {
    accessPoints = accessPoints+1;
    }
    return accessPoints;
    },

     

    Yes there are several function to find distance between two targets. Cehck out http://support.screeps.com/hc/en-us/articles/207023879-PathFinder 

    By yes I mean you first find the path then check its length. Need to decide whether just doing a trigonometric distance is good enough.