{"action":"created","issue":{"url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist/issues/55","repository_url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist","labels_url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist/issues/55/comments","events_url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist/issues/55/events","html_url":"https://github.com/Dwarf-Therapist/Dwarf-Therapist/issues/55","id":288759226,"node_id":"MDU6SXNzdWUyODg3NTkyMjY=","number":55,"title":"Role Calculation error when '100' cell changes","user":{"login":"feelotraveller","id":33111504,"node_id":"MDQ6VXNlcjMzMTExNTA0","avatar_url":"https://avatars1.githubusercontent.com/u/33111504?v=4","gravatar_id":"","url":"https://api.github.com/users/feelotraveller","html_url":"https://github.com/feelotraveller","followers_url":"https://api.github.com/users/feelotraveller/followers","following_url":"https://api.github.com/users/feelotraveller/following{/other_user}","gists_url":"https://api.github.com/users/feelotraveller/gists{/gist_id}","starred_url":"https://api.github.com/users/feelotraveller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feelotraveller/subscriptions","organizations_url":"https://api.github.com/users/feelotraveller/orgs","repos_url":"https://api.github.com/users/feelotraveller/repos","events_url":"https://api.github.com/users/feelotraveller/events{/privacy}","received_events_url":"https://api.github.com/users/feelotraveller/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-01-16T01:34:37Z","updated_at":"2018-10-04T09:47:21Z","closed_at":null,"author_association":"NONE","body":"This bug has existed since the Splinterz versions.  When the cell that DT assigns the normalised value of 100 to changes it sometimes happens that normalised distribution becomes errant.  **The workaround is to create a new custom role, or to delete one.**\r\n\r\nThis save should demonstrate the problem: [http://dffd.bay12games.com/file.php?id=13422](http://dffd.bay12games.com/file.php?id=13422)\r\n\r\nWorld was generated in DF44.02, embarked 44.03, unpaused, bug seen and saved in 44.05.  Download also includes custom roles and gridviews that will be useful (needed?) to see the problem.  Images that graphically display the problem - from DT39.1.2 (sex-icon experimental) but checked also with DT39.1.2.  Top is (what I take to be) the correct distribution, the bottom is an example of the error that arises.\r\n\r\n<a href=\"https://postimg.org/image/95x5r93x7/\" target=\"_blank\"><img src=\"https://s17.postimg.org/9iojxfm73/nobug1.png\" alt=\"nobug1\"/></a><br/><br/>\r\n\r\n<a href=\"https://postimg.org/image/wk5536e4r/\" target=\"_blank\"><img src=\"https://s17.postimg.org/q6g1zx98v/bug1.png\" alt=\"bug1\"/></a><br/><br/>\r\n\r\nTo get the bug with the savegame, custom roles + gridviews delete the Tanner++ custom role and then read.  (I added the Tanner++ role as a workaround to the bug.)  Adding it back and reading restores the correct distribution.  Zuglar Mistemthimshur (Carpenter+) was the intial 100 cell that subsequently changed to Urdim Adilkakdal (Herbalist).\r\n\r\nI have heard reports of at least two other users encountering this bug.  For what it's worth they were both also using custom roles and gridviews.  I don't know if it might occur without them.  Also note that it does not always occur when the 100 cell changes but neither is it rare for it to happen.\r\n\r\nHappy to provide further information, or the initial savegame (after embark) if these might be helpful\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist/issues/comments/426955077","html_url":"https://github.com/Dwarf-Therapist/Dwarf-Therapist/issues/55#issuecomment-426955077","issue_url":"https://api.github.com/repos/Dwarf-Therapist/Dwarf-Therapist/issues/55","id":426955077,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjk1NTA3Nw==","user":{"login":"cvuchener","id":3874173,"node_id":"MDQ6VXNlcjM4NzQxNzM=","avatar_url":"https://avatars1.githubusercontent.com/u/3874173?v=4","gravatar_id":"","url":"https://api.github.com/users/cvuchener","html_url":"https://github.com/cvuchener","followers_url":"https://api.github.com/users/cvuchener/followers","following_url":"https://api.github.com/users/cvuchener/following{/other_user}","gists_url":"https://api.github.com/users/cvuchener/gists{/gist_id}","starred_url":"https://api.github.com/users/cvuchener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvuchener/subscriptions","organizations_url":"https://api.github.com/users/cvuchener/orgs","repos_url":"https://api.github.com/users/cvuchener/repos","events_url":"https://api.github.com/users/cvuchener/events{/privacy}","received_events_url":"https://api.github.com/users/cvuchener/received_events","type":"User","site_admin":false},"created_at":"2018-10-04T09:47:21Z","updated_at":"2018-10-04T09:47:21Z","author_association":"CONTRIBUTOR","body":"There is a bug in how the median is computed and this could be the cause of this bug. I'm rewriting the rating normalization anyway in #126.\r\n\r\nIf you want to try with a fixed median, it is only a couple of line to delete:\r\n```diff\r\ndiff --git a/src/rolecalcbase.cpp b/src/rolecalcbase.cpp\r\nindex a3c08fe..a6dc6d2 100644\r\n--- a/src/rolecalcbase.cpp\r\n+++ b/src/rolecalcbase.cpp\r\n@@ -50,10 +50,8 @@ double RoleCalcBase::find_median(QVector<double> v){\r\n     int idx_mid = (double)v.count() / 2.0f;\r\n     double m = 0.0;\r\n     if(v.count() % 2 == 0){\r\n-        std::nth_element(v.begin(),v.begin()+idx_mid,v.end());\r\n         m = 0.5 * (v.at(idx_mid)+v.at(idx_mid-1));\r\n     }else{\r\n-        std::nth_element(v.begin(),v.begin()+idx_mid,v.end());\r\n         m =  v.at(idx_mid);\r\n     }\r\n     return m;\r\n```"}}
{"actor":{"display_login":"cvuchener"}}