Last active
December 26, 2015 05:29
-
-
Save steveshogren/7100597 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn roll-fate-die [] | |
(- (rand-int 3) 1)) | |
(defn test-fate-percentages [rolls-count] | |
(let [rolls (map (fn [x] | |
(reduce + (map (fn [x] (roll-fate-die)) | |
(range 4)))) | |
(range rolls-count))] | |
(map (fn [x] [(first x) | |
(int (* 100 (/ (count (second x)) rolls-count)))]) | |
(group-by (fn [x] x) rolls)))) | |
(test-fate-percentages 100000) | |
;; => ([-1 19] [0 23] [1 19] [-2 12] [2 12] [-3 4] [3 4] [-4 1] [4 1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment