Skip to content

Commit

Permalink
MoveToMapPokemon: Replacing min_time with reachable distance calculat…
Browse files Browse the repository at this point in the history
…ion (#4022)

* * replacing min_time functionality of MoveToMapPokemon by a more sophisticated way of determining reachability on time

* * fixing #3609

* moving config values to top
  • Loading branch information
mvrska authored and elicwhite committed Aug 16, 2016
1 parent 2dd8a5e commit e6c8f53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"config": {
"address": "http://localhost:5000",
"max_distance": 500,
"min_time": 60,
"min_ball": 50,
"prioritize_vips": true,
"snipe": true,
Expand Down
15 changes: 10 additions & 5 deletions pokemongo_bot/cell_workers/move_to_map_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e6c8f53

Please sign in to comment.