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

[Feature] Move map should accept multiple pokemon sources #3656

Closed
shivamkalra opened this issue Aug 11, 2016 · 10 comments
Closed

[Feature] Move map should accept multiple pokemon sources #3656

shivamkalra opened this issue Aug 11, 2016 · 10 comments

Comments

@shivamkalra
Copy link

One of te best feature of bot is that it can be guided using data from pokeman-map.

Since we already have the logic of guiding the bot based on priority and distance to the pokemon that needs to be caught.

I suggest guiding code should be separated out from data collection code. Such that I can collect pokemon data from various sources (twitter, pokemonmap, pokesniper and etc), normalize them and feed them to bot's guide module.

Basically my suggestion is to remove dependency on pokemap instead use some universal format which contains pokemon and their locations which guides the bot. However source can be either pokemon map or some twitter alerts or anything.

What do you think? I could work on it if you people like the idea?

@DanielVolz
Copy link

It's a great idea! I actually use a hack to feed the movetopokemonmap worker with location data from a discord channel and it works really great as a sniper! But I would be happy to have a proper integration of this feature. 👍

@stevelacey
Copy link

stevelacey commented Aug 11, 2016

I got this far, butchered copy of MoveToMapPokemon.get_pokemon_from_map:

from datetime import datetime
import dateutil.parser

def get_pokemon_from_pokesniper(self):
    try:
        req = requests.get('http://pokesnipers.com/api/v1/pokemon.json')
    except requests.exceptions.ConnectionError:
        self._emit_failure('Could not get Pokemon data from PokemonGo-Map: '
                           '{}. Is it running?'.format(
                               self.config['address']))
        return []

    try:
        raw_data = req.json()
    except ValueError:
        self._emit_failure('Map data was not valid')
        return []

    pokemon_list = []
    now = int(time.time())

    for pokemon in raw_data['results']:
        pokemon['encounter_id'] = None
        pokemon['spawn_point_id'] = None
        pokemon['latitude'], _, pokemon['longitude'] = pokemon['coords'].partition(',')
        pokemon['latitude'], pokemon['longitude'] = float(pokemon['latitude']), float(pokemon['longitude'])
        pokemon['disappear_time'] = int((dateutil.parser.parse(pokemon['until'].replace('Z', '')) - datetime(1970, 1, 1, 0, 0, 0)).total_seconds())
        pokemon['name'] = pokemon['name']
        pokemon['is_vip'] = pokemon['name'] in self.bot.config.vips

Seemed to get as far as encountering the first thing off of the pokesnipers list and then idling – I don't know what to do about encounter or spawn ids – @DanielVolz presumably you have something like this?

@ghost
Copy link

ghost commented Aug 12, 2016

@stevelacey Its don't work

2016-08-11 23:30:21,148 [PokemonGoBot] [INFO] Found encrypt.so! Platform: linux2 Encrypt.so directory: /home/carlos/Documentos/POKEMON/PokemonGo-Bot
2016-08-11 23:30:21,148 [PokemonGoBot] [INFO] 
2016-08-11 23:30:25,688 [PokemonGoBot] [INFO] [bot_start] Starting bot...
2016-08-11 23:30:26,231 [CollectLevelUpReward] [INFO] [level_up_reward] Received level up reward: []
2016-08-11 23:30:26,233 [IncubateEggs] [INFO] [next_egg_incubates] Next egg incubates in 4.76 km
2016-08-11 23:30:29,089 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_to] Teleporting to Snorlax. (4131.17km)
2016-08-11 23:30:29,091 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_encounter] Encountered Pokemon: Snorlax
2016-08-11 23:30:31,591 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_teleport_back] Teleporting back to previous location (40.7711329, -73.9741874)
2016-08-11 23:30:34,062 [MoveToMapPokemon] [INFO] [move_to_map_pokemon_move_towards] Moving towards Snorlax, 4131.17km, left (3 minutes, 24 seconds)
2016-08-11 23:30:41,917 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Sheep Meadow - 0.08km
2016-08-11 23:30:45,303 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Sheep Meadow - 0.07km
2016-08-11 23:30:49,887 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Sheep Meadow - 0.07km
2016-08-11 23:30:53,082 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Sheep Meadow - 0.07km
2016-08-11 23:30:58,488 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Sheep Meadow - 0.06km
2016-08-11 23:31:02,999 [MoveToFort] [INFO] [moving_to_fort] Moving towards pokestop Sheep Meadow - 0.06km
´´´

@stevelacey
Copy link

stevelacey commented Aug 12, 2016

@MrCarlosJr no shit

@ahammond
Copy link

Hmm, my reading of the docs suggests this is working correctly: "Will teleport to target pokemon, encounter it, teleport back then catch it" so it teleports there to stimulate the encounter, and then walks over and catches it. The problem is that some of these are a very, very, very long way away.

@stevelacey
Copy link

Seriously? If you'd read the rest of my comment you'd see I am providing a WIP – not something that works

@DanielVolz
Copy link

@stevelacey actually I have a really (unnecessarily )complex setupt/hack because I'm not very skilled in the needed languages.

  1. I use a discord bot for scanning a channel for locations of rare pokemon (unfortunately the repo of this bot is offline) and write them to a local db.
  2. Then I modified the move_to_map_pokem worker to load those locations from the db and to feed them to the update_map_location().

It's really more a hack but it works for me 😄

@stevelacey
Copy link

@DanielVolz can you paste the python bit where you call update_map_location? I might be attempting a too fancy solve

@DanielVolz
Copy link

def get_snipe_pokemon(self):
    pokemon_list = []
    pokemon = {}

    for p in Spawns.select():

        pokemon['name'] = p.name
        try:
            pokemon['latitude'] = float(p.lat)
        except ValueError:
            q = Spawns.delete().where(Spawns.name == pokemon['name'])
            self._emit_failure('lat error')
            q.execute()  # remove the rows
            continue

        try:
            pokemon['longitude'] = float(p.lon)
        except ValueError:
            q = Spawns.delete().where(Spawns.name == pokemon['name'])
            self._emit_failure('long error')
            q.execute()  # remove the rows
            continue

        #self._emit_log('Füge {} zur Liste hinzu'.format(p.name))
        pokemon_list.append(pokemon)

    return pokemon_list

The get_snipe_pokemon(self) function loads them from the db to a list.
And to update_map_location() I just added:

pokemon_list = self.get_snipe_pokemon()
if len(pokemon_list) > 0:
pokemon = pokemon_list[0]
q = Spawns.delete().where(Spawns.name == pokemon['name'])
q.execute() # remove the rows

        requests.post(
            '{}/next_loc?lat={}&lon={}'.format(self.config['address'],
                                               pokemon['latitude'],
                                               pokemon['longitude']))
        self.emit_event(
            'move_to_map_pokemon_updated_map',
            formatted='Updated PokemonGo-Map to {lat}, {lon}',
            data={
                'lat': pokemon['latitude'],
                'lon': pokemon['longitude']
            }
        )

@k4n30
Copy link
Contributor

k4n30 commented Aug 18, 2016

@shivamkalra I'm going to create this FR in favour for #3672 Although yours was technically first, and therefore the other one should be marked as duplicate, I feel #3672 captures your request and a little bit more and goes into more detail for whoever works on it. If you feel it misses anything out, please don't hesitate to comment on #3672

@k4n30 k4n30 closed this as completed Aug 18, 2016
This was referenced Sep 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@stevelacey @ahammond @shivamkalra @k4n30 @DanielVolz and others