From e6c8f5303f3d8b63ef3ca6297eb560797399b2ff Mon Sep 17 00:00:00 2001 From: Raiven66 Date: Tue, 16 Aug 2016 20:46:31 +0200 Subject: [PATCH] MoveToMapPokemon: Replacing min_time with reachable distance calculation (#4022) * * replacing min_time functionality of MoveToMapPokemon by a more sophisticated way of determining reachability on time * * fixing #3609 * moving config values to top --- configs/config.json.map.example | 1 - pokemongo_bot/cell_workers/move_to_map_pokemon.py | 15 ++++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configs/config.json.map.example b/configs/config.json.map.example index d691011e0f..0655c7c8d1 100644 --- a/configs/config.json.map.example +++ b/configs/config.json.map.example @@ -79,7 +79,6 @@ "config": { "address": "http://localhost:5000", "max_distance": 500, - "min_time": 60, "min_ball": 50, "prioritize_vips": true, "snipe": true, diff --git a/pokemongo_bot/cell_workers/move_to_map_pokemon.py b/pokemongo_bot/cell_workers/move_to_map_pokemon.py index 8a4ae9ca27..82bb509419 100644 --- a/pokemongo_bot/cell_workers/move_to_map_pokemon.py +++ b/pokemongo_bot/cell_workers/move_to_map_pokemon.py @@ -85,6 +85,9 @@ def initialize(self): self.caught = [] self.min_ball = self.config.get('min_ball', 1) self.map_path = self.config.get('map_path', 'raw_data') + self.snipe_high_prio_only = self.config.get('snipe_high_prio_only', False) + self.snipe_high_prio_threshold = self.config.get('snipe_high_prio_threshold', 400) + data_file = os.path.join(_base_dir, 'map-caught-{}.json'.format(self.bot.config.username)) if os.path.isfile(data_file): @@ -124,9 +127,6 @@ def get_pokemon_from_map(self): if pokemon['name'] not in self.config['catch'] and not pokemon['is_vip']: continue - if pokemon['disappear_time'] < (now + self.config['min_time']): - continue - if self.was_caught(pokemon): continue @@ -142,6 +142,11 @@ def get_pokemon_from_map(self): if pokemon['dist'] > self.config['max_distance'] and not self.config['snipe']: continue + # pokemon not reachable with mean walking speed (by config) + mean_walk_speed = (self.bot.config.walk_max + self.bot.config.walk_min) / 2 + if pokemon['dist'] > ((pokemon['expire'] - now) * mean_walk_speed) and not self.config['snipe']: + continue + pokemon_list.append(pokemon) return pokemon_list @@ -257,8 +262,8 @@ def work(self): return WorkerResult.SUCCESS if self.config['snipe']: - if self.config['snipe_high_prio_only']: - if self.config['snipe_high_prio_threshold'] < pokemon['priority'] or pokemon['is_vip']: + if self.snipe_high_prio_only: + if self.snipe_high_prio_threshold < pokemon['priority'] or pokemon['is_vip']: self.snipe(pokemon) else: return self.snipe(pokemon)