fix: refactor tile checks in pathfinding