Thanks for your help.
findClosestByPath takes either a number or array. The number parameter is a FIND_?? constant. From API reference I am passing one of
FIND_EXIT_TOP: 1, FIND_EXIT_RIGHT: 3, FIND_EXIT_BOTTOM: 5, FIND_EXIT_LEFT: 7,
I am actually scouting a source in a remote room to see if it is economic to harvest so I do not necessarily have access to a room object. In fact, here I am creating a function to calculate the exact distance between any two points. Hence I really want to only use RoomPosition and Map methods.
The code works mostly but for this one source object, both findClosestByPath and findClosestByRange seem to be failing. Ok, I will spend some more time debugging the code and maybe the problem will go away.