Created
May 21, 2015 16:49
-
-
Save omegahm/709e9e187c1e38048f51 to your computer and use it in GitHub Desktop.
4d9 > 6d6
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
sums_4d9 = [1, 2, 3, 4].repeated_combination(9).map { |roll| roll.inject(:+) } | |
sums_6d6 = [1, 2, 3, 4, 5, 6].repeated_combination(6).map { |roll| roll.inject(:+) } | |
wins_4d9, wins_6d6, draws = 0, 0, 0 | |
sums_4d9.each do |four| | |
sums_6d6.each do |six| | |
if four > six | |
wins_4d9 += 1 | |
elsif four < six | |
wins_6d6 += 1 | |
else | |
draws += 1 | |
end | |
end | |
end | |
total = wins_4d9 + wins_6d6 + draws | |
puts "Matches: #{total}" | |
puts "4d9 wins: #{wins_4d9}" | |
puts "4d9 wins %: #{wins_4d9 / total.to_f}" | |
puts "6d6 wins: #{wins_6d6}" | |
puts "6d6 wins %: #{wins_6d6 / total.to_f}" | |
puts "Draws: #{draws}" |
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
Matches: 101640 | |
4d9 wins: 55948 | |
4d9 wins %: 0.550452577725305 | |
6d6 wins: 40641 | |
6d6 wins %: 0.3998524203069658 | |
Draws: 5051 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment