Avoid SourceKeepers in `moveTo`



  • I'm still trying to figure out an effective way on how to integrate a strategy into the moveTo command on how to avoid the sourcekeepers. Do you guys have any suggestions and ideas? You don't need to expose your super-effective and top secret code, just basic ideas would already be enough. I tried to work with avoids, but these still seem quite buggy (at least it did not work for me reliably).



  • Use avoid parameter of the Room.find command. moveTo uses the same command internally.

    var _ = require('lodash');
    var avoidPosArray= [
    {0,1}
    {12,3}
    ]
    //avoid wants position objects, map our source array
    avoidPosArray = _.map(avoidPosArray, function(o) {return room.getPositionAt(o.x, o.y);});
    
    avoidPosArray.push(KnownSourceKeeper.pos);
    
    Urist.moveTo(room.getPositionAt(12,12), {avoid: avoidPosArray});
    

    Something like this will work - not of this code is tested - wrote it from memory into this edito.



  • Sorry - it's the room.findPath, not room.find command - docs are here - http://support.screeps.com/hc/en-us/articles/203079011-Room#findPath
    these options also work with moveTo command.



  • I already tried exactly this, but it is not working for me. Also this seems like quite a huge overhead 😕



  • Avoid is definetely working - I was using it myself before steal^H^H^H^H^Hwriting a pathfinder that can give custom weighs to squares.
    Are you sure that you've provided the command correct array of RoomPosition objects? Also is the target square actually reachable with these avoid squares? Also it's not enough to avoid just the square SK is standing on - you'll have to avoid all the squares in 7x7 area.



  • Actually, since the method signature of the original function is a bit messy, my wrapper class handed over the parameters in a faulty manner for one of the cases. It's working now.