Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed logic to check if move_to_fort is stuck #6153

Merged
merged 1 commit into from
Jul 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions pokemongo_bot/cell_workers/move_to_fort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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':
Expand All @@ -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
Expand Down