-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support for IV scanning and CP scanning #1980
Conversation
this will need a lot of testing, also i can see alot of unneeded changes in the code, prepare for adjustments :) |
without looking at the code, is this designed to be where the iv/cp accts are restricted to a particular hex? or those who run bh -st 5 etc, will they be able to service all the hexes available ? |
I'm not familiar with beehive, I use speed scan. Maybe someone who understands the entire code base can find out how this would work ? I suspect it will work. The workers will currently speed block to avoid high kph. I am planning to implement geo-localization of the workers, but might not include this in first version (The worker manager would take location as input and find the "closest" available free worker, worker still blocks to obey speed restrictions like today). Right now your IV checker pool needs to be sufficiently large to avoid too much travel-blocking issues (Currently it appears |
well how --behive works with -speed is lets say i do -st 6 -wph 3 -w 108 that creates 36 st6 hexes - which if defined by hex would require 36 lvl 25 accts to handle it to keep one locked to each hex if needed. Your geo-loc would overcome that situation or that multi webhook as well that we talked about so the lvl 25 accts arent restricted to a certain region like those who are running multiple hives or bh. Though maybe the recommended way to run would be like -st10 wph 4 -wphiv 1 -w 144 etc so that in a st10 4 accts are normal and 1 is set as the iv checker but i think that would be way more work to go that route as many prefer the large st path. |
Wonderful. I'll test this PR asap. Thankd for it. Just one question : how does it work wrt webhooks ? As far as a "normal" account will probably find the pokemon before another account from the 25+ pool is sent for encountering, will it wait for sending the webhook until pokemon has been encountered or will it send 2 webhooks ? Also will pool accounts be used for "normal" scanning as well or will they wait until they are needed for an encounter ? And finally are you also sending CP to webhook ? Thanks |
All encountering is done before anything is sent to the webhook. cp is sent to webhook. cp & iv scanning pools are only used for cp & iv scanning |
Review inc. soon by me. It's a huge PR and my time feels like its reciprocal. |
pogom/models.py
Outdated
@@ -1760,9 +1767,60 @@ def hex_bounds(center, steps=None, radius=None): | |||
return (n, e, s, w) | |||
|
|||
|
|||
def do_cp_iv_scan(cpWorkerManager, p, step_location): | |||
worker = cpWorkerManager.get_worker_for_location(step_location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this line inside try
block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am definitely not a python developer, but the try/finally block is not to guard against allocation failures (which should be handled inside get_worker_for_location), but from failures when invoking the actual logic inside the block. Please explain to me if python somehow works differently from other langs I'm used to :)
config/config.ini.example
Outdated
# Search settings | ||
################# | ||
|
||
#china # Coordinates transformer for China. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All end-of-line changes?
Please reduce the noise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line endings in this file are incorrect in the RocketMap repo, which means that any well behaved git client changing this file will appear to change the entire file. Someone with commit priviliges should really run dos2unix on this file and commit the change. I also see that the repository is missing a .gitattributes files, which is probably a very good idea to add. This would prevent future line ending issues., since .gitattributes dictate how the REPOSITORY wants things to be
accounts.txt
Outdated
@@ -0,0 +1,308 @@ | |||
ptc,irkopampcr0kysk,aaaaaaA1! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krosenvold remove this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
Hello. Trying to test this PR, but I'm immediately getting an error when starting
Looks like my DB was not updated as it should... Any idea why ? What columns should I add to my DB ? Also 2 more questions :
Thanks |
A group of us have been testing for 6 hours yesterday and noticed the CP was different with the same spawn for all their levels and they're all lvl30+ trainers? They think the CP is now depended for each individual trainer level and is no longer the same for evere trainer level from lvl 30? |
@bbdoc Happy to see people in GitHub, fiddling around PRs etc. but you probably see reasons for direct errors pretty fast. So, in this PR the cp column was not integrated into the DB as well as there is a wrong DB version and migration only for |
@aRengo Yes of course adding CP column would be a quick fix, but is it really a good solution. I do see indeed that the code still mention I still guess it's worth it mentionning to PR initiator that there is something wrong in his code resulting in db not being updated. I guess people who managed to get it working started with a blank db and thus didn't get this error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my first review regarding already existing RM code, I did not had a look into the new classes which demand extra time. I do like the abstraction in general but it'll need some more work. Additionally, please do not commit files like temp saved .gitignore~
or bad bad material we do not like here in the repo (psst, sprites).
pogom/models.py
Outdated
@@ -2625,6 +2723,12 @@ def database_migrate(db, old_ver): | |||
|
|||
db.drop_tables([ScanSpawnPoint]) | |||
|
|||
if old_ver < 12: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure it has to be 17
.
pogom/models.py
Outdated
if old_ver < 12: | ||
migrate( | ||
migrator.add_column('pokemon', 'cp', | ||
IntegerField(null=True, default=0)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SmallIntegerField(null=True)
pogom/models.py
Outdated
@@ -109,6 +114,8 @@ class Pokemon(BaseModel): | |||
gender = SmallIntegerField(null=True) | |||
last_modified = DateTimeField( | |||
null=True, index=True, default=datetime.utcnow) | |||
cp = IntegerField(null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SmallIntegerField(null=True)
This is valid until we reach Pokémon with CP ~16.000 and can be extended by PositiveSmallIntegerField
to ~32.000. The we can still switch IntegerField if this will expand further, what I do not believe.
pogom/models.py
Outdated
@@ -2667,6 +2771,7 @@ def database_migrate(db, old_ver): | |||
'NULL DEFAULT NULL,' | |||
'MODIFY COLUMN `move_1` SMALLINT NULL DEFAULT NULL,' | |||
'MODIFY COLUMN `move_2` SMALLINT NULL DEFAULT NULL;' | |||
'MODIFY COLUMN `cp` SMALLINT NULL DEFAULT NULL;' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, we are at
Versions.schema_version = 16
pogom/models.py
Outdated
@@ -2738,4 +2843,9 @@ def database_migrate(db, old_ver): | |||
migrate( | |||
migrator.add_index('pokestop', ('last_updated',), False) | |||
) | |||
if old_ver < 19: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this to the
if old_ver < 17
pogom/models.py
Outdated
'height': None, | ||
'weight': None, | ||
'gender': None | ||
} | ||
|
||
pokemon_info = None | ||
cp = 0 | ||
pokemon_level = 0 | ||
if (encounter_result is not None and 'wild_pokemon' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a do_iv_scan
, do_cp_scan
think about abstracting any encounter_result
into one function definition def get_encounter_response
where you request accordingly to given args for distinguishing the config of the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style-wise I agree. But I also believe the current encounter logic is entirely useless ? I'd really enjoy looking at all of these together, so I'm sort-of awaiting the "encounter" issue to clear out.
pogom/models.py
Outdated
pokemon_info = do_cp_iv_scan(cpWorkers, p, | ||
step_location) | ||
cp = pokemon_info.get('cp', 0) | ||
pokemon_level = pokemon_info.get('level', 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik a level
is not submitted, only the corresponding cp_multiplier
which translates into a level with a table (I think I saw this table once in your fork)
pogom/models.py
Outdated
@@ -1968,47 +2027,86 @@ def parse_map(args, map_dict, step_location, db_update_queue, wh_update_queue, | |||
'individual_stamina': None, | |||
'move_1': None, | |||
'move_2': None, | |||
'cp': None, | |||
'level': None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until now we only store direct API values in the database - so this should be cp_multiplier
and the conversion should be done somewhere after the DB instead of in the back-end
pogom/models.py
Outdated
height = pokemon_info['height_m'] | ||
weight = pokemon_info['weight_kg'] | ||
gender = pokemon_info['pokemon_display']['gender'] | ||
if pokemon_info['pokemon_id'] == 201: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for being so kind, addressing #1914 directly. While this is in general a good move to finally include it into RM, leave it out for lowering complexity since whatever will be merged first, the other one has to adjust.
pogom/models.py
Outdated
cp = pokemon_info.get('cp', 0) | ||
pokemon_level = pokemon_info.get('level', 0) | ||
|
||
if pokemon_info is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a general dict update style across all possibilities imo it would be logically the best to get away from standard encounter, check if encounter lvl 25+ or lvl 30+, adding all values of old encounter by a first dict.update and then adding the last two values regarding cp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure I understand this comment
Note that there was a bug I fixed this morning: For pokemons that were NEITHER CP or IV scanned, the "cp" would slip through from the original map worker. This was fixed about 5 hours ago |
I have rebased this PR, but I am now not squashing to make it easier to follow the changes done in the review process. |
@krosenvold you should remove copyrighted content |
pogom/utils.py
Outdated
parser.add_argument('--scan-iv', action='append', default=[], | ||
help='List of pokemon to check IV and ' | ||
'moveset with level 25+ account') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a --scan-iv parameter on command line but no equivalent in config.ini.example ? Did I miss it ? I also think it would be good to have both whitelist and blacklist for this parameter as it does exist for encounter, and I guess if you use an encounter blacklist you also want to use the same blacklist for scanning IV with a lvl 25+ account. Quid if you only have -cpac ? Will those accounts be used for IV scanning as well (as if they are 30+ they are also 25+) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running on my map right now and all looking fine, but only scanning IV right now. My IV scanning accounts are lvl30+ so I think when sending an IV scanning account to a spawn and it is lvl30+, it should automatically check cp as well as it doesn't cost any additional request.
PR #1981 is being tested for merge rather than this PR. Relaying feedback as mentioned in our Discord's #pr:
Arguably, you've taken time to work on things that absolutely needed to be reworked, but then you don't seem to have taken the time to wonder how the abstractions could be written properly. And then you don't seem to have talked to anyone about what you were doing, so there was no code feedback. With the PR's size, there's no time for us to review and rework all points properly, because that would involve rewriting account handling as there's an important part in the legacy code that really needs to be reworked. In the meantime, PR #1981 will serve as the initial implementation, and we'll rework the rest as we go. PR 1981 separates the new account pools from the old code so we can more easily rewrite account handling and the other TODOs without having to undo a new mess that a larger PR like this one would have created. I've also been PM'ed that you've been inviting people to a new Discord of yours called "FreeSpeechRocket". I can appreciate a good joke, but not a bad attitude. I don't know you and I've never worked with you, so if there's already a problem I'd love to hear about it so I can make sure someone else talks to you instead in the future. That someone PM's me about it is already too much: I'm not sure how you consider that kind of attitude constructive or productive. |
Added two additional account pools, for a total of three pools. One regular pool, one for level 25 iv scanners and another for level 30 cp/iv scanners.
Added additional abstractions to handle the increased complexity.
To reduce overall risk, I did not introduce the new abstractions in the existing code. I believe the safe approach is to do this once the new feature is properly battle proven. Hence the impact on existing functionality if running without IV/CP scanning is practically nonexistant
Description
Added Account, AccountManager, Worker and WorkerManager to facilitiate multiple account pools and safe & simple IV/CP scanning.
Motivation and Context
Continued support of IV scanning as well as CP scanning.
How Has This Been Tested?
A superset of this code has been run on my 250km2 scanner rig. The CP scanning code has been running for 4 months
Types of changes
Checklist: