Repository: PokemonGoF/PokemonGo-Bot

Issue:
Having difficulty walking to XXXX

### Expected Behavior

When walking to next Pokestop the bot should spin the stop

### Actual Behavior

Stop does not spin, message in log shows "Having difficulty walking to XXXX", bot continues to walk buddy and incubate eggs

### Your FULL config.json (remove your username, password, gmapkey and any other private info)
{
    "websocket_server": false,
    "heartbeat_threshold": 10,
    "enable_social": true,
    "check_niantic_api": true,
     "solve_captcha": false,
     "live_config_update": {
      "enabled": false,
      "tasks_only": false
    },
       "tasks": [
        {
            "type": "TelegramTask",
            "config": {
                "enabled": false,
                "master": null,
                "password": null,
                "// old syntax, still supported: alert_catch": [
                    "all"
                ],
                "// new syntax:": {},
                "alert_catch": {
                    "all": {
                        "operator": "and",
                        "cp": 1300,
                        "iv": 0.95
                    },
                    "Snorlax": {
                        "operator": "or",
                        "cp": 900,
                        "iv": 0.9
                    }
                }
            }
        },
        {
            "type": "DiscordTask",
            "config": {
                "enabled": false,
                "master": null,
                "// old syntax, still supported: alert_catch": [
                    "all"
                ],
                "// new syntax:": {},
                "alert_catch": {
                    "all": {
                        "operator": "and",
                        "cp": 1300,
                        "iv": 0.95
                    },
                    "Snorlax": {
                        "operator": "or",
                        "cp": 900,
                        "iv": 0.9
                    }
                }
            }
        },
      {
        "//NOTE: This task MUST be placed on the top of task list": {},
        "type": "RandomAlivePause",
        "config": {
          "enabled": false,
          "min_duration": "00:00:10",
          "max_duration": "00:10:00",
          "min_interval": "00:05:00",
          "max_interval": "01:30:00"
        }
      },
      {
        "type": "HandleSoftBan"
      },
      {
        "type": "RandomPause",
        "config": {
          "enabled": false,
          "min_duration": "00:00:10",
          "max_duration": "00:10:00",
          "min_interval": "00:10:00",
          "max_interval": "02:00:00"
        }
      },
      {
        "type": "CompleteTutorial",
        "config": {
          "enabled": false,
          "// set a name": "",
          "nickname": "",
          "// 0 = No Team, 1 = Blue, 2 = Red, 3 = Yellow": "",
          "team": 2
        }
      },
      {
        "type": "CollectLevelUpReward",
        "config": {
          "collect_reward": true,
          "level_limit": -1
        }
      },
        {
           "type": "BuddyPokemon",
            "config": {
                "enabled": true,
                "buddy_list": "dratini, larvitar, chansey, heracross, snorlax, lapras, rhyhorn",
                "best_in_family": true,
                "// candy_limit = 0 means no limit, so it will never change current buddy": {},
                "candy_limit": 25,
                "candy_limit_absolute": 0,
                "// force_first_change = true will always change buddy at start removing current one": {},
                "force_first_change": false,
                "buddy_change_wait_min": 3,
                "buddy_change_wait_max": 5,
                "min_interval": 120
            }
        },
        {
        "type": "IncubateEggs",
        "config": {
          "enabled": true,
          "infinite_longer_eggs_first": false,
          "breakable_longer_eggs_first": true,
          "min_interval": 120,
         "infinite": [2,5],
         "breakable": [10]
        }
      },
      {
        "type": "UpdateLiveStats",
        "config": {
          "enabled": true,
          "min_interval": 139,
          "stats": ["uptime", "km_walked", "xp_earned", "xp_per_hour", "stardust_earned", "level_completion", "highest_cp_pokemon", "most_perfect_pokemon"],
          "terminal_log": true,
          "terminal_title": true
        }
      },
      {
        "type": "UpdateLiveInventory",
        "config": {
          "enabled": true,
          "min_interval": 205,
          "show_all_multiple_lines": false,
          "items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg", "incense"]
        }
      },
        {
            "type": "UpdateHashStats",
            "config": {
                "enabled": true,
                "min_interval": 60,
                "stats" : ["period", "remaining", "maximum", "expiration"]
            }
        },
         {
        "type": "ShowBestPokemon",
        "config": {
          "enabled": true,
          "min_interval": 300,
          "amount": 10,
          "order_by": "cp",
          "info_to_show": ["cp", "ivcp", "dps", "hp"]
        }
      },
      {
        "type": "TransferPokemon",
        "config": {
          "enabled": true,
          "min_free_slot": 200,
          "transfer_wait_min": 3,
          "transfer_wait_max": 5
        }
      },
      {
        "type": "NicknamePokemon",
        "config": {
          "enabled": true,
          "nickname_above_iv": 0.8,
          "nickname_template": "{iv_pct}_{iv_ads}",
          "nickname_wait_min": 3,
          "nickname_wait_max": 5
        }
      },
      {
         "type": "EvolvePokemon",
        "config": {
          "enabled": true,
           "evolve_list": "all",
            "donot_evolve_list": "Magikarp, Chansey, Rhyhorn, Dragonair, Dratini, Larvitar, Pupitar",
            
          "first_evolve_by": "iv",
          "evolve_above_cp": 0,
          "evolve_above_iv": 0.9,
          "logic": "and",
          "min_evolve_speed": 25,
          "max_evolve_speed": 30,
          "use_lucky_egg": false
        }
      },
      {
        "type": "UseIncense",
        "config": {
          "use_incense": true,
          "use_order": [
            "ordinary",
            "spicy",
            "cool",
            "floral" 
          ]
        }
      },
      {
        "type": "RecycleItems",
        "config": {
          "enabled": true,
          "min_empty_space": 15,
          "max_balls_keep": 150,
          "max_potions_keep": 75,
          "max_berries_keep": 50,
          "max_revives_keep": 25,
          "item_filter": {
            "Pokeball":       { "keep" : 100 },
            "Potion":         { "keep" : 10 },
            "Super Potion":   { "keep" : 20 },
            "Hyper Potion":   { "keep" : 30 },
            "Revive":         { "keep" : 25 },
            "Razz Berry":     { "keep" : 50 }
          },
          "recycle_wait_min": 3,
          "recycle_wait_max": 5,
          "recycle_force": true,
          "recycle_force_min": "00:01:00",
          "recycle_force_max": "00:05:00"
        }
      },
       {
            "type": "CatchLimiter",
            "config": {
                "enabled": true,
                "min_balls": 20,
                "duration": 15
            }
        },
         {
        "type": "CatchPokemon",
        "config": {
          "enabled": true,
          "catch_visible_pokemon": true,
          "catch_lured_pokemon": true,
          "min_ultraball_to_keep": 5,
          "berry_threshold": 0.35,
          "use_pinap_on_vip": true,
          "vip_berry_threshold": 0.9,
          "treat_unseen_as_vip": true,
          "daily_catch_limit": 800,
          "vanish_settings": {
            "consecutive_vanish_limit": 10,
            "rest_duration_min": "02:00:00",
            "rest_duration_max": "04:00:00"
          },
          "catch_throw_parameters": {
            "excellent_rate": 0.1,
            "great_rate": 0.5,
            "nice_rate": 0.3,
            "normal_rate": 0.1,
            "spin_success_rate" : 0.6,
            "hit_rate": 0.75
          },
          "catch_simulation": {
            "flee_count": 3,
            "flee_duration": 2,
            "catch_wait_min": 3,
            "catch_wait_max": 6,
            "berry_wait_min": 3,
            "berry_wait_max": 5,
            "changeball_wait_min": 3,
            "changeball_wait_max": 5,
            "newtodex_wait_min": 20, 
            "newtodex_wait_max": 30
          }
        }
      },
      {
        "type": "SpinFort",
        "config": {
          "enabled": true,
          "spin_wait_min": 3,
          "spin_wait_max": 5,
          "daily_spin_limit": 1900
        }
      },
      { "type": "UpdateWebInventory",
        "config": {
          "enabled": true
        }
      },  
      {
            "type": "PokemonHunter",
            "config": {
                "enabled": false,
                "max_distance": 1500,
                "hunt_all": false,
                "hunt_vip": true,
                "hunt_pokedex": true,
                "lock_on_target": false
            }
        },
      {
        "type": "MoveToFort",
        "config": {
          "enabled": true,
          "lure_attraction": true,
          "lure_max_distance": 2000,
          "walker": "StepWalker",
          "log_interval": 5
        }
      },
      {
        "type": "FollowSpiral",
        "config": {
          "enabled": true,
          "diameter": 4,
          "step_size": 70
        }
      }
    ],
    "map_object_cache_time": 5,
    "forts": {
      "avoid_circles": true,
      "max_circle_size": 50,
      "cache_recent_forts": true
    },
    "pokemon_bag": {
      "// if 'show_at_start' is true, it will log all the pokemons in the bag (not eggs) at bot start": {},
      "show_at_start": true,
      "// if 'show_count' is true, it will show the amount of each pokemon (minimum 1)": {},
      "show_count": false,
      "// if 'show_candies' is true, it will show the amount of candies for each pokemon": {},
      "show_candies": true,
      "// 'pokemon_info' parameter define which info to show for each pokemon": {},
      "// the available options are": {},
      "// ['cp', 'iv_ads', 'iv_pct', 'ivcp', 'ncp', 'level', 'hp', 'moveset', 'dps']": {},
      "pokemon_info": ["cp", "iv_pct"]
    },
    "walk_max": 4.16,
    "walk_min": 2.16,
    "alt_min": 500,
    "alt_max": 1000,
    "sleep_schedule": {
      "enabled": true,
      "enable_reminder": false,
      "reminder_interval": 600,
      "entries": [
         {
          "enabled": true,
          "time": "00:30",
          "duration": "2:30",
          "time_random_offset": "00:30",
          "duration_random_offset": "00:30",
          "wake_up_at_location": ""
        },
        {
          "enabled": true,
          "time": "05:00",
          "duration": "4:00",
          "time_random_offset": "00:30",
          "duration_random_offset": "00:30",
          "wake_up_at_location": ""
        },
        {
          "enabled": true,
          "time": "11:30",
          "duration": "3:00",
          "time_random_offset": "00:30",
          "duration_random_offset": "00:30",
          "wake_up_at_location": ""
        },
        {
          "enabled": true,
          "time": "16:30",
          "duration": "3:30",
          "time_random_offset": "00:30",
          "duration_random_offset": "00:30",
          "wake_up_at_location": ""
        },
        {
          "enabled": true,
          "time": "21:00",
          "duration": "1:30",
          "time_random_offset": "01:00",
          "duration_random_offset": "00:30",
          "wake_up_at_location": ""
        }
      ]
    },
    "gps_default_altitude": 8.0,
    "replicate_gps_xy_noise": false,
    "replicate_gps_z_noise": false,
    "gps_xy_noise_range": 0.000125,
    "gps_z_noise_range": 12.5,
    "debug": false,
    "test": false,
    "walker_limit_output": false,
    "health_record": true,
    "location_cache": false,
    "distance_unit": "km",
    "reconnecting_timeout": 15,
    "logging": {
      "color": true,
      "show_datetime": true,
      "show_process_name": true,
      "show_log_level": true,
      "show_thread_name": false
    },
    "catch": {
      "any": {"candy_threshold" : 500 ,"catch_above_cp": 0, "catch_above_iv": 0.85, "logic": "and"},
      "// Example of always catching Rattata:": {},
      
      "Mareep": { "always_catch" : true },
      "Flaaffy": { "always_catch" : true },

      "Tauros": { "always_catch" : true },
      "Kangaskhan": { "always_catch" : true },
      "Heracross": { "always_catch" : true },
      "Corsola": { "always_catch" : true },
      "Farfetch'd": { "always_catch" : true },
      
      "Togetic": { "always_catch" : true },
      "Hitmontop": { "always_catch" : true },
      "Unown": { "always_catch" : true },
      "Arcanine": { "always_catch" : true },
      "Growlithe": { "always_catch" : true },
      "Dragonite": { "always_catch" : true },
      "Dragonair": { "always_catch" : true },
      "Dratini": { "always_catch" : true },
      "Wartorle": { "always_catch" : true },
      "Blastoise": { "always_catch" : true },
      "Pikachu": { "always_catch" : true },
      "Raichu": { "always_catch" : true },
      "Ivysaur": { "always_catch" : true },
      "Venusaur": { "always_catch" : true },
      "Charmeleon": { "always_catch" : true },
      "Charizard": { "always_catch" : true },
      "Lapras": { "always_catch" : true },
      "Exeggcute": { "always_catch" : true },
      "Rhyhorn": { "always_catch" : true },
      "Rhydon": { "always_catch" : true },
      "Exeggutor": { "always_catch" : true },
      "Chansey": { "always_catch" : true },
      "Magikarp": { "always_catch" : true },
      "Gyarados": { "always_catch" : true },
      "Aerodactyl": { "always_catch" : true },
      "Mew": { "always_catch" : true },
      "Ditto": { "always_catch" : true },
      "Mewtwo": { "always_catch" : true },
      "Snorlax": { "always_catch" : true },  
      "Porygon": { "always_catch" : true },   
      "Machoke": { "always_catch" : true },  
      "Machamp": { "always_catch" : true },   
      "Tyranitar": { "always_catch" : true },
      "Blissey": { "always_catch" : true },
      "Scizor": { "always_catch" : true },
      "Farfetch'd": { "always_catch" : true },
      "Espeon": { "always_catch" : true },
      "Ursaring": { "always_catch" : true },
      "Feraligatr": { "always_catch" : true },
      "Typhlosion": { "always_catch" : true },
      "Ampharos": { "always_catch" : true },
      "Porygon2": { "always_catch" : true },
      "Unown" : { "always_catch" : true }
    },
    
    
    "release": {
      
      "any": {"keep_best_iv": 2, "keep_best_cp": 1},
      
      "// any": {"release_below_cp": 0, "release_below_iv": 0.9, "logic": "or"},
      
      "Arcanine": { "never_release" : true },
      "Dragonite": { "never_release" : true },
      "Lapras": { "never_release" : true },
      "Muk": { "never_release" : true },
      "Exeggutor": { "never_release" : true },
      "Chansey": { "never_release" : true },
      "Gyarados": { "never_release" : true },
      "Aerodactyl": { "never_release" : true },
      "Farfetch'd": { "never_release" : true },
      "Mew": { "never_release" : true },
      "Mewtwo": { "never_release" : true },
      "Snorlax": { "never_release" : true },
      "Machamp": {"never_release": true},
      "Articuno": {"never_release": true},
      "Zapdos": {"never_release": true},
      "Moltres": {"never_release": true},
      "Tyranitar": {"never_release": true},
      "Blissey": {"never_release": true},
      "Unown": {"never_release": true}
         
    },
    "vips" : {
        "Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate": {},
        "any": {"catch_above_cp": 1500, "catch_above_iv": 0.9, "logic": "or" },
        "Lapras": {},
        "Moltres": {},
        "Zapdos": {},
        "Articuno": {},

        "// S-Tier pokemons (if pokemon can be evolved into tier, list the representative)": {},
        "Mewtwo": {},
        "Dragonite": {},
        "Dragonair": {},
        "Dratini": {},
        "Snorlax": {},
        "// Mew evolves to Mewtwo": {},
        "Mew": {},
        "Arcanine": {},
        "Vaporeon": {},
        "Gyarados": {},
        "Chansey": {},
        "Flareon": {},
        "Larvitar": {},
        "Pupitar": {},
        "Tyranitar": {},
        "Blissey": {},
        "Heracross": {},
        "Scizor": {},
        "Espeon": {},
        "Feraligatr": {},
        "Typhlosion": {},
        "Ampharos": {},
        "Porygon2": {},
        "Togetic": {},
        "Unown": {}, 
        
        "Mareep": {},
        "Flaaffy": {}

    },
	"websocket": {
		"start_embedded_server": true,
		"server_url": "127.0.0.1:4001"
	}
}

### Other Information
OS: Ubuntu

Branch: Master

Git Commit: de8de509
 
Python Version: Python 2.7.12

Any other relevant files/configs (eg: path files) 


<!-- ===============END OF ISSUE SECTION=============== -->







Discussion:
i never ever see that message in bot 
Sometimes the bot gets stuck on its way to a Pokestop as reported in #6065 this message is an attempt to fix those problems and was introduced in #6092 
is the bot not moving at all, or does it just skip the stop?
The bot seems to be moving, buddy still walked, eggs still incubated, but skips the stops and moves to the next
I have the same problem that it just "freezes" into moving to a pokestop after some time. MoveToFort just gets stuck.
@camnomis that's the intended behaviour 😄 

@goedzo do you still have that problem a lot while using the latest dev?
@davidakachaos that good to know, however what causes the behaviour? Do we know what causes the Pokestop's to not spin, or more importantly is/could this be a flag for Niantic to suspect 3rd party usage?
This isn't caused by not spinning the Pokestop, it's a problem somewhere in the walker that makes it confused about moving to the Pokestop in question. Polyline sometimes has the problem a stop isn't reachable from the road (according to Google Maps)
I admit, this is just a bandage and doesn't solve the real problem. I don't know why the Walkers sometimes have problems moving toward a stop. And most other times it seems to work fine, that is why I created this solution; skip the stop for 5 minutes and move on.
Yep. Had it yesterday evening on two accounts.
I'm getting the same error and on top of that sometimes it starts towards a pokestop or a gym and then starts towards another and never goes to either.

```[2017-07-20 18:24:36] Moving towards gym Crumb Memorial Library - 120.65m
[2017-07-20 18:24:45] Moving towards pokestop Roland Gibson Gallery - 130.84m
[2017-07-20 18:25:14] Moving towards pokestop The Reader - 89.24m
[2017-07-20 18:25:31] Moving towards pokestop Outdoor Class - 91.77m
[2017-07-20 18:25:33] Evolvable: 0/0
[2017-07-20 18:25:40] Moving towards pokestop Outdoor Class - 75.33m
[2017-07-20 18:25:45] Moving towards pokestop Golas Memorial - 108.27m
[2017-07-20 18:25:47] Having difficulty walking to Golas Memorial
[2017-07-20 18:26:19] Moving towards pokestop Satterlee Hall - 60.62m
[2017-07-20 18:26:24] Moving towards pokestop Zodiac wall - 124.53m
I swapped in an older version of move_to_fort.py and I no longer experience the issue! Not sure which commit this is from but here's the move_to_fort.py i'm using that's working fine. I am 100% sure that it is unmodified from when originally cloned. https://pastebin.com/xDKrydS5 .

Actually, it stopped working after 15 minutes.... maybe the issue isn't with the walker it self but elsewhere... ??
Are you all in dense area with lots of pokestops?

here is my config, i dont have any issue:

https://pastebin.com/cVPx2UGw
@MerlionRock in my play area there are about 20 stops and 5 gyms. In my instance, only 2 stops can be reached simultaneously, all others require walking of ~10-15 meters. I have noted that at times my bot will actually pursue a fort that is further away than the one it was previously walking to.
![screenshot_2017-07-22-01-49-07](https://user-images.githubusercontent.com/23582713/28486223-78ae6154-6e80-11e7-86ec-3db9bcb7a1d4.png)
This looks like the issue. It's running in circles. Ps. This is the new web-ui on moble.
Having difficulty walking to Laddermen Memorial. Changing walker.

First time on me when i changed StepWalker to PolylineWalker
@Jcolomar it's okay. Polyline Walker follows path, but some gyms and pokestop won't have path leading to them, so changing Walker is appropriate
It seems that I have this:

        {
            "type": "MoveToFort",
            "config": {
                "enabled": true,
                "lure_attraction": true,
                "lure_max_distance": 2000,
                "walker": "PolylineWalker",
                "log_interval": 60
            }
        },

So maybe that is why it cannog make it,. Howevel polyline is the safest, because it follows real roads. So what to do here? I would like to keep it.
I'm also having this problem, on different systems (ubuntu and raspbian), and on all my accounts. I normally bot in my hometown, but I also used it when I was on holidays at the holiday resort, about four weeks ago, when I first stumbled into this (back then there was no "Having difficulty walking to XXXX", but the bot was not getting to the pokestop). It is happening with both StepWalker and PolylineWalker. I got the bot to not be stuck forever by adding Campfort to the config file, so after some time the bot enters into Campfort mode and moves away, but this makes the bot quite ineffective. The bot seems not to move when stuck, except for the simulated GPS noise. Since this message has been added, the bot changes its target making it difficult to be observed. The output in such a situation is:
[2017-07-23 19:08:21] [MoveToFort] [INFO] Moving towards pokestop Salacz Gyula - 0.09km
[2017-07-23 19:08:24] [MoveToFort] [INFO] Having difficulty walking to Salacz Gyula. Changing walker.
[2017-07-23 19:08:34] [MoveToFort] [INFO] Having difficulty walking to Salacz Gyula
[2017-07-23 19:08:36] [MoveToFort] [INFO] Moving towards pokestop Cinema Arta - 0.14km
[2017-07-23 19:08:41] [MoveToFort] [INFO] Having difficulty walking to Cinema Arta. Changing walker.
[2017-07-23 19:08:49] [MoveToFort] [INFO] Having difficulty walking to Cinema Arta
[2017-07-23 19:08:59] [MoveToFort] [INFO] Moving towards pokestop Universitatea De Vest Vasile Goldis - 0.14km
[2017-07-23 19:09:04] [MoveToFort] [INFO] Having difficulty walking to Universitatea De Vest Vasile Goldis. Changing walker.
[2017-07-23 19:09:14] [MoveToFort] [INFO] Moving towards pokestop Universitatea De Vest Vasile Goldis - 0.14km

 The hunter is having the same problem, it gets stuck for some time without being able to approach it's target, but it appears to get able to move again after a few minutes.

[config.json.txt](https://github.com/PokemonGoF/PokemonGo-Bot/files/1168185/config.json.txt)



I'm wondering... Will setting the noise to off help us?
```json
    "replicate_gps_xy_noise": false,
    "replicate_gps_z_noise": true,
    "gps_xy_noise_range": 1.01E-4,
    "gps_z_noise_range": 7.5,
```
So, disable the replicate_gps_xy_noise thingie, does that help anyone else? It seems to reduce the number of times this happens to me (not sure why)
i got this values if wanna check on ur setup:

"replicate_gps_xy_noise": false,
"replicate_gps_z_noise": false,
"gps_xy_noise_range": 0.000010,
"gps_z_noise_range": 0.5,

Resolving patch:
diff --git a/pokemongo_bot/cell_workers/move_to_fort.py b/pokemongo_bot/cell_workers/move_to_fort.py
--- a/pokemongo_bot/cell_workers/move_to_fort.py
+++ b/pokemongo_bot/cell_workers/move_to_fort.py
@@ -77,6 +77,7 @@ def work(self):
         moving = noised_dist > Constants.MAX_DISTANCE_FORT_IS_REACHABLE if self.bot.config.replicate_gps_xy_noise else dist > Constants.MAX_DISTANCE_FORT_IS_REACHABLE
 
         distance_to_target = int(noised_dist if self.bot.config.replicate_gps_xy_noise else dist)
+
         if len(self.previous_distance) == 0:
             self.previous_distance.append(distance_to_target)
         elif self.target_id is not fort_name:
@@ -86,15 +87,16 @@ def work(self):
             if self.walker is not self.config.get('walker', 'StepWalker'):
                 self.walker = self.config.get('walker', 'StepWalker')
         else:
-            # self.logger.info("Previous distances: %s" % self.previous_distance)
-            if len(self.previous_distance) > 5:
-                self.previous_distance.pop(0)
-            error_moving = False
-            times_found = 0
-            for prev_distance in self.previous_distance:
-                if prev_distance == distance_to_target:
-                    error_moving = True
-                    break
+            if len(self.previous_distance) < 10:
+                self.previous_distance.append(distance_to_target) # collect more previous distance data
+                error_moving = False
+            else:
+                if sum(self.previous_distance[0:5]) <= sum(self.previous_distance[5:10]):
+                    error_moving = True # if previous distance data trend is increasing we're stuck
+                else:
+                    self.previous_distance.pop(0)
+                    self.previous_distance.append(distance_to_target) # collect more previous distance data
+                    error_moving = False
 
             if error_moving:
                 if self.walker == 'StepWalker':
@@ -105,8 +107,6 @@ def work(self):
                     self.logger.info("Having difficulty walking to %s. Changing walker." % fort_name)
                     self.walker = 'StepWalker'
                     self.previous_distance = [distance_to_target]
-            else:
-                self.previous_distance.append(distance_to_target)
 
         if moving:
             self.wait_log_sent = None


Test patch: