PathFinder ignores 255 cost for one-step paths



  • Try to do Room.findPath with a costmatrix full of 255. It should not find any paths. Instead, it finds no paths over length one, and is happy to return one-step paths (for origins and destinations that are adjacent).

     

    Test cases (should log two empty paths):

     

    var room = Game.spawns[Object.keys(Game.spawns)[0]].room;
    var src = new RoomPosition(3,17,room.name);
    var dst = new RoomPosition(4,17,room.name);
    var path = src.findPathTo(dst,{costCallback:function (foo,bar){
    for(var x=0; x<50; x++) {
    for(var y=0; y<50; y++) {
    bar.set(x,y,255);
    }
    }
    return bar;
    }});
    console.log(JSON.stringify(path));
    dst = new RoomPosition(5,17,room.name);
    path = src.findPathTo(dst,{costCallback:function (foo,bar){
    for(var x=0; x<50; x++) {
    for(var y=0; y<50; y++) {
    bar.set(x,y,255);
    }
    }
    return bar;
    }});
    console.log(JSON.stringify(path));



  • Can confirm and I am also interested in why it's behaving like this. As it is right now it seems to completely ignore the costmatrix for adjacent tiles.



  • nihilrex suggests that there is an exception case in findPath for adjacent destinations, and PathFinder doesn't even get called in that case.