{"action":"created","comment":{"url":"https://api.github.com/repos/j-e-k/poketrainer/pulls/comments/72689812","id":72689812,"diff_hunk":"@@ -627,39 +640,65 @@ def cleanup_pokemon(self, inventory_items=None):\n         caught_pokemon = self.get_caught_pokemons(inventory_items)\n         for pokemons in caught_pokemon.values():\n             if len(pokemons) > self.MIN_SIMILAR_POKEMON:\n-                # highest lvl pokemon first\n-                sorted_pokemons = sorted(pokemons, key=self.pokemon_lvl, reverse=True)\n-                for pokemon in sorted_pokemons[self.MIN_SIMILAR_POKEMON:]:\n-                    if self.is_pokemon_eligible_for_transfer(pokemon, sorted_pokemons[0]):\n+                # highest scoring pokemon first\n+                sorted_pokemons = sorted(pokemons, key=self.pokemon_score, reverse=True)\n+                pokemons_keep_counter = 0\n+                pokemons_keep_iv_counter = 0\n+                for pokemon in sorted_pokemons:\n+                    eligible, keep_iv = self.is_pokemon_eligible_for_transfer(pokemon, sorted_pokemons[0],\n+                                                                              pokemons_keep_counter,\n+                                                                              pokemons_keep_iv_counter)\n+                    if (eligible and pokemons_keep_counter > self.MIN_SIMILAR_POKEMON)\\\n+                            or pokemons_keep_counter >= self.MAX_SIMILAR_POKEMON:\n                         self.do_release_pokemon(pokemon)\n+                        continue\n+                    else:\n+                        pokemons_keep_counter += 1\n+                        if keep_iv:\n+                            pokemons_keep_iv_counter += 1\n \n-    def is_pokemon_eligible_for_transfer(self, pokemon, best_pokemon):\n+    def is_pokemon_eligible_for_transfer(self, pokemon, best_pokemon=Pokemon(),\n+                                         pokemons_keep_counter=0, pokemons_keep_iv_counter=0):\n         # never release favorites and other defined pokemons\n         if pokemon.is_favorite or pokemon.pokemon_id in self.keep_pokemon_ids:\n-            return False\n-        elif self.RELEASE_DUPLICATES and (\n-                    self.pokemon_lvl(best_pokemon) * self.RELEASE_DUPLICATES_SCALER > self.pokemon_lvl(\n-                    pokemon) and self.pokemon_lvl(pokemon) < self.RELEASE_DUPLICATES_MAX_LV):\n-            return True\n-        # release defined throwaway pokemons  but make sure we have kept at least 1 (dont throw away all of them)\n-        elif pokemon.pokemon_id in self.throw_pokemon_ids:\n-            return True\n+            return False, False\n+        # release defined throwaway pokemons, but make sure we have kept at least 1 (dont throw away all of them)\n+        elif pokemon.pokemon_id in self.throw_pokemon_ids and pokemons_keep_counter >= self.MIN_SIMILAR_POKEMON:\n+            return True, False\n+        # release duplicates if applicable\n+        elif self.RELEASE_METHOD == \"DUPLICATES\":\n+            if (self.pokemon_score(best_pokemon) * self.RELEASE_DUPLICATES_SCALAR > self.pokemon_score(pokemon) and\n+                    self.pokemon_score(pokemon) < self.RELEASE_DUPLICATES_MAX_SCORE) and \\\n+                            pokemons_keep_counter >= self.MIN_SIMILAR_POKEMON:\n+                return True, False\n+            else:\n+                return False, False\n+        # keep high-iv pokemons based on config values\n+        elif pokemon.iv_normalized > self.KEEP_IV_OVER \\\n+                and pokemons_keep_iv_counter < self.MAX_POKEMON_HIGH_IV \\\n+                and pokemon.cp > (best_pokemon.cp * self.KEEP_IV_WITH_PERCENT_CP / 100):\n+            return False, True\n         # keep high-cp pokemons\n-        elif pokemon.cp > self.KEEP_CP_OVER or pokemon.iv > self.KEEP_IV_OVER:\n-            return False\n-        # if we haven't found a reason to keep it, transfer it\n-        else:\n-            return True\n-\n-    def pokemon_lvl(self, pokemon):\n-        if self.DEFINE_POKEMON_LV == \"CP\":\n+        elif pokemon.cp > self.KEEP_CP_OVER:\n+            return False, False\n+        # release all other pokemons\n+        elif pokemons_keep_counter >= self.MIN_SIMILAR_POKEMON:\n+            return True, False\n+        # if we haven't found a reason, keep it! (probably not at MIN_SIMILAR yet)\n+        return False, False\n+\n+    def pokemon_score(self, pokemon):\n+        if self.SCORE_METHOD == \"CP\":\n             return pokemon.cp\n-        elif self.DEFINE_POKEMON_LV == \"IV\":\n-            return pokemon.iv\n-        elif self.DEFINE_POKEMON_LV == \"CP*IV\":\n-            return pokemon.cp * pokemon.iv\n-        elif self.DEFINE_POKEMON_LV == \"CP+IV\":\n-            return pokemon.cp + pokemon.iv\n+        elif self.SCORE_METHOD == \"IV\":\n+            return pokemon.iv_normalized\n+        elif self.SCORE_METHOD == \"CP*IV\":\n+            return pokemon.cp * pokemon.iv_normalized\n+        elif self.SCORE_METHOD == \"CP+IV\":","path":"pgoapi/pgoapi.py","position":182,"original_position":182,"commit_id":"6a1ebb0f7aa313f886d416f2a1cc879550f59fba","original_commit_id":"6a1ebb0f7aa313f886d416f2a1cc879550f59fba","user":{"login":"destiny117","id":3976393,"avatar_url":"https://avatars.githubusercontent.com/u/3976393?v=3","gravatar_id":"","url":"https://api.github.com/users/destiny117","html_url":"https://github.com/destiny117","followers_url":"https://api.github.com/users/destiny117/followers","following_url":"https://api.github.com/users/destiny117/following{/other_user}","gists_url":"https://api.github.com/users/destiny117/gists{/gist_id}","starred_url":"https://api.github.com/users/destiny117/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/destiny117/subscriptions","organizations_url":"https://api.github.com/users/destiny117/orgs","repos_url":"https://api.github.com/users/destiny117/repos","events_url":"https://api.github.com/users/destiny117/events{/privacy}","received_events_url":"https://api.github.com/users/destiny117/received_events","type":"User","site_admin":false},"body":"i agree i don't see a reason to use them either, but @beeedy has implemented them so maybe he uses one of them. i'm hesitant to remove a feature that is already live, especially when it does not bother the rest of the code","created_at":"2016-07-28T19:48:58Z","updated_at":"2016-07-28T19:48:58Z","html_url":"https://github.com/j-e-k/poketrainer/pull/216#discussion_r72689812","pull_request_url":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216","_links":{"self":{"href":"https://api.github.com/repos/j-e-k/poketrainer/pulls/comments/72689812"},"html":{"href":"https://github.com/j-e-k/poketrainer/pull/216#discussion_r72689812"},"pull_request":{"href":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216"}}},"pull_request":{"url":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216","id":79254460,"html_url":"https://github.com/j-e-k/poketrainer/pull/216","diff_url":"https://github.com/j-e-k/poketrainer/pull/216.diff","patch_url":"https://github.com/j-e-k/poketrainer/pull/216.patch","issue_url":"https://api.github.com/repos/j-e-k/poketrainer/issues/216","number":216,"state":"open","locked":false,"title":"New config style and Release algorythm","user":{"login":"destiny117","id":3976393,"avatar_url":"https://avatars.githubusercontent.com/u/3976393?v=3","gravatar_id":"","url":"https://api.github.com/users/destiny117","html_url":"https://github.com/destiny117","followers_url":"https://api.github.com/users/destiny117/followers","following_url":"https://api.github.com/users/destiny117/following{/other_user}","gists_url":"https://api.github.com/users/destiny117/gists{/gist_id}","starred_url":"https://api.github.com/users/destiny117/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/destiny117/subscriptions","organizations_url":"https://api.github.com/users/destiny117/orgs","repos_url":"https://api.github.com/users/destiny117/repos","events_url":"https://api.github.com/users/destiny117/events{/privacy}","received_events_url":"https://api.github.com/users/destiny117/received_events","type":"User","site_admin":false},"body":"Not ready for pull yet\r\n\r\nmost important change:\r\n- the config file now has a \"default\" section which is appliet to all accounts.\r\n- furthermore many configs were grouped for better visibility and more logical structure\r\nthis is because the config file really got bloated and #127 did not receive any easy propositions yet, i hope this is good for now and ppl dont have too much of a hassle adapting their local configs\r\n\r\nnext i have reimplemented the releasing-algorythm from #110 because it feels way more natural for me.\r\n\r\ni am testing a bit now and waiting for feedback. will need to update the readme as well","created_at":"2016-07-28T19:32:35Z","updated_at":"2016-07-28T19:48:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216/commits","review_comments_url":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216/comments","review_comment_url":"https://api.github.com/repos/j-e-k/poketrainer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/j-e-k/poketrainer/issues/216/comments","statuses_url":"https://api.github.com/repos/j-e-k/poketrainer/statuses/6a1ebb0f7aa313f886d416f2a1cc879550f59fba","head":{"label":"destiny117:new-release-algorythm","ref":"new-release-algorythm","sha":"6a1ebb0f7aa313f886d416f2a1cc879550f59fba","user":{"login":"destiny117","id":3976393,"avatar_url":"https://avatars.githubusercontent.com/u/3976393?v=3","gravatar_id":"","url":"https://api.github.com/users/destiny117","html_url":"https://github.com/destiny117","followers_url":"https://api.github.com/users/destiny117/followers","following_url":"https://api.github.com/users/destiny117/following{/other_user}","gists_url":"https://api.github.com/users/destiny117/gists{/gist_id}","starred_url":"https://api.github.com/users/destiny117/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/destiny117/subscriptions","organizations_url":"https://api.github.com/users/destiny117/orgs","repos_url":"https://api.github.com/users/destiny117/repos","events_url":"https://api.github.com/users/destiny117/events{/privacy}","received_events_url":"https://api.github.com/users/destiny117/received_events","type":"User","site_admin":false},"repo":{"id":64405841,"name":"poketrainer","full_name":"destiny117/poketrainer","owner":{"login":"destiny117","id":3976393,"avatar_url":"https://avatars.githubusercontent.com/u/3976393?v=3","gravatar_id":"","url":"https://api.github.com/users/destiny117","html_url":"https://github.com/destiny117","followers_url":"https://api.github.com/users/destiny117/followers","following_url":"https://api.github.com/users/destiny117/following{/other_user}","gists_url":"https://api.github.com/users/destiny117/gists{/gist_id}","starred_url":"https://api.github.com/users/destiny117/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/destiny117/subscriptions","organizations_url":"https://api.github.com/users/destiny117/orgs","repos_url":"https://api.github.com/users/destiny117/repos","events_url":"https://api.github.com/users/destiny117/events{/privacy}","received_events_url":"https://api.github.com/users/destiny117/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/destiny117/poketrainer","description":"A poorly hacked together bot for Pokemon go (But actually, one of the first/most advanced/\"human\")","fork":true,"url":"https://api.github.com/repos/destiny117/poketrainer","forks_url":"https://api.github.com/repos/destiny117/poketrainer/forks","keys_url":"https://api.github.com/repos/destiny117/poketrainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/destiny117/poketrainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/destiny117/poketrainer/teams","hooks_url":"https://api.github.com/repos/destiny117/poketrainer/hooks","issue_events_url":"https://api.github.com/repos/destiny117/poketrainer/issues/events{/number}","events_url":"https://api.github.com/repos/destiny117/poketrainer/events","assignees_url":"https://api.github.com/repos/destiny117/poketrainer/assignees{/user}","branches_url":"https://api.github.com/repos/destiny117/poketrainer/branches{/branch}","tags_url":"https://api.github.com/repos/destiny117/poketrainer/tags","blobs_url":"https://api.github.com/repos/destiny117/poketrainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/destiny117/poketrainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/destiny117/poketrainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/destiny117/poketrainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/destiny117/poketrainer/statuses/{sha}","languages_url":"https://api.github.com/repos/destiny117/poketrainer/languages","stargazers_url":"https://api.github.com/repos/destiny117/poketrainer/stargazers","contributors_url":"https://api.github.com/repos/destiny117/poketrainer/contributors","subscribers_url":"https://api.github.com/repos/destiny117/poketrainer/subscribers","subscription_url":"https://api.github.com/repos/destiny117/poketrainer/subscription","commits_url":"https://api.github.com/repos/destiny117/poketrainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/destiny117/poketrainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/destiny117/poketrainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/destiny117/poketrainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/destiny117/poketrainer/contents/{+path}","compare_url":"https://api.github.com/repos/destiny117/poketrainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/destiny117/poketrainer/merges","archive_url":"https://api.github.com/repos/destiny117/poketrainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/destiny117/poketrainer/downloads","issues_url":"https://api.github.com/repos/destiny117/poketrainer/issues{/number}","pulls_url":"https://api.github.com/repos/destiny117/poketrainer/pulls{/number}","milestones_url":"https://api.github.com/repos/destiny117/poketrainer/milestones{/number}","notifications_url":"https://api.github.com/repos/destiny117/poketrainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/destiny117/poketrainer/labels{/name}","releases_url":"https://api.github.com/repos/destiny117/poketrainer/releases{/id}","deployments_url":"https://api.github.com/repos/destiny117/poketrainer/deployments","created_at":"2016-07-28T15:15:22Z","updated_at":"2016-07-28T15:15:23Z","pushed_at":"2016-07-28T19:26:21Z","git_url":"git://github.com/destiny117/poketrainer.git","ssh_url":"git@github.com:destiny117/poketrainer.git","clone_url":"https://github.com/destiny117/poketrainer.git","svn_url":"https://github.com/destiny117/poketrainer","homepage":"","size":2469,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"j-e-k:develop","ref":"develop","sha":"fae51425cb554154cc8886d14be04154e2d3a064","user":{"login":"j-e-k","id":2546697,"avatar_url":"https://avatars.githubusercontent.com/u/2546697?v=3","gravatar_id":"","url":"https://api.github.com/users/j-e-k","html_url":"https://github.com/j-e-k","followers_url":"https://api.github.com/users/j-e-k/followers","following_url":"https://api.github.com/users/j-e-k/following{/other_user}","gists_url":"https://api.github.com/users/j-e-k/gists{/gist_id}","starred_url":"https://api.github.com/users/j-e-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j-e-k/subscriptions","organizations_url":"https://api.github.com/users/j-e-k/orgs","repos_url":"https://api.github.com/users/j-e-k/repos","events_url":"https://api.github.com/users/j-e-k/events{/privacy}","received_events_url":"https://api.github.com/users/j-e-k/received_events","type":"User","site_admin":false},"repo":{"id":63714996,"name":"poketrainer","full_name":"j-e-k/poketrainer","owner":{"login":"j-e-k","id":2546697,"avatar_url":"https://avatars.githubusercontent.com/u/2546697?v=3","gravatar_id":"","url":"https://api.github.com/users/j-e-k","html_url":"https://github.com/j-e-k","followers_url":"https://api.github.com/users/j-e-k/followers","following_url":"https://api.github.com/users/j-e-k/following{/other_user}","gists_url":"https://api.github.com/users/j-e-k/gists{/gist_id}","starred_url":"https://api.github.com/users/j-e-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j-e-k/subscriptions","organizations_url":"https://api.github.com/users/j-e-k/orgs","repos_url":"https://api.github.com/users/j-e-k/repos","events_url":"https://api.github.com/users/j-e-k/events{/privacy}","received_events_url":"https://api.github.com/users/j-e-k/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/j-e-k/poketrainer","description":"A poorly hacked together bot for Pokemon go (But actually, one of the first/most advanced/\"human\")","fork":false,"url":"https://api.github.com/repos/j-e-k/poketrainer","forks_url":"https://api.github.com/repos/j-e-k/poketrainer/forks","keys_url":"https://api.github.com/repos/j-e-k/poketrainer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/j-e-k/poketrainer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/j-e-k/poketrainer/teams","hooks_url":"https://api.github.com/repos/j-e-k/poketrainer/hooks","issue_events_url":"https://api.github.com/repos/j-e-k/poketrainer/issues/events{/number}","events_url":"https://api.github.com/repos/j-e-k/poketrainer/events","assignees_url":"https://api.github.com/repos/j-e-k/poketrainer/assignees{/user}","branches_url":"https://api.github.com/repos/j-e-k/poketrainer/branches{/branch}","tags_url":"https://api.github.com/repos/j-e-k/poketrainer/tags","blobs_url":"https://api.github.com/repos/j-e-k/poketrainer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/j-e-k/poketrainer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/j-e-k/poketrainer/git/refs{/sha}","trees_url":"https://api.github.com/repos/j-e-k/poketrainer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/j-e-k/poketrainer/statuses/{sha}","languages_url":"https://api.github.com/repos/j-e-k/poketrainer/languages","stargazers_url":"https://api.github.com/repos/j-e-k/poketrainer/stargazers","contributors_url":"https://api.github.com/repos/j-e-k/poketrainer/contributors","subscribers_url":"https://api.github.com/repos/j-e-k/poketrainer/subscribers","subscription_url":"https://api.github.com/repos/j-e-k/poketrainer/subscription","commits_url":"https://api.github.com/repos/j-e-k/poketrainer/commits{/sha}","git_commits_url":"https://api.github.com/repos/j-e-k/poketrainer/git/commits{/sha}","comments_url":"https://api.github.com/repos/j-e-k/poketrainer/comments{/number}","issue_comment_url":"https://api.github.com/repos/j-e-k/poketrainer/issues/comments{/number}","contents_url":"https://api.github.com/repos/j-e-k/poketrainer/contents/{+path}","compare_url":"https://api.github.com/repos/j-e-k/poketrainer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/j-e-k/poketrainer/merges","archive_url":"https://api.github.com/repos/j-e-k/poketrainer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/j-e-k/poketrainer/downloads","issues_url":"https://api.github.com/repos/j-e-k/poketrainer/issues{/number}","pulls_url":"https://api.github.com/repos/j-e-k/poketrainer/pulls{/number}","milestones_url":"https://api.github.com/repos/j-e-k/poketrainer/milestones{/number}","notifications_url":"https://api.github.com/repos/j-e-k/poketrainer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/j-e-k/poketrainer/labels{/name}","releases_url":"https://api.github.com/repos/j-e-k/poketrainer/releases{/id}","deployments_url":"https://api.github.com/repos/j-e-k/poketrainer/deployments","created_at":"2016-07-19T17:38:59Z","updated_at":"2016-07-28T18:37:44Z","pushed_at":"2016-07-28T19:47:45Z","git_url":"git://github.com/j-e-k/poketrainer.git","ssh_url":"git@github.com:j-e-k/poketrainer.git","clone_url":"https://github.com/j-e-k/poketrainer.git","svn_url":"https://github.com/j-e-k/poketrainer","homepage":"","size":2756,"stargazers_count":103,"watchers_count":103,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":53,"mirror_url":null,"open_issues_count":43,"forks":53,"open_issues":43,"watchers":103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216"},"html":{"href":"https://github.com/j-e-k/poketrainer/pull/216"},"issue":{"href":"https://api.github.com/repos/j-e-k/poketrainer/issues/216"},"comments":{"href":"https://api.github.com/repos/j-e-k/poketrainer/issues/216/comments"},"review_comments":{"href":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216/comments"},"review_comment":{"href":"https://api.github.com/repos/j-e-k/poketrainer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/j-e-k/poketrainer/pulls/216/commits"},"statuses":{"href":"https://api.github.com/repos/j-e-k/poketrainer/statuses/6a1ebb0f7aa313f886d416f2a1cc879550f59fba"}}}}
{"actor":{"display_login":"destiny117"}}