{"action":"created","comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/47134185","id":47134185,"diff_hunk":"@@ -2798,38 +2801,67 @@ spawns happen at... <cue Clue music>\n 20:56 <kevingranade>: game:pawn_mon() in game.cpp:7380*/\n void overmap::place_cities()\n {\n-    int NUM_CITIES = dice(4, 4);\n-    int start_dir;\n     int op_city_size = int(ACTIVE_WORLD_OPTIONS[\"CITY_SIZE\"]);\n     if( op_city_size <= 0 ) {\n         return;\n     }\n-    // Limit number of cities based on average size.\n-    NUM_CITIES = std::min(NUM_CITIES, int(256 / op_city_size * op_city_size));\n-\n-    // Generate a list of random cities in accordance with village/town/city rules.\n-    int village_size = std::max(op_city_size - 2, 1);\n-    int town_min = std::max(op_city_size - 1, 1);\n-    int town_max = op_city_size + 1;\n-    int city_size = op_city_size + 3;\n-\n-    while (cities.size() < size_t(NUM_CITIES)) {\n-        int cx = rng(12, OMAPX - 12);\n-        int cy = rng(12, OMAPY - 12);\n-        int size = dice(town_min, town_max);\n-        if (one_in(6)) {\n-            size = city_size;\n-        } else if (one_in(3)) {\n-            size = village_size;\n-        }\n+    int op_city_spacing = int(ACTIVE_WORLD_OPTIONS[\"CITY_SPACING\"]);\n+\n+    // spacing dictates how much of the map is covered in cities\n+    //   city  |  cities  |   size N cities per overmap\n+    // spacing | % of map |  2  |  4  |  8  |  12 |  16\n+    //     0   |   ~99    |2025 | 506 | 126 |  56 |  31\n+    //     1   |    50    |1012 | 253 |  63 |  28 |  15\n+    //     2   |    25    | 506 | 126 |  31 |  14 |   7\n+    //     3   |    12    | 253 |  63 |  15 |   7 |   3\n+    //     4   |     6    | 126 |  31 |   7 |   3 |   1\n+    //     5   |     3    |  63 |  15 |   3 |   1 |   0\n+    //     6   |     1    |  31 |   7 |   1 |   0 |   0\n+    //     7   |     0    |  15 |   3 |   0 |   0 |   0\n+    //     8   |     0    |   7 |   1 |   0 |   0 |   0\n+\n+    double NUM_CITIES_d =\n+        (double(OMAPX*OMAPX)) // OMTs per overmap\n+        /\n+        (std::pow(2.0, op_city_spacing)) // cities cover 1/(2**n)th of the map\n+        /\n+        ((op_city_size*2+1) * (op_city_size*2+1) * 3 / 4); // OMTs per city\n+\n+    int NUM_CITIES = NUM_CITIES_d;\n+\n+    // chance of one extra city, or the only city for low densities\n+    double EXTRA_CHANCE = NUM_CITIES_d - NUM_CITIES;\n+\n+    // place a seed for NUM_CITIES cities, and maybe one more\n+    while (\n+        cities.size() < size_t(NUM_CITIES) ||\n+        ( cities.size() == size_t(NUM_CITIES) && x_in_y(EXTRA_CHANCE,1.0) )","path":"src/overmap.cpp","position":120,"original_position":120,"commit_id":"13a39421ea614167b7a11b84354dfda8b25219b0","original_commit_id":"13a39421ea614167b7a11b84354dfda8b25219b0","user":{"login":"sparr","id":121299,"avatar_url":"https://avatars.githubusercontent.com/u/121299?v=3","gravatar_id":"","url":"https://api.github.com/users/sparr","html_url":"https://github.com/sparr","followers_url":"https://api.github.com/users/sparr/followers","following_url":"https://api.github.com/users/sparr/following{/other_user}","gists_url":"https://api.github.com/users/sparr/gists{/gist_id}","starred_url":"https://api.github.com/users/sparr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparr/subscriptions","organizations_url":"https://api.github.com/users/sparr/orgs","repos_url":"https://api.github.com/users/sparr/repos","events_url":"https://api.github.com/users/sparr/events{/privacy}","received_events_url":"https://api.github.com/users/sparr/received_events","type":"User","site_admin":false},"body":"I didn't know about it. I'm not a huge fan of how using it looks, since it replaces one of the existing division operations. I think I'm gonna break roll_remainder out from divide_roll_remainder.","created_at":"2015-12-09T18:54:46Z","updated_at":"2015-12-09T18:54:46Z","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/14362#discussion_r47134185","pull_request_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362","_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments/47134185"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/14362#discussion_r47134185"},"pull_request":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362"}}},"pull_request":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362","id":53087432,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/14362","diff_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/14362.diff","patch_url":"https://github.com/CleverRaven/Cataclysm-DDA/pull/14362.patch","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/14362","number":14362,"state":"open","locked":false,"title":"City spacing option [CR]","user":{"login":"sparr","id":121299,"avatar_url":"https://avatars.githubusercontent.com/u/121299?v=3","gravatar_id":"","url":"https://api.github.com/users/sparr","html_url":"https://github.com/sparr","followers_url":"https://api.github.com/users/sparr/followers","following_url":"https://api.github.com/users/sparr/following{/other_user}","gists_url":"https://api.github.com/users/sparr/gists{/gist_id}","starred_url":"https://api.github.com/users/sparr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparr/subscriptions","organizations_url":"https://api.github.com/users/sparr/orgs","repos_url":"https://api.github.com/users/sparr/repos","events_url":"https://api.github.com/users/sparr/events{/privacy}","received_events_url":"https://api.github.com/users/sparr/received_events","type":"User","site_admin":false},"body":"First and foremost, this patch corrects a couple of logic/arithmetic bugs in some of the world generation code. City generation was meant to work differently than it does. The default behavior at different city sizes will be more sensible now.\r\n\r\nThis patch also adds a world generation option for \"City Spacing\". Leaving this alone while adjusting City Size will behave as city size was always supposed to behave but never really did.\r\n\r\nCity Spacing 0 gives you a map almost entirely comprised of city. Even more solid than the old buggy City Size 16.\r\n\r\nCity Spacing 1 fills about 50% of the map with city. Most cities will directly touch one of their neighbors.\r\n\r\nCity Spacing 4 fills about 6% of the map with city. This is close to the old behavior at City Size 4.\r\n\r\nCity Spacing 8 fills only 0.4% of the map with city. This is very very sparse. At City Size 1 there will be just 31 \"cities\" per overmap. At City Size 16 there will be one big city every 8 overmaps, with only wilderness and specials in between.\r\n\r\nI also changed the distribution of random city sizes. Previously the smallest cities would only be a few sizes smaller than the largest cities. Now every map will have a bunch of size=1 cities which means little 2-3 building outposts along the road, and a few cities double the requested size.\r\n\r\nThis patch also half-fixes the empty stripes of land along overmap boundaries. We still can't generate a city that spans the border, but I added a little logic to put smaller cities closer to the edge, instead of leaving a boundary wide enough for the biggest cities.\r\n\r\nI am very open to suggestions for changing the default values or behaviors. Also changing the distribution of city sizes for a given City Size setting.\r\n\r\nI am somewhat open to suggestions for changing what the spacing setting means. Currently with a constant spacing setting the absolute distance between cities goes up as the city size setting goes up. I could reconsider that and make the distances not correlate to the sizes, so size 1 and size 16 cities would be the same distance apart with the same distance setting.\r\n\r\nCloses #14360 ","created_at":"2015-12-09T08:02:41Z","updated_at":"2015-12-09T18:54:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fedada0e49c25132c78fc5eb8c28e4addf9bb06e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362/commits","review_comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362/comments","review_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/14362/comments","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/13a39421ea614167b7a11b84354dfda8b25219b0","head":{"label":"sparr:city_spacing_option","ref":"city_spacing_option","sha":"13a39421ea614167b7a11b84354dfda8b25219b0","user":{"login":"sparr","id":121299,"avatar_url":"https://avatars.githubusercontent.com/u/121299?v=3","gravatar_id":"","url":"https://api.github.com/users/sparr","html_url":"https://github.com/sparr","followers_url":"https://api.github.com/users/sparr/followers","following_url":"https://api.github.com/users/sparr/following{/other_user}","gists_url":"https://api.github.com/users/sparr/gists{/gist_id}","starred_url":"https://api.github.com/users/sparr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparr/subscriptions","organizations_url":"https://api.github.com/users/sparr/orgs","repos_url":"https://api.github.com/users/sparr/repos","events_url":"https://api.github.com/users/sparr/events{/privacy}","received_events_url":"https://api.github.com/users/sparr/received_events","type":"User","site_admin":false},"repo":{"id":32027760,"name":"Cataclysm-DDA","full_name":"sparr/Cataclysm-DDA","owner":{"login":"sparr","id":121299,"avatar_url":"https://avatars.githubusercontent.com/u/121299?v=3","gravatar_id":"","url":"https://api.github.com/users/sparr","html_url":"https://github.com/sparr","followers_url":"https://api.github.com/users/sparr/followers","following_url":"https://api.github.com/users/sparr/following{/other_user}","gists_url":"https://api.github.com/users/sparr/gists{/gist_id}","starred_url":"https://api.github.com/users/sparr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparr/subscriptions","organizations_url":"https://api.github.com/users/sparr/orgs","repos_url":"https://api.github.com/users/sparr/repos","events_url":"https://api.github.com/users/sparr/events{/privacy}","received_events_url":"https://api.github.com/users/sparr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sparr/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":true,"url":"https://api.github.com/repos/sparr/Cataclysm-DDA","forks_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/sparr/Cataclysm-DDA/releases{/id}","created_at":"2015-03-11T16:16:29Z","updated_at":"2015-04-23T01:47:10Z","pushed_at":"2015-12-09T09:13:35Z","git_url":"git://github.com/sparr/Cataclysm-DDA.git","ssh_url":"git@github.com:sparr/Cataclysm-DDA.git","clone_url":"https://github.com/sparr/Cataclysm-DDA.git","svn_url":"https://github.com/sparr/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":598689,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"CleverRaven:master","ref":"master","sha":"b6029b6c5cc65ac9f0dd6bb3b55481a2d9e74c6e","user":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"repo":{"id":5973855,"name":"Cataclysm-DDA","full_name":"CleverRaven/Cataclysm-DDA","owner":{"login":"CleverRaven","id":4367009,"avatar_url":"https://avatars.githubusercontent.com/u/4367009?v=3","gravatar_id":"","url":"https://api.github.com/users/CleverRaven","html_url":"https://github.com/CleverRaven","followers_url":"https://api.github.com/users/CleverRaven/followers","following_url":"https://api.github.com/users/CleverRaven/following{/other_user}","gists_url":"https://api.github.com/users/CleverRaven/gists{/gist_id}","starred_url":"https://api.github.com/users/CleverRaven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CleverRaven/subscriptions","organizations_url":"https://api.github.com/users/CleverRaven/orgs","repos_url":"https://api.github.com/users/CleverRaven/repos","events_url":"https://api.github.com/users/CleverRaven/events{/privacy}","received_events_url":"https://api.github.com/users/CleverRaven/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CleverRaven/Cataclysm-DDA","description":"Cataclysm - Dark Days Ahead. A fork/variant of Cataclysm Roguelike by Whales.","fork":false,"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA","forks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/forks","keys_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/teams","hooks_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/hooks","issue_events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/events{/number}","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/events","assignees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/assignees{/user}","branches_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/branches{/branch}","tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/tags","blobs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/refs{/sha}","trees_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/{sha}","languages_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/languages","stargazers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/stargazers","contributors_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contributors","subscribers_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscribers","subscription_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/subscription","commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/commits{/sha}","git_commits_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/git/commits{/sha}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/comments{/number}","issue_comment_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments{/number}","contents_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/contents/{+path}","compare_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/merges","archive_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/downloads","issues_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues{/number}","pulls_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls{/number}","milestones_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/milestones{/number}","notifications_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/labels{/name}","releases_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/releases{/id}","created_at":"2012-09-26T22:57:43Z","updated_at":"2015-12-09T07:13:09Z","pushed_at":"2015-12-09T16:35:20Z","git_url":"git://github.com/CleverRaven/Cataclysm-DDA.git","ssh_url":"git@github.com:CleverRaven/Cataclysm-DDA.git","clone_url":"https://github.com/CleverRaven/Cataclysm-DDA.git","svn_url":"https://github.com/CleverRaven/Cataclysm-DDA","homepage":"http://en.cataclysmdda.com/","size":837928,"stargazers_count":810,"watchers_count":810,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":811,"mirror_url":null,"open_issues_count":1172,"forks":811,"open_issues":1172,"watchers":810,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362"},"html":{"href":"https://github.com/CleverRaven/Cataclysm-DDA/pull/14362"},"issue":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/14362"},"comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/14362/comments"},"review_comments":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362/comments"},"review_comment":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/pulls/14362/commits"},"statuses":{"href":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/statuses/13a39421ea614167b7a11b84354dfda8b25219b0"}}}}