From 2006abd8166c1559b1c021b63ff4a0a7386e6227 Mon Sep 17 00:00:00 2001 From: tstumm Date: Mon, 25 Jul 2016 14:53:59 +0200 Subject: [PATCH] Fixes SpiralNavigation skipping waypoints (#807) * Fixed sleep to use floats again * Fixed sleep to use floats again #2 * Refactored jitter to have its own function to be used elsewhere * Fixes SpiralNavigation skipping waypoints * Fixing stationary movements --- pokemongo_bot/human_behaviour.py | 8 +++++--- pokemongo_bot/spiral_navigator.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pokemongo_bot/human_behaviour.py b/pokemongo_bot/human_behaviour.py index 18d8fb47f4..2da9d1e365 100644 --- a/pokemongo_bot/human_behaviour.py +++ b/pokemongo_bot/human_behaviour.py @@ -5,9 +5,11 @@ def sleep(seconds, delta=0.3): - jitter = delta * seconds - sleep_time = uniform(seconds - jitter, seconds + jitter) - time.sleep(sleep_time) + time.sleep(jitter(seconds,delta)) + +def jitter(value, delta=0.3): + jitter = delta * value + return uniform(value-jitter, value+jitter) def random_lat_long_delta(): diff --git a/pokemongo_bot/spiral_navigator.py b/pokemongo_bot/spiral_navigator.py index 6fb174b0e9..56d8eee03c 100644 --- a/pokemongo_bot/spiral_navigator.py +++ b/pokemongo_bot/spiral_navigator.py @@ -78,6 +78,12 @@ def take_step(self): if self.x == self.y or self.x < 0 and self.x == -self.y or self.x > 0 and self.x == 1 - self.y: (self.dx, self.dy) = (-self.dy, self.dx) - (self.x, self.y) = (self.x + self.dx, self.y + self.dy) - sleep(10) + if distance( + i2f(self.api._position_lat), + i2f(self.api._position_lng), + position[0], + position[1] + ) <= 1 or (self.config.walk > 0 and self._step_walker == None): + (self.x, self.y) = (self.x + self.dx, self.y + self.dy) + sleep(1) return position[0:2]