digitalmars.D - Faster weighted choice range
- bearophile (10/10) Dec 28 2011 Along the time time I have put in Bugzilla a good amount of code for Pho...
- bearophile (4/7) Dec 29 2011 Now it's a more correct Range:
Along the time time I have put in Bugzilla a good amount of code for Phobos. In Bugzilla I have an enhancement request that asks to turn std.random.dice into a range: http://d.puremagic.com/issues/show_bug.cgi?id=5849 Through Reddit I have found an efficient O(1) weighted choice: http://www.keithschwarz.com/darts-dice-coins/ So I have translated the Java code, with small changes, into a D almost-range: http://codepad.org/Ipp6R3DR The code contains some questions, some TODOs, and probably a Range mistake too. Bye, bearophile
Dec 28 2011
So I have translated the Java code, with small changes, into a D almost-range: http://codepad.org/... The code contains some questions, some TODOs, and probably a Range mistake too.Now it's a more correct Range: http://codepad.org/1TW3zp30 Bye, bearophile
Dec 29 2011