bug in findClosest



  • var closestEmpty = creep.pos.findClosest(FIND_MY_STRUCTURES, {
                       filter: function(object){
                           if(object.structureType != STRUCTURE_EXTENSION ) {
                               return false;
                           }
                           if(object.energy == object.energyCapacity) {
                               return false;
                           }
                           return true;
                       } 
                    });
    
    

    When this code runs, if the extension is only accessible from above, then even if the creep is standing next to the extension, a different extension will be found to be closest.

    If the extension is available from a different direction, but it would require travelling through swamp for instance, even if the creep is standing directly next to and above the empty extension, the longer path around can/will be used, and a different extension will be found to be the closest one.



  • I have the same issue. For me it seems to happen with extensions that are directly north of a wall or other extension.

    It results in a creep going back and forth on 2 adjacent positions (and thus being stuck).



  • E.g. W2N8 extension at position 35,16


  • Dev Team

    Could you please make a reproducible scenario of this in the simulation room?