Game.map.protectionLevel(roomName) or .availability(roomName)



  • I am in a novice area right now and it is shaped a little bit odd in that it makes it difficult to get from one side of the novice area to the other without going all the way around the outside of the novice area in the highway rooms. When I try to tell a creep to move to a room on the other side, it attempts to move through rooms that are not accessible because of the novice area walls and the creep just gets stuck.

    I know there is a routeCallback that can be used to avoid or prefer certain rooms, but I can't find a way for the code to know whether or not a room is in a novice area or not. I originally thought Game.map.isRoomAvailable was the answer but i guess that is not the intended purpose of that function.

    I also know you can tell if a wall is a novice wall by checking that it doesnt have a .hits value, but this only kind of helps in the immediate room, it doesnt let you path through multiple rooms optimally. The UI has a timer showing for the novice walls but I cannot seem to access that timer value.

    Someone sent me to this post:

    https://screeps.com/forum/topic/1930/insufficient-data-on-novice-respawn-areas-to-effectively-run-fully-automated-code

    where someone says there is a .ticksToLive property on the wall, but there is no such property (maybe it was removed), so there is no way for the code to determine when a wall will come down. Even if this property did exist or if we could access the decay timer, there is still no way to determine which side of the wall i'm on.

    It would be really nice to have a new function like:

    Game.map.protectionLevel(roomName) that returns values like the following (or similar):

    {type: "normal"}
    {type: "novice", endDate: 1519073582938}
    {type: "respawn", endDate: 1519073582938}
    

    Where endDate is a value similar to that returned by Date.now()

    Could also roll the Game.map.isRoomAvailable functionality into it and have it be Game.map.availability(roomName) with the additional return value:

    {type: "unavailable"}
    

    This would allow us to use this feature in our route callbacks and make it so we can path around and inside of these novice zones.

    I suppose there would also be constants

    AVAILABILITY_NORMAL: "normal",
    AVAILABILITY_NOVICE: "novice",
    AVAILABILITY_RESPAWN: "respawn",
    AVAILABILITY_UNAVAILABLE: "unavailable"
    

    I would image that if this were implemented, future types of rooms would be easily added as an additional return value.

    EDIT: The only issue i see with this right now is that highway rooms adjacent to novice rooms would both be "novice" and "normal"... Perhaps each room could have multiple types if necessary. I'm not sure on that one.

    👍


  • For illustrative purposes:

    • Blue lines show more optimal paths that would be taken without novice walls.
    • Purple lines show the only way to get there given the novice walls. 0_1519075113638_Screen Shot 2018-02-19 at 2.12.50 PM.png


  • Also want to note that as my temporary work around I just manually typed in the 60 room names that surround my novice area so that i can tell my pathing to avoid them. If/when i get killed and respawn in a different respawn zone i'm going to have to do that again. Let me tell you nothing makes you want to play a game more than manually typing in 60 room names with the knowledge that you may have to do it again in the future.

    😂


  • Uhm if I remember correctly the Pathfinder for multi room paths works sorta in two steps:

    • It looks up the rooms which ones are connected by design
      (This ignores the fact of blocked transition tiles since those don't sever the link)

    • Create a in-room path to the next transition tile

    That is the reason why your creeps get stuck...
    But yes currently there is no "direct" information on a rooms status and you have to use context to figure it out by your self.
    This is something that should be addressed with proper fields some day.

    BTW. Try flags to blacklist rooms 😉



  • @mrfaul Yes that is how it works, but there is also a roomCallback or routeCallback depending on which function you use so that you can do things like tell the pathfinder to avoid certain rooms or to prefer highway rooms and things like that. I know WHY my creeps are getting stuck, i'm just asking for a way to solve that problem in my code, and not have to manually type out room names for dozens and dozens of rooms when there is a novice/respawn area. Manually adding flags to 60 rooms is not a fun solution either, and will still need to be redone every time you spawn into a new respawn zone.

    As a side note it would be nice if the max value of the maxRooms option was increased. The longer purple arrow in that picture i shared goes through more than 16 rooms which means no path can be found. I'll have to do some kind of multi stage pathing to get that far for now but it would be cool if the maxRooms option could go higher instead. If using Game.map.findRoute to only allow rooms along the optimal room path it doesn't use an unreasonable amount of CPU to path that far considering the distance.

    👍