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

MapObjects lack of pokemon and other issue #73

Closed
dnsBlah opened this issue Aug 8, 2016 · 23 comments
Closed

MapObjects lack of pokemon and other issue #73

dnsBlah opened this issue Aug 8, 2016 · 23 comments

Comments

@dnsBlah
Copy link
Contributor

dnsBlah commented Aug 8, 2016

Hi all,

is it just me or are there soo much less pokemons on the map (meaning wild_pokemon and catchable_pokemon)
Is there any way to find more pokemons?
Im already doing a scan in the walkto function, every 10th loop

Besides that, to minimize the mapobject calls I decided to store the results for a while

When I stored the result(s) in a global var, and later on print then out again, i only see 3 empty cells for some reason. Just to be clear, I did not do another request.
When I start the bot, check map objects and stored them globally
Use the global results to filter forts and go there one by one
when arrived I use the same globals to filter pokemons. guess what, its empty?!!

@jangeja
Copy link

jangeja commented Aug 8, 2016

Need to increase radius of get map objects call to 1000

@jangeja
Copy link

jangeja commented Aug 8, 2016

@dnsBlah

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 8, 2016

@jmangeja1 to 1000 !?
Even on 10 I find 196 pokestops, how can that radius be too low for decent pokemons ? 👯

Any idea about my 're-using' mapobjects issue? Looks like I can't re-use it at all, as it appears empty by then :S

@jangeja
Copy link

jangeja commented Aug 8, 2016

@dnsBlah I actually haven't used this Ali, but if you look at keyphacts phosphine you'll see they use 1000 as the radius

@jangeja
Copy link

jangeja commented Aug 8, 2016

Sorry my spelling is awful. I'm on an iPhone. Ali= API
Phosphine = pygo api

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 8, 2016

hmmm I will have a look in that later then
dont worry, same thing here ;-)

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 9, 2016

I do see a limit of 100 there, going to give it a try :)
With laods of delays I'm already getting more results.

Still an issue when re-using mapobjects like this:

aCells = getMapObjects(session)
pokemons = getPokemonsNearby(session, aCells)
for pokemon in pokemons:
    #looping here
pokeForts = getPokeFortsNearby(session,aCells)
#from here aCells is empty! :-/

getPokemonsNearby and getPokeFortsNearby look like this:

#get pokemons
def getPokemonsNearby(session, cells):
    tPokemons = []
    latitude, longitude, _ = session.getCoordinates()
    for cell in cells.map_cells:
        pokemons = [p for p in cell.wild_pokemons] + [p for p in cell.catchable_pokemons]
        for pokemon in pokemons:
            dist = Location.getDistance(
                latitude,
                longitude,
                pokemon.latitude,
                pokemon.longitude
            )
            tPokemons.append({'distance': dist, 'pokemon': pokemon})

    if len(tPokemons) == 0:
        cells = getMapObjects(session, 10)
        for cell in cells.map_cells:
            pokemons = [p for p in cell.wild_pokemons] + [p for p in cell.catchable_pokemons]
            for pokemon in pokemons:
                dist = Location.getDistance(
                    latitude,
                    longitude,
                    pokemon.latitude,
                    pokemon.longitude
                )
                tPokemons.append({'distance': dist, 'pokemon': pokemon})

    tPokemons = sorted(tPokemons, key=lambda k: k['distance'])

    return [instance['pokemon'] for instance in tPokemons]

#get forts (pokestops and gyms)
def getPokeFortsNearby(session, cells):    
    ordered_forts = []
    latitude, longitude, _ = session.getCoordinates()
    for cell in cells.map_cells:
        for fort in cell.forts:
            dist = Location.getDistance(
                latitude,
                longitude,
                fort.latitude,
                fort.longitude
            )
            if fort.type == 1:
                if fort.cooldown_complete_timestamp_ms<time.time():
                    ordered_forts.append({'distance': dist, 'fort': fort})
            else:
                ordered_forts.append({'distance': dist, 'fort': fort})

    ordered_forts = sorted(ordered_forts, key=lambda k: k['distance'])

    return [instance['fort'] for instance in ordered_forts]

As far as I know, I'm not getting 'new' mapObjects, just trying to re-use the mapobjects i retrieved earlier.
Any idea?

@jangeja
Copy link

jangeja commented Aug 9, 2016

@dnsBlah. Yea, you can only scan a short distance for Pokemon so not many will show up. I recommend implementing a mapping tool and incorporating that in your program

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 9, 2016

@jmangeja1 Yes I gathered that one :)
I also think there will be a proto update soon related to pokemons nearby, as its back in the game

Anyways yet I don't understand the second part

I retrieve map objects and store it in a variable (aCells)
when I print that variable, I see forts and pokemons
Now I'm using this variable to filter out pokemons and store it in another variable (pokemons)
i loop through them, walk and catch
when finished I use the aCells to filter out the forts
and store it pokeForts
but pokeForts got empty!?

If I print aCells after the pokemon loop
the aCells got empty cells
I haven't rechecked mapobjects yet
Why is it empty?

@jangeja
Copy link

jangeja commented Aug 9, 2016

@dnsBlah I'm learning N as I go with this app, but what do you mean there has been an update to pokemons nearby in the game?

Regarding your second question as to why the Acells empty... Are you modifying acells as you loop through Pokemon?

@jangeja
Copy link

jangeja commented Aug 9, 2016

@dnsBlah let me read your source code posted above.

@jangeja
Copy link

jangeja commented Aug 9, 2016

@dnsBlah in function getnearbypokemons look at the line cells= getmapobjects(radius =10) that's clearing acells because radius is only 10 and its overwriting acells

@jangeja
Copy link

jangeja commented Aug 9, 2016

actually I don't think that should affect it

@Jefreesujit
Copy link

could someone tell me where to place this libencrypt.so

@jangeja
Copy link

jangeja commented Aug 9, 2016

Place it in same directory as the python program that you are running or edit path to include it

@Jefreesujit
Copy link

still it says no forts found.. what could be the problem?

@jangeja
Copy link

jangeja commented Aug 9, 2016

Did you download correct version? I actually don't use this Ali. I use keyphacts edited pgoapi

@Jefreesujit
Copy link

i just downloaded it.. its the latest one

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 9, 2016

Hi @jmangeja1 ,

thanks for your time, but I only do
cells = getMapObjects(session, 10)
When I don't see any pokemons. Just for the... you know, maybe there are a few in the area where I am at that moment, instead of the area where I scanned aCells
Next to that, it will be stored as 'cells', and not 'aCells' as I pass it to the location :)

And if radius 10 is too low, I even put it on 9 now. As it gives me more often results without multiple loops and sleep times.
[ ] Found 147 Forts nearby
*** These are pokestops AND gyms ofcourse.

pgoapi / kryphacts are using radius in meters I guess.
But indeed, I'm also only getting empty cells there.

@jangeja
Copy link

jangeja commented Aug 9, 2016

@dnsBlah that line is called when you don't find any Pokemon so it might be clearing out the cells variable. I would test that. Take out that getmapcells call inside the get pokemonsnearby and see if that works. I think that's why your forts are empty

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 9, 2016

@jmangeja1 is it possible by calling getmapobjects to return to a variable named cells inside pokemonsnearby function, to overwrite an older variable named aCells, which is even outside that function, and without mentioning it to be global at the beginning of pokemonsnearby function?

Then it's time to stop doing python...

Maybe its a bug/'unsolved feature' from proto's ? They work in 'memory/cache' ? Is getmapobjects stored in something like 'cache' instead of the variable I defined?

@jangeja
Copy link

jangeja commented Aug 9, 2016

I would google a little but on Python pass by object reference. This is the explanation of how Python passes arguments in functions. From what I can remember a cells should be unaffected once you reassign something in a function. So I'm not sure why you're cells are being cleared out.

@dnsBlah
Copy link
Contributor Author

dnsBlah commented Aug 10, 2016

It's ok for now.. with my workaround with threshold delays
Still, I find it weird that it hardly sees any.

@dnsBlah dnsBlah closed this as completed Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants