{"action":"created","comment":{"url":"https://api.github.com/repos/freeorion/freeorion/pulls/comments/67743660","id":67743660,"diff_hunk":"@@ -84,13 +84,37 @@ def generate_systems(pos_list, gsd):\n                               % (position[0], position[1]))\n             continue\n         sys_list.append(system)\n-        for orbit in range(fo.sys_get_num_orbits(system)):\n-            # check for each orbit if a planet shall be created by determining planet size\n-            planet_size = planets.calc_planet_size(star_type, orbit, gsd.planet_density, gsd.shape)\n-            if planet_size in planets.planet_sizes:\n-                # ok, we want a planet, determine planet type and generate the planet\n-                planet_type = planets.calc_planet_type(star_type, orbit, planet_size)\n-                if fo.create_planet(planet_size, planet_type, system, orbit, \"\") == fo.invalid_object():\n-                    # create planet failed, report an error and try to continue with next orbit\n-                    util.report_error(\"Python generate_systems: create planet in system %d failed\" % system)\n+\n+        orbits = range(fo.sys_get_num_orbits(system))\n+\n+        if not planets.can_have_planets(star_type, orbits, gsd.planet_density, gsd.shape):\n+            continue\n+\n+        # Try to generate planets in each orbit.\n+        # If after each orbit is tried once there are no planets then\n+        # keep trying until a single planet is placed.\n+        # Except for black hole systems, which can be empty.\n+\n+        at_least_one_planet = False\n+        random.shuffle(orbits)\n+        for orbit in orbits:\n+            if planets.generate_a_planet(system, star_type, orbit, gsd.planet_density, gsd.shape):\n+                at_least_one_planet = True\n+\n+        if star_type == fo.starType.blackHole:\n+            continue\n+\n+        ii_safety = 1000\n+        while not at_least_one_planet and ii_safety > 0:\n+            ii_safety -= 1\n+            for orbit in orbits:\n+                if planets.generate_a_planet(system, star_type, orbit, gsd.planet_density, gsd.shape):\n+                    at_least_one_planet = True","path":"default/python/universe_generation/starsystems.py","position":38,"original_position":38,"commit_id":"2b5ba51545935a28bf183059f766ee493e0ac299","original_commit_id":"2b5ba51545935a28bf183059f766ee493e0ac299","user":{"login":"Cjkjvfnby","id":171597,"avatar_url":"https://avatars.githubusercontent.com/u/171597?v=3","gravatar_id":"","url":"https://api.github.com/users/Cjkjvfnby","html_url":"https://github.com/Cjkjvfnby","followers_url":"https://api.github.com/users/Cjkjvfnby/followers","following_url":"https://api.github.com/users/Cjkjvfnby/following{/other_user}","gists_url":"https://api.github.com/users/Cjkjvfnby/gists{/gist_id}","starred_url":"https://api.github.com/users/Cjkjvfnby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cjkjvfnby/subscriptions","organizations_url":"https://api.github.com/users/Cjkjvfnby/orgs","repos_url":"https://api.github.com/users/Cjkjvfnby/repos","events_url":"https://api.github.com/users/Cjkjvfnby/events{/privacy}","received_events_url":"https://api.github.com/users/Cjkjvfnby/received_events","type":"User","site_admin":false},"body":"You can drop some variables and simplify this code\r\n```python\r\nfor x in xrange(1000):\r\n    if condition:\r\n        break\r\nelse:  # if no break was in cycle\r\n    print >> sys.stderr\r\n```","created_at":"2016-06-20T18:43:03Z","updated_at":"2016-06-20T18:43:03Z","html_url":"https://github.com/freeorion/freeorion/pull/718#discussion_r67743660","pull_request_url":"https://api.github.com/repos/freeorion/freeorion/pulls/718","_links":{"self":{"href":"https://api.github.com/repos/freeorion/freeorion/pulls/comments/67743660"},"html":{"href":"https://github.com/freeorion/freeorion/pull/718#discussion_r67743660"},"pull_request":{"href":"https://api.github.com/repos/freeorion/freeorion/pulls/718"}}},"pull_request":{"url":"https://api.github.com/repos/freeorion/freeorion/pulls/718","id":74347790,"html_url":"https://github.com/freeorion/freeorion/pull/718","diff_url":"https://github.com/freeorion/freeorion/pull/718.diff","patch_url":"https://github.com/freeorion/freeorion/pull/718.patch","issue_url":"https://api.github.com/repos/freeorion/freeorion/issues/718","number":718,"state":"open","locked":false,"title":"Require systems with non black hole stars to have a satellite.","user":{"login":"LGM-Doyle","id":17235966,"avatar_url":"https://avatars.githubusercontent.com/u/17235966?v=3","gravatar_id":"","url":"https://api.github.com/users/LGM-Doyle","html_url":"https://github.com/LGM-Doyle","followers_url":"https://api.github.com/users/LGM-Doyle/followers","following_url":"https://api.github.com/users/LGM-Doyle/following{/other_user}","gists_url":"https://api.github.com/users/LGM-Doyle/gists{/gist_id}","starred_url":"https://api.github.com/users/LGM-Doyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LGM-Doyle/subscriptions","organizations_url":"https://api.github.com/users/LGM-Doyle/orgs","repos_url":"https://api.github.com/users/LGM-Doyle/repos","events_url":"https://api.github.com/users/LGM-Doyle/events{/privacy}","received_events_url":"https://api.github.com/users/LGM-Doyle/received_events","type":"User","site_admin":false},"body":"@MatGB suggested this change.  \r\n\r\nOnce he suggested it I started to notice how much time I was spending clicking on systems with stars, because I couldn't remember if they had planets or not.\r\n\r\n@MatGB may want to rebalance it to have fewer stars, since they all now have at least one planet/asteroids.\r\n\r\nI still allowed black holes to have no planets.  I think that they are rare and that flavor-wise the absence of planets works.","created_at":"2016-06-18T21:27:08Z","updated_at":"2016-06-20T18:43:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a16245f28f1dfce9370f1eb89c522052ee51564f","assignee":{"login":"Vezzra","id":10279417,"avatar_url":"https://avatars.githubusercontent.com/u/10279417?v=3","gravatar_id":"","url":"https://api.github.com/users/Vezzra","html_url":"https://github.com/Vezzra","followers_url":"https://api.github.com/users/Vezzra/followers","following_url":"https://api.github.com/users/Vezzra/following{/other_user}","gists_url":"https://api.github.com/users/Vezzra/gists{/gist_id}","starred_url":"https://api.github.com/users/Vezzra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vezzra/subscriptions","organizations_url":"https://api.github.com/users/Vezzra/orgs","repos_url":"https://api.github.com/users/Vezzra/repos","events_url":"https://api.github.com/users/Vezzra/events{/privacy}","received_events_url":"https://api.github.com/users/Vezzra/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/freeorion/freeorion/milestones/15","html_url":"https://github.com/freeorion/freeorion/milestones/Release%20v0.4.6","labels_url":"https://api.github.com/repos/freeorion/freeorion/milestones/15/labels","id":1226316,"number":15,"title":"Release v0.4.6","description":"Bugs, features and pull requests that should be fixed/finalized for the 0.4.6 release.","creator":{"login":"adrianbroher","id":84891,"avatar_url":"https://avatars.githubusercontent.com/u/84891?v=3","gravatar_id":"","url":"https://api.github.com/users/adrianbroher","html_url":"https://github.com/adrianbroher","followers_url":"https://api.github.com/users/adrianbroher/followers","following_url":"https://api.github.com/users/adrianbroher/following{/other_user}","gists_url":"https://api.github.com/users/adrianbroher/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianbroher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianbroher/subscriptions","organizations_url":"https://api.github.com/users/adrianbroher/orgs","repos_url":"https://api.github.com/users/adrianbroher/repos","events_url":"https://api.github.com/users/adrianbroher/events{/privacy}","received_events_url":"https://api.github.com/users/adrianbroher/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":330,"state":"open","created_at":"2015-07-26T16:21:09Z","updated_at":"2016-06-20T18:30:44Z","due_on":"2016-06-29T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/freeorion/freeorion/pulls/718/commits","review_comments_url":"https://api.github.com/repos/freeorion/freeorion/pulls/718/comments","review_comment_url":"https://api.github.com/repos/freeorion/freeorion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/freeorion/freeorion/issues/718/comments","statuses_url":"https://api.github.com/repos/freeorion/freeorion/statuses/2b5ba51545935a28bf183059f766ee493e0ac299","head":{"label":"LGM-Doyle:change_all_systems_have_a_planet","ref":"change_all_systems_have_a_planet","sha":"2b5ba51545935a28bf183059f766ee493e0ac299","user":{"login":"LGM-Doyle","id":17235966,"avatar_url":"https://avatars.githubusercontent.com/u/17235966?v=3","gravatar_id":"","url":"https://api.github.com/users/LGM-Doyle","html_url":"https://github.com/LGM-Doyle","followers_url":"https://api.github.com/users/LGM-Doyle/followers","following_url":"https://api.github.com/users/LGM-Doyle/following{/other_user}","gists_url":"https://api.github.com/users/LGM-Doyle/gists{/gist_id}","starred_url":"https://api.github.com/users/LGM-Doyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LGM-Doyle/subscriptions","organizations_url":"https://api.github.com/users/LGM-Doyle/orgs","repos_url":"https://api.github.com/users/LGM-Doyle/repos","events_url":"https://api.github.com/users/LGM-Doyle/events{/privacy}","received_events_url":"https://api.github.com/users/LGM-Doyle/received_events","type":"User","site_admin":false},"repo":{"id":51704490,"name":"freeorion","full_name":"LGM-Doyle/freeorion","owner":{"login":"LGM-Doyle","id":17235966,"avatar_url":"https://avatars.githubusercontent.com/u/17235966?v=3","gravatar_id":"","url":"https://api.github.com/users/LGM-Doyle","html_url":"https://github.com/LGM-Doyle","followers_url":"https://api.github.com/users/LGM-Doyle/followers","following_url":"https://api.github.com/users/LGM-Doyle/following{/other_user}","gists_url":"https://api.github.com/users/LGM-Doyle/gists{/gist_id}","starred_url":"https://api.github.com/users/LGM-Doyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LGM-Doyle/subscriptions","organizations_url":"https://api.github.com/users/LGM-Doyle/orgs","repos_url":"https://api.github.com/users/LGM-Doyle/repos","events_url":"https://api.github.com/users/LGM-Doyle/events{/privacy}","received_events_url":"https://api.github.com/users/LGM-Doyle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LGM-Doyle/freeorion","description":"Source code repository of the FreeOrion project.","fork":true,"url":"https://api.github.com/repos/LGM-Doyle/freeorion","forks_url":"https://api.github.com/repos/LGM-Doyle/freeorion/forks","keys_url":"https://api.github.com/repos/LGM-Doyle/freeorion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LGM-Doyle/freeorion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LGM-Doyle/freeorion/teams","hooks_url":"https://api.github.com/repos/LGM-Doyle/freeorion/hooks","issue_events_url":"https://api.github.com/repos/LGM-Doyle/freeorion/issues/events{/number}","events_url":"https://api.github.com/repos/LGM-Doyle/freeorion/events","assignees_url":"https://api.github.com/repos/LGM-Doyle/freeorion/assignees{/user}","branches_url":"https://api.github.com/repos/LGM-Doyle/freeorion/branches{/branch}","tags_url":"https://api.github.com/repos/LGM-Doyle/freeorion/tags","blobs_url":"https://api.github.com/repos/LGM-Doyle/freeorion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LGM-Doyle/freeorion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LGM-Doyle/freeorion/git/refs{/sha}","trees_url":"https://api.github.com/repos/LGM-Doyle/freeorion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LGM-Doyle/freeorion/statuses/{sha}","languages_url":"https://api.github.com/repos/LGM-Doyle/freeorion/languages","stargazers_url":"https://api.github.com/repos/LGM-Doyle/freeorion/stargazers","contributors_url":"https://api.github.com/repos/LGM-Doyle/freeorion/contributors","subscribers_url":"https://api.github.com/repos/LGM-Doyle/freeorion/subscribers","subscription_url":"https://api.github.com/repos/LGM-Doyle/freeorion/subscription","commits_url":"https://api.github.com/repos/LGM-Doyle/freeorion/commits{/sha}","git_commits_url":"https://api.github.com/repos/LGM-Doyle/freeorion/git/commits{/sha}","comments_url":"https://api.github.com/repos/LGM-Doyle/freeorion/comments{/number}","issue_comment_url":"https://api.github.com/repos/LGM-Doyle/freeorion/issues/comments{/number}","contents_url":"https://api.github.com/repos/LGM-Doyle/freeorion/contents/{+path}","compare_url":"https://api.github.com/repos/LGM-Doyle/freeorion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LGM-Doyle/freeorion/merges","archive_url":"https://api.github.com/repos/LGM-Doyle/freeorion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LGM-Doyle/freeorion/downloads","issues_url":"https://api.github.com/repos/LGM-Doyle/freeorion/issues{/number}","pulls_url":"https://api.github.com/repos/LGM-Doyle/freeorion/pulls{/number}","milestones_url":"https://api.github.com/repos/LGM-Doyle/freeorion/milestones{/number}","notifications_url":"https://api.github.com/repos/LGM-Doyle/freeorion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LGM-Doyle/freeorion/labels{/name}","releases_url":"https://api.github.com/repos/LGM-Doyle/freeorion/releases{/id}","deployments_url":"https://api.github.com/repos/LGM-Doyle/freeorion/deployments","created_at":"2016-02-14T17:21:56Z","updated_at":"2016-02-14T17:22:02Z","pushed_at":"2016-06-18T21:39:16Z","git_url":"git://github.com/LGM-Doyle/freeorion.git","ssh_url":"git@github.com:LGM-Doyle/freeorion.git","clone_url":"https://github.com/LGM-Doyle/freeorion.git","svn_url":"https://github.com/LGM-Doyle/freeorion","homepage":"http://www.freeorion.org/","size":516776,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"freeorion:master","ref":"master","sha":"938e1daffaf1fff4d4a33be216f0893f2298a382","user":{"login":"freeorion","id":1025550,"avatar_url":"https://avatars.githubusercontent.com/u/1025550?v=3","gravatar_id":"","url":"https://api.github.com/users/freeorion","html_url":"https://github.com/freeorion","followers_url":"https://api.github.com/users/freeorion/followers","following_url":"https://api.github.com/users/freeorion/following{/other_user}","gists_url":"https://api.github.com/users/freeorion/gists{/gist_id}","starred_url":"https://api.github.com/users/freeorion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeorion/subscriptions","organizations_url":"https://api.github.com/users/freeorion/orgs","repos_url":"https://api.github.com/users/freeorion/repos","events_url":"https://api.github.com/users/freeorion/events{/privacy}","received_events_url":"https://api.github.com/users/freeorion/received_events","type":"Organization","site_admin":false},"repo":{"id":33066062,"name":"freeorion","full_name":"freeorion/freeorion","owner":{"login":"freeorion","id":1025550,"avatar_url":"https://avatars.githubusercontent.com/u/1025550?v=3","gravatar_id":"","url":"https://api.github.com/users/freeorion","html_url":"https://github.com/freeorion","followers_url":"https://api.github.com/users/freeorion/followers","following_url":"https://api.github.com/users/freeorion/following{/other_user}","gists_url":"https://api.github.com/users/freeorion/gists{/gist_id}","starred_url":"https://api.github.com/users/freeorion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeorion/subscriptions","organizations_url":"https://api.github.com/users/freeorion/orgs","repos_url":"https://api.github.com/users/freeorion/repos","events_url":"https://api.github.com/users/freeorion/events{/privacy}","received_events_url":"https://api.github.com/users/freeorion/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/freeorion/freeorion","description":"Source code repository of the FreeOrion project.","fork":false,"url":"https://api.github.com/repos/freeorion/freeorion","forks_url":"https://api.github.com/repos/freeorion/freeorion/forks","keys_url":"https://api.github.com/repos/freeorion/freeorion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freeorion/freeorion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freeorion/freeorion/teams","hooks_url":"https://api.github.com/repos/freeorion/freeorion/hooks","issue_events_url":"https://api.github.com/repos/freeorion/freeorion/issues/events{/number}","events_url":"https://api.github.com/repos/freeorion/freeorion/events","assignees_url":"https://api.github.com/repos/freeorion/freeorion/assignees{/user}","branches_url":"https://api.github.com/repos/freeorion/freeorion/branches{/branch}","tags_url":"https://api.github.com/repos/freeorion/freeorion/tags","blobs_url":"https://api.github.com/repos/freeorion/freeorion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freeorion/freeorion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freeorion/freeorion/git/refs{/sha}","trees_url":"https://api.github.com/repos/freeorion/freeorion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freeorion/freeorion/statuses/{sha}","languages_url":"https://api.github.com/repos/freeorion/freeorion/languages","stargazers_url":"https://api.github.com/repos/freeorion/freeorion/stargazers","contributors_url":"https://api.github.com/repos/freeorion/freeorion/contributors","subscribers_url":"https://api.github.com/repos/freeorion/freeorion/subscribers","subscription_url":"https://api.github.com/repos/freeorion/freeorion/subscription","commits_url":"https://api.github.com/repos/freeorion/freeorion/commits{/sha}","git_commits_url":"https://api.github.com/repos/freeorion/freeorion/git/commits{/sha}","comments_url":"https://api.github.com/repos/freeorion/freeorion/comments{/number}","issue_comment_url":"https://api.github.com/repos/freeorion/freeorion/issues/comments{/number}","contents_url":"https://api.github.com/repos/freeorion/freeorion/contents/{+path}","compare_url":"https://api.github.com/repos/freeorion/freeorion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freeorion/freeorion/merges","archive_url":"https://api.github.com/repos/freeorion/freeorion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freeorion/freeorion/downloads","issues_url":"https://api.github.com/repos/freeorion/freeorion/issues{/number}","pulls_url":"https://api.github.com/repos/freeorion/freeorion/pulls{/number}","milestones_url":"https://api.github.com/repos/freeorion/freeorion/milestones{/number}","notifications_url":"https://api.github.com/repos/freeorion/freeorion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freeorion/freeorion/labels{/name}","releases_url":"https://api.github.com/repos/freeorion/freeorion/releases{/id}","deployments_url":"https://api.github.com/repos/freeorion/freeorion/deployments","created_at":"2015-03-29T08:22:20Z","updated_at":"2016-06-18T17:04:05Z","pushed_at":"2016-06-20T18:28:31Z","git_url":"git://github.com/freeorion/freeorion.git","ssh_url":"git@github.com:freeorion/freeorion.git","clone_url":"https://github.com/freeorion/freeorion.git","svn_url":"https://github.com/freeorion/freeorion","homepage":"http://www.freeorion.org/","size":535403,"stargazers_count":148,"watchers_count":148,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":57,"mirror_url":null,"open_issues_count":69,"forks":57,"open_issues":69,"watchers":148,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freeorion/freeorion/pulls/718"},"html":{"href":"https://github.com/freeorion/freeorion/pull/718"},"issue":{"href":"https://api.github.com/repos/freeorion/freeorion/issues/718"},"comments":{"href":"https://api.github.com/repos/freeorion/freeorion/issues/718/comments"},"review_comments":{"href":"https://api.github.com/repos/freeorion/freeorion/pulls/718/comments"},"review_comment":{"href":"https://api.github.com/repos/freeorion/freeorion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/freeorion/freeorion/pulls/718/commits"},"statuses":{"href":"https://api.github.com/repos/freeorion/freeorion/statuses/2b5ba51545935a28bf183059f766ee493e0ac299"}}}}
{"actor":{"display_login":"Cjkjvfnby"}}