{"action":"created","comment":{"url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/comments/35341028","id":35341028,"diff_hunk":"@@ -453,28 +492,45 @@ def generate_research_orders():\n     rng = random.Random()\n     rng.seed(fo.getEmpire().name + fo.getGalaxySetupData().seed)\n \n-    research_reqs = calculate_research_requirements(empire)\n+    calculate_research_requirements(empire)\n     total_rp = empire.resourceProduction(fo.resourceType.research)\n \n     if total_rp <= 0: # No RP available - no research.\n         return\n \n+    raw_priorities = {}\n     priorities = {}\n+    on_path_to = {}\n     for tech_name in fo.techs():\n-        priority = get_priority(rng, tech_name)\n+        this_tech = fo.getTech(tech_name)\n+        if not this_tech:\n+            continue\n+        raw_priorities[tech_name] = get_priority(rng, tech_name)\n+    for tech_name, priority in raw_priorities.iteritems():\n         if not tech_is_complete(tech_name) and priority >= 0:\n-            turn_needed = float(research_reqs[tech_name][1]) / total_rp\n-            priorities[tech_name] = float(priority) / turn_needed / max(1, (turn_needed - 12) / 4 + 1)**2\n+            turn_needed = max(research_reqs[tech_name][2], math.ceil(float(research_reqs[tech_name][1]) / total_rp))\n+            adjusted_priority = float(priority) / turn_needed / max(1, (turn_needed - 12) / 4 + 1)**2","path":"default/AI/ResearchAI.py","position":175,"original_position":175,"commit_id":"06e758951277f93fddc6dcfe2b0fcc06411a293f","original_commit_id":"06e758951277f93fddc6dcfe2b0fcc06411a293f","user":{"login":"Morlic-fo","id":11706951,"avatar_url":"https://avatars.githubusercontent.com/u/11706951?v=3","gravatar_id":"","url":"https://api.github.com/users/Morlic-fo","html_url":"https://github.com/Morlic-fo","followers_url":"https://api.github.com/users/Morlic-fo/followers","following_url":"https://api.github.com/users/Morlic-fo/following{/other_user}","gists_url":"https://api.github.com/users/Morlic-fo/gists{/gist_id}","starred_url":"https://api.github.com/users/Morlic-fo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Morlic-fo/subscriptions","organizations_url":"https://api.github.com/users/Morlic-fo/orgs","repos_url":"https://api.github.com/users/Morlic-fo/repos","events_url":"https://api.github.com/users/Morlic-fo/events{/privacy}","received_events_url":"https://api.github.com/users/Morlic-fo/received_events","type":"User","site_admin":false},"body":"Then again, after these techs are researched, if I started with the slow techs, I will be able to research the other ones much faster (assuming that our RP are growing in the meantime). The slow but cheap techs will still take maximum time.\r\n\r\nSo long story short, I don't consider this to be an issue resolved by a simple formula but something which would need a more complex approach which at least at this point in time is probably not worth it as this is a second order considerations while we have not solved most of the first-order problems yet...\r\n\r\nSo for now, I think we should ignore these timing considerations or at least not restrain a tech by long research time unless we find a very specific problem with the current tech tree that is related to this issue.","created_at":"2015-07-23T16:25:19Z","updated_at":"2015-07-23T16:25:19Z","html_url":"https://github.com/Dilvish-fo/freeorion/pull/6#discussion_r35341028","pull_request_url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/comments/35341028"},"html":{"href":"https://github.com/Dilvish-fo/freeorion/pull/6#discussion_r35341028"},"pull_request":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6","id":40620747,"html_url":"https://github.com/Dilvish-fo/freeorion/pull/6","diff_url":"https://github.com/Dilvish-fo/freeorion/pull/6.diff","patch_url":"https://github.com/Dilvish-fo/freeorion/pull/6.patch","issue_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/6","number":6,"state":"open","locked":false,"title":"Research ai adjustments","user":{"login":"Dilvish-fo","id":10995939,"avatar_url":"https://avatars.githubusercontent.com/u/10995939?v=3","gravatar_id":"","url":"https://api.github.com/users/Dilvish-fo","html_url":"https://github.com/Dilvish-fo","followers_url":"https://api.github.com/users/Dilvish-fo/followers","following_url":"https://api.github.com/users/Dilvish-fo/following{/other_user}","gists_url":"https://api.github.com/users/Dilvish-fo/gists{/gist_id}","starred_url":"https://api.github.com/users/Dilvish-fo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dilvish-fo/subscriptions","organizations_url":"https://api.github.com/users/Dilvish-fo/orgs","repos_url":"https://api.github.com/users/Dilvish-fo/repos","events_url":"https://api.github.com/users/Dilvish-fo/events{/privacy}","received_events_url":"https://api.github.com/users/Dilvish-fo/received_events","type":"User","site_admin":false},"body":"Since Phwk/luiges90 is also continuing to work on his own modifications to the initial ai rework, I'm putting these in a separate branch-- sort of a PR to  PR #5  :smiley: to help keep the various conversations distinct.\r\n\r\nMost of this is structural, some of it is tuning priority parameters; the latter will surely need a lot more work.","created_at":"2015-07-22T22:50:56Z","updated_at":"2015-07-23T16:25:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0168b84a3e8dea42dd88cfdc8b72e26cf955fe19","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6/commits","review_comments_url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6/comments","review_comment_url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/6/comments","statuses_url":"https://api.github.com/repos/Dilvish-fo/freeorion/statuses/06e758951277f93fddc6dcfe2b0fcc06411a293f","head":{"label":"Dilvish-fo:research-ai-adjustments","ref":"research-ai-adjustments","sha":"06e758951277f93fddc6dcfe2b0fcc06411a293f","user":{"login":"Dilvish-fo","id":10995939,"avatar_url":"https://avatars.githubusercontent.com/u/10995939?v=3","gravatar_id":"","url":"https://api.github.com/users/Dilvish-fo","html_url":"https://github.com/Dilvish-fo","followers_url":"https://api.github.com/users/Dilvish-fo/followers","following_url":"https://api.github.com/users/Dilvish-fo/following{/other_user}","gists_url":"https://api.github.com/users/Dilvish-fo/gists{/gist_id}","starred_url":"https://api.github.com/users/Dilvish-fo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dilvish-fo/subscriptions","organizations_url":"https://api.github.com/users/Dilvish-fo/orgs","repos_url":"https://api.github.com/users/Dilvish-fo/repos","events_url":"https://api.github.com/users/Dilvish-fo/events{/privacy}","received_events_url":"https://api.github.com/users/Dilvish-fo/received_events","type":"User","site_admin":false},"repo":{"id":33093847,"name":"freeorion","full_name":"Dilvish-fo/freeorion","owner":{"login":"Dilvish-fo","id":10995939,"avatar_url":"https://avatars.githubusercontent.com/u/10995939?v=3","gravatar_id":"","url":"https://api.github.com/users/Dilvish-fo","html_url":"https://github.com/Dilvish-fo","followers_url":"https://api.github.com/users/Dilvish-fo/followers","following_url":"https://api.github.com/users/Dilvish-fo/following{/other_user}","gists_url":"https://api.github.com/users/Dilvish-fo/gists{/gist_id}","starred_url":"https://api.github.com/users/Dilvish-fo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dilvish-fo/subscriptions","organizations_url":"https://api.github.com/users/Dilvish-fo/orgs","repos_url":"https://api.github.com/users/Dilvish-fo/repos","events_url":"https://api.github.com/users/Dilvish-fo/events{/privacy}","received_events_url":"https://api.github.com/users/Dilvish-fo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Dilvish-fo/freeorion","description":"Source code repository of the FreeOrion project.","fork":true,"url":"https://api.github.com/repos/Dilvish-fo/freeorion","forks_url":"https://api.github.com/repos/Dilvish-fo/freeorion/forks","keys_url":"https://api.github.com/repos/Dilvish-fo/freeorion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dilvish-fo/freeorion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dilvish-fo/freeorion/teams","hooks_url":"https://api.github.com/repos/Dilvish-fo/freeorion/hooks","issue_events_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/events{/number}","events_url":"https://api.github.com/repos/Dilvish-fo/freeorion/events","assignees_url":"https://api.github.com/repos/Dilvish-fo/freeorion/assignees{/user}","branches_url":"https://api.github.com/repos/Dilvish-fo/freeorion/branches{/branch}","tags_url":"https://api.github.com/repos/Dilvish-fo/freeorion/tags","blobs_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dilvish-fo/freeorion/statuses/{sha}","languages_url":"https://api.github.com/repos/Dilvish-fo/freeorion/languages","stargazers_url":"https://api.github.com/repos/Dilvish-fo/freeorion/stargazers","contributors_url":"https://api.github.com/repos/Dilvish-fo/freeorion/contributors","subscribers_url":"https://api.github.com/repos/Dilvish-fo/freeorion/subscribers","subscription_url":"https://api.github.com/repos/Dilvish-fo/freeorion/subscription","commits_url":"https://api.github.com/repos/Dilvish-fo/freeorion/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dilvish-fo/freeorion/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dilvish-fo/freeorion/contents/{+path}","compare_url":"https://api.github.com/repos/Dilvish-fo/freeorion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dilvish-fo/freeorion/merges","archive_url":"https://api.github.com/repos/Dilvish-fo/freeorion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dilvish-fo/freeorion/downloads","issues_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues{/number}","pulls_url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls{/number}","milestones_url":"https://api.github.com/repos/Dilvish-fo/freeorion/milestones{/number}","notifications_url":"https://api.github.com/repos/Dilvish-fo/freeorion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dilvish-fo/freeorion/labels{/name}","releases_url":"https://api.github.com/repos/Dilvish-fo/freeorion/releases{/id}","created_at":"2015-03-29T23:31:21Z","updated_at":"2015-07-23T01:07:45Z","pushed_at":"2015-07-22T22:50:58Z","git_url":"git://github.com/Dilvish-fo/freeorion.git","ssh_url":"git@github.com:Dilvish-fo/freeorion.git","clone_url":"https://github.com/Dilvish-fo/freeorion.git","svn_url":"https://github.com/Dilvish-fo/freeorion","homepage":"http://www.freeorion.org/","size":481740,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"Dilvish-fo:research-ai-example-cleanup","ref":"research-ai-example-cleanup","sha":"fec2d968af30dad4dd66c08bdd1edda11c25ea20","user":{"login":"Dilvish-fo","id":10995939,"avatar_url":"https://avatars.githubusercontent.com/u/10995939?v=3","gravatar_id":"","url":"https://api.github.com/users/Dilvish-fo","html_url":"https://github.com/Dilvish-fo","followers_url":"https://api.github.com/users/Dilvish-fo/followers","following_url":"https://api.github.com/users/Dilvish-fo/following{/other_user}","gists_url":"https://api.github.com/users/Dilvish-fo/gists{/gist_id}","starred_url":"https://api.github.com/users/Dilvish-fo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dilvish-fo/subscriptions","organizations_url":"https://api.github.com/users/Dilvish-fo/orgs","repos_url":"https://api.github.com/users/Dilvish-fo/repos","events_url":"https://api.github.com/users/Dilvish-fo/events{/privacy}","received_events_url":"https://api.github.com/users/Dilvish-fo/received_events","type":"User","site_admin":false},"repo":{"id":33093847,"name":"freeorion","full_name":"Dilvish-fo/freeorion","owner":{"login":"Dilvish-fo","id":10995939,"avatar_url":"https://avatars.githubusercontent.com/u/10995939?v=3","gravatar_id":"","url":"https://api.github.com/users/Dilvish-fo","html_url":"https://github.com/Dilvish-fo","followers_url":"https://api.github.com/users/Dilvish-fo/followers","following_url":"https://api.github.com/users/Dilvish-fo/following{/other_user}","gists_url":"https://api.github.com/users/Dilvish-fo/gists{/gist_id}","starred_url":"https://api.github.com/users/Dilvish-fo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dilvish-fo/subscriptions","organizations_url":"https://api.github.com/users/Dilvish-fo/orgs","repos_url":"https://api.github.com/users/Dilvish-fo/repos","events_url":"https://api.github.com/users/Dilvish-fo/events{/privacy}","received_events_url":"https://api.github.com/users/Dilvish-fo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Dilvish-fo/freeorion","description":"Source code repository of the FreeOrion project.","fork":true,"url":"https://api.github.com/repos/Dilvish-fo/freeorion","forks_url":"https://api.github.com/repos/Dilvish-fo/freeorion/forks","keys_url":"https://api.github.com/repos/Dilvish-fo/freeorion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dilvish-fo/freeorion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dilvish-fo/freeorion/teams","hooks_url":"https://api.github.com/repos/Dilvish-fo/freeorion/hooks","issue_events_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/events{/number}","events_url":"https://api.github.com/repos/Dilvish-fo/freeorion/events","assignees_url":"https://api.github.com/repos/Dilvish-fo/freeorion/assignees{/user}","branches_url":"https://api.github.com/repos/Dilvish-fo/freeorion/branches{/branch}","tags_url":"https://api.github.com/repos/Dilvish-fo/freeorion/tags","blobs_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dilvish-fo/freeorion/statuses/{sha}","languages_url":"https://api.github.com/repos/Dilvish-fo/freeorion/languages","stargazers_url":"https://api.github.com/repos/Dilvish-fo/freeorion/stargazers","contributors_url":"https://api.github.com/repos/Dilvish-fo/freeorion/contributors","subscribers_url":"https://api.github.com/repos/Dilvish-fo/freeorion/subscribers","subscription_url":"https://api.github.com/repos/Dilvish-fo/freeorion/subscription","commits_url":"https://api.github.com/repos/Dilvish-fo/freeorion/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dilvish-fo/freeorion/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dilvish-fo/freeorion/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dilvish-fo/freeorion/contents/{+path}","compare_url":"https://api.github.com/repos/Dilvish-fo/freeorion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dilvish-fo/freeorion/merges","archive_url":"https://api.github.com/repos/Dilvish-fo/freeorion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dilvish-fo/freeorion/downloads","issues_url":"https://api.github.com/repos/Dilvish-fo/freeorion/issues{/number}","pulls_url":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls{/number}","milestones_url":"https://api.github.com/repos/Dilvish-fo/freeorion/milestones{/number}","notifications_url":"https://api.github.com/repos/Dilvish-fo/freeorion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dilvish-fo/freeorion/labels{/name}","releases_url":"https://api.github.com/repos/Dilvish-fo/freeorion/releases{/id}","created_at":"2015-03-29T23:31:21Z","updated_at":"2015-07-23T01:07:45Z","pushed_at":"2015-07-22T22:50:58Z","git_url":"git://github.com/Dilvish-fo/freeorion.git","ssh_url":"git@github.com:Dilvish-fo/freeorion.git","clone_url":"https://github.com/Dilvish-fo/freeorion.git","svn_url":"https://github.com/Dilvish-fo/freeorion","homepage":"http://www.freeorion.org/","size":481740,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6"},"html":{"href":"https://github.com/Dilvish-fo/freeorion/pull/6"},"issue":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/6"},"comments":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/Dilvish-fo/freeorion/statuses/06e758951277f93fddc6dcfe2b0fcc06411a293f"}}}}