games_dice 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +38 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +41 -3
- data/.yardopts +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +10 -0
- data/README.md +11 -33
- data/Rakefile +2 -18
- data/ext/games_dice/games_dice.c +1 -1
- data/ext/games_dice/probabilities.c +127 -8
- data/ext/games_dice/probabilities.h +1 -1
- data/games_dice.gemspec +11 -19
- data/lib/games_dice/bunch.rb +27 -65
- data/lib/games_dice/bunch_helpers.rb +68 -0
- data/lib/games_dice/complex_die.rb +10 -146
- data/lib/games_dice/complex_die_helpers.rb +238 -46
- data/lib/games_dice/dice.rb +17 -10
- data/lib/games_dice/die.rb +2 -2
- data/lib/games_dice/die_result.rb +84 -71
- data/lib/games_dice/marshal.rb +26 -3
- data/lib/games_dice/parser.rb +128 -102
- data/lib/games_dice/version.rb +2 -1
- data/lib/games_dice.rb +7 -9
- data/spec/bunch_spec.rb +72 -72
- data/spec/complex_die_spec.rb +158 -158
- data/spec/dice_spec.rb +5 -5
- data/spec/die_result_spec.rb +98 -98
- data/spec/die_spec.rb +19 -19
- data/spec/helpers.rb +2 -4
- data/spec/map_rule_spec.rb +17 -17
- data/spec/parser_spec.rb +7 -7
- data/spec/probability_spec.rb +188 -196
- data/spec/readme_spec.rb +28 -22
- data/spec/reroll_rule_spec.rb +15 -15
- metadata +16 -139
- data/.travis.yml +0 -11
data/spec/bunch_spec.rb
CHANGED
|
@@ -4,37 +4,37 @@ require 'helpers'
|
|
|
4
4
|
|
|
5
5
|
describe GamesDice::Bunch do
|
|
6
6
|
describe 'dice scheme' do
|
|
7
|
-
before
|
|
7
|
+
before do
|
|
8
8
|
srand(67_809)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
describe '1d10' do
|
|
12
|
-
let(:bunch) {
|
|
12
|
+
let(:bunch) { described_class.new(sides: 10, ndice: 1) }
|
|
13
13
|
|
|
14
|
-
it '
|
|
14
|
+
it 'simulate rolling a ten-sided die' do
|
|
15
15
|
[3, 2, 8, 8, 5, 3, 7].each do |expected_total|
|
|
16
16
|
expect(bunch.roll).to eql expected_total
|
|
17
17
|
expect(bunch.result).to eql expected_total
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
it '
|
|
21
|
+
it 'concisely explain each result' do
|
|
22
22
|
%w[3 2 8 8].each do |expected_explain|
|
|
23
23
|
bunch.roll
|
|
24
24
|
expect(bunch.explain_result).to eql expected_explain
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
it '
|
|
29
|
-
expect(bunch.min).to
|
|
30
|
-
expect(bunch.max).to
|
|
28
|
+
it 'calculate correct min, max = 1,10' do
|
|
29
|
+
expect(bunch.min).to be 1
|
|
30
|
+
expect(bunch.max).to be 10
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it '
|
|
33
|
+
it 'have a mean value of 5.5' do
|
|
34
34
|
expect(bunch.probabilities.expected).to be_within(1e-10).of 5.5
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
it '
|
|
37
|
+
it 'calculate probabilities correctly' do
|
|
38
38
|
prob_hash = bunch.probabilities.to_h
|
|
39
39
|
expect(prob_hash[1]).to be_within(1e-10).of 0.1
|
|
40
40
|
expect(prob_hash[2]).to be_within(1e-10).of 0.1
|
|
@@ -46,21 +46,21 @@ describe GamesDice::Bunch do
|
|
|
46
46
|
expect(prob_hash[8]).to be_within(1e-10).of 0.1
|
|
47
47
|
expect(prob_hash[9]).to be_within(1e-10).of 0.1
|
|
48
48
|
expect(prob_hash[10]).to be_within(1e-10).of 0.1
|
|
49
|
-
expect(prob_hash.values.
|
|
49
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
describe '2d6' do
|
|
54
|
-
let(:bunch) {
|
|
54
|
+
let(:bunch) { described_class.new(sides: 6, ndice: 2) }
|
|
55
55
|
|
|
56
|
-
it '
|
|
56
|
+
it 'simulate rolling two six-sided dice and adding them' do
|
|
57
57
|
[9, 6, 11, 9, 7, 7, 10].each do |expected_total|
|
|
58
58
|
expect(bunch.roll).to eql expected_total
|
|
59
59
|
expect(bunch.result).to eql expected_total
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
it '
|
|
63
|
+
it 'concisely explain each result' do
|
|
64
64
|
['3 + 6 = 9', '2 + 4 = 6', '5 + 6 = 11', '3 + 6 = 9', '2 + 5 = 7', '6 + 1 = 7',
|
|
65
65
|
'5 + 5 = 10'].each do |expected_explain|
|
|
66
66
|
bunch.roll
|
|
@@ -68,16 +68,16 @@ describe GamesDice::Bunch do
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
it '
|
|
72
|
-
expect(bunch.min).to
|
|
73
|
-
expect(bunch.max).to
|
|
71
|
+
it 'calculate correct min, max = 2,12' do
|
|
72
|
+
expect(bunch.min).to be 2
|
|
73
|
+
expect(bunch.max).to be 12
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
it '
|
|
76
|
+
it 'have a mean value of 7.0' do
|
|
77
77
|
expect(bunch.probabilities.expected).to be_within(1e-10).of 7.0
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
it '
|
|
80
|
+
it 'calculate probabilities correctly' do
|
|
81
81
|
prob_hash = bunch.probabilities.to_h
|
|
82
82
|
expect(prob_hash[2]).to be_within(1e-10).of 1 / 36.0
|
|
83
83
|
expect(prob_hash[3]).to be_within(1e-10).of 2 / 36.0
|
|
@@ -90,21 +90,21 @@ describe GamesDice::Bunch do
|
|
|
90
90
|
expect(prob_hash[10]).to be_within(1e-10).of 3 / 36.0
|
|
91
91
|
expect(prob_hash[11]).to be_within(1e-10).of 2 / 36.0
|
|
92
92
|
expect(prob_hash[12]).to be_within(1e-10).of 1 / 36.0
|
|
93
|
-
expect(prob_hash.values.
|
|
93
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
describe '20d10' do
|
|
98
|
-
let(:bunch) {
|
|
98
|
+
let(:bunch) { described_class.new(sides: 10, ndice: 20) }
|
|
99
99
|
|
|
100
|
-
it '
|
|
100
|
+
it 'simulate rolling twenty ten-sided dice and adding them' do
|
|
101
101
|
[132, 103, 102, 124, 132, 96, 111].each do |expected_total|
|
|
102
102
|
expect(bunch.roll).to eql expected_total
|
|
103
103
|
expect(bunch.result).to eql expected_total
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
-
it '
|
|
107
|
+
it 'concisely explain each result' do
|
|
108
108
|
explains = ['3 + 2 + 8 + 8 + 5 + 3 + 7 + 7 + 6 + 10 + 7 + 6 + 9 + 5 + 5 + 8 + 10 + 9 + 5 + 9 = 132',
|
|
109
109
|
'3 + 9 + 1 + 4 + 3 + 5 + 7 + 1 + 10 + 4 + 7 + 7 + 6 + 5 + 2 + 7 + 4 + 9 + 7 + 2 = 103',
|
|
110
110
|
'6 + 1 + 1 + 3 + 1 + 4 + 9 + 6 + 3 + 10 + 9 + 10 + 8 + 4 + 1 + 4 + 2 + 1 + 10 + 9 = 102']
|
|
@@ -115,34 +115,34 @@ describe GamesDice::Bunch do
|
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
it '
|
|
119
|
-
expect(bunch.min).to
|
|
120
|
-
expect(bunch.max).to
|
|
118
|
+
it 'calculate correct min, max = 20,200' do
|
|
119
|
+
expect(bunch.min).to be 20
|
|
120
|
+
expect(bunch.max).to be 200
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
it '
|
|
123
|
+
it 'have a mean value of 110.0' do
|
|
124
124
|
expect(bunch.probabilities.expected).to be_within(1e-8).of 110.0
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
-
it '
|
|
127
|
+
it 'calculate probabilities correctly' do
|
|
128
128
|
prob_hash = bunch.probabilities.to_h
|
|
129
129
|
expect(prob_hash[20]).to be_within(1e-26).of 1e-20
|
|
130
130
|
expect(prob_hash[110]).to be_within(1e-10).of 0.0308191892
|
|
131
|
-
expect(prob_hash.values.
|
|
131
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
describe '4d6 keep best 3' do
|
|
136
|
-
let(:bunch) {
|
|
136
|
+
let(:bunch) { described_class.new(sides: 6, ndice: 4, keep_mode: :keep_best, keep_number: 3) }
|
|
137
137
|
|
|
138
|
-
it '
|
|
138
|
+
it 'simulate rolling four six-sided dice and adding the best three values' do
|
|
139
139
|
[13, 17, 13, 12, 13, 10, 14].each do |expected_total|
|
|
140
140
|
expect(bunch.roll).to eql expected_total
|
|
141
141
|
expect(bunch.result).to eql expected_total
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
it '
|
|
145
|
+
it 'concisely explain each result' do
|
|
146
146
|
['3, 6, 2, 4. Keep: 3 + 4 + 6 = 13',
|
|
147
147
|
'5, 6, 3, 6. Keep: 5 + 6 + 6 = 17',
|
|
148
148
|
'2, 5, 6, 1. Keep: 2 + 5 + 6 = 13',
|
|
@@ -152,16 +152,16 @@ describe GamesDice::Bunch do
|
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
154
|
|
|
155
|
-
it '
|
|
156
|
-
expect(bunch.min).to
|
|
157
|
-
expect(bunch.max).to
|
|
155
|
+
it 'calculate correct min, max = 3,18' do
|
|
156
|
+
expect(bunch.min).to be 3
|
|
157
|
+
expect(bunch.max).to be 18
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
-
it '
|
|
160
|
+
it 'have a mean value of roughly 12.2446' do
|
|
161
161
|
expect(bunch.probabilities.expected).to be_within(1e-9).of 12.244598765
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
it '
|
|
164
|
+
it 'calculate probabilities correctly' do
|
|
165
165
|
prob_hash = bunch.probabilities.to_h
|
|
166
166
|
expect(prob_hash[3]).to be_within(1e-10).of 1 / 1296.0
|
|
167
167
|
expect(prob_hash[4]).to be_within(1e-10).of 4 / 1296.0
|
|
@@ -179,21 +179,21 @@ describe GamesDice::Bunch do
|
|
|
179
179
|
expect(prob_hash[16]).to be_within(1e-10).of 94 / 1296.0
|
|
180
180
|
expect(prob_hash[17]).to be_within(1e-10).of 54 / 1296.0
|
|
181
181
|
expect(prob_hash[18]).to be_within(1e-10).of 21 / 1296.0
|
|
182
|
-
expect(prob_hash.values.
|
|
182
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
describe '10d10 keep worst one' do
|
|
187
|
-
let(:bunch) {
|
|
187
|
+
let(:bunch) { described_class.new(sides: 10, ndice: 10, keep_mode: :keep_worst, keep_number: 1) }
|
|
188
188
|
|
|
189
|
-
it '
|
|
189
|
+
it 'simulate rolling ten ten-sided dice and keeping the worst value' do
|
|
190
190
|
[2, 5, 1, 2, 1, 1, 2].each do |expected_total|
|
|
191
191
|
expect(bunch.roll).to eql expected_total
|
|
192
192
|
expect(bunch.result).to eql expected_total
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
195
|
|
|
196
|
-
it '
|
|
196
|
+
it 'concisely explain each result' do
|
|
197
197
|
['3, 2, 8, 8, 5, 3, 7, 7, 6, 10. Keep: 2',
|
|
198
198
|
'7, 6, 9, 5, 5, 8, 10, 9, 5, 9. Keep: 5',
|
|
199
199
|
'3, 9, 1, 4, 3, 5, 7, 1, 10, 4. Keep: 1',
|
|
@@ -203,16 +203,16 @@ describe GamesDice::Bunch do
|
|
|
203
203
|
end
|
|
204
204
|
end
|
|
205
205
|
|
|
206
|
-
it '
|
|
207
|
-
expect(bunch.min).to
|
|
208
|
-
expect(bunch.max).to
|
|
206
|
+
it 'calculate correct min, max = 1,10' do
|
|
207
|
+
expect(bunch.min).to be 1
|
|
208
|
+
expect(bunch.max).to be 10
|
|
209
209
|
end
|
|
210
210
|
|
|
211
|
-
it '
|
|
211
|
+
it 'have a mean value of roughly 1.491' do
|
|
212
212
|
expect(bunch.probabilities.expected).to be_within(1e-9).of 1.4914341925
|
|
213
213
|
end
|
|
214
214
|
|
|
215
|
-
it '
|
|
215
|
+
it 'calculate probabilities correctly' do
|
|
216
216
|
prob_hash = bunch.probabilities.to_h
|
|
217
217
|
expect(prob_hash[1]).to be_within(1e-10).of 0.6513215599
|
|
218
218
|
expect(prob_hash[2]).to be_within(1e-10).of 0.2413042577
|
|
@@ -224,26 +224,26 @@ describe GamesDice::Bunch do
|
|
|
224
224
|
expect(prob_hash[8]).to be_within(1e-10).of 0.0000058025
|
|
225
225
|
expect(prob_hash[9]).to be_within(1e-10).of 0.0000001023
|
|
226
226
|
expect(prob_hash[10]).to be_within(1e-18).of 1e-10
|
|
227
|
-
expect(prob_hash.values.
|
|
227
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
228
228
|
end
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
describe '5d10, re-roll and add on 10s, keep best 2' do
|
|
232
232
|
let(:bunch) do
|
|
233
|
-
|
|
233
|
+
described_class.new(
|
|
234
234
|
sides: 10, ndice: 5, keep_mode: :keep_best, keep_number: 2,
|
|
235
235
|
rerolls: [GamesDice::RerollRule.new(10, :==, :reroll_add)]
|
|
236
236
|
)
|
|
237
237
|
end
|
|
238
238
|
|
|
239
|
-
it "
|
|
239
|
+
it "simulate rolling five ten-sided 'exploding' dice and adding the best two values" do
|
|
240
240
|
[16, 24, 17, 28, 12, 21, 16].each do |expected_total|
|
|
241
241
|
expect(bunch.roll).to eql expected_total
|
|
242
242
|
expect(bunch.result).to eql expected_total
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
-
it '
|
|
246
|
+
it 'concisely explain each result' do
|
|
247
247
|
['3, 2, 8, 8, 5. Keep: 8 + 8 = 16',
|
|
248
248
|
'3, 7, 7, 6, [10+7] 17. Keep: 7 + 17 = 24',
|
|
249
249
|
'6, 9, 5, 5, 8. Keep: 8 + 9 = 17',
|
|
@@ -253,16 +253,16 @@ describe GamesDice::Bunch do
|
|
|
253
253
|
end
|
|
254
254
|
end
|
|
255
255
|
|
|
256
|
-
it '
|
|
257
|
-
expect(bunch.min).to
|
|
256
|
+
it 'calculate correct min, max = 2, > 100' do
|
|
257
|
+
expect(bunch.min).to be 2
|
|
258
258
|
expect(bunch.max).to be > 100
|
|
259
259
|
end
|
|
260
260
|
|
|
261
|
-
it '
|
|
261
|
+
it 'have a mean value of roughly 18.986' do
|
|
262
262
|
expect(bunch.probabilities.expected).to be_within(1e-9).of 18.9859925804
|
|
263
263
|
end
|
|
264
264
|
|
|
265
|
-
it '
|
|
265
|
+
it 'calculate probabilities correctly' do
|
|
266
266
|
prob_hash = bunch.probabilities.to_h
|
|
267
267
|
probs = prob_hash.values_at(*2..30)
|
|
268
268
|
expected_probs = [0.00001, 0.00005, 0.00031, 0.00080, 0.00211, 0.00405, 0.00781, 0.01280, 0.02101, 0.0312,
|
|
@@ -274,25 +274,25 @@ describe GamesDice::Bunch do
|
|
|
274
274
|
expect(got_prob).to be_within(1e-10).of(expected_prob)
|
|
275
275
|
end
|
|
276
276
|
|
|
277
|
-
expect(prob_hash.values.
|
|
277
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
278
278
|
end
|
|
279
279
|
end
|
|
280
280
|
|
|
281
281
|
describe 'roll 2d20, keep best value' do
|
|
282
282
|
let(:bunch) do
|
|
283
|
-
|
|
283
|
+
described_class.new(
|
|
284
284
|
sides: 20, ndice: 2, keep_mode: :keep_best, keep_number: 1
|
|
285
285
|
)
|
|
286
286
|
end
|
|
287
287
|
|
|
288
|
-
it '
|
|
288
|
+
it 'simulate rolling two twenty-sided dice and keeping the best value' do
|
|
289
289
|
[19, 18, 14, 6, 13, 10, 16].each do |expected_total|
|
|
290
290
|
expect(bunch.roll).to eql expected_total
|
|
291
291
|
expect(bunch.result).to eql expected_total
|
|
292
292
|
end
|
|
293
293
|
end
|
|
294
294
|
|
|
295
|
-
it '
|
|
295
|
+
it 'concisely explain each result' do
|
|
296
296
|
['19, 14. Keep: 19',
|
|
297
297
|
'18, 16. Keep: 18',
|
|
298
298
|
'5, 14. Keep: 14',
|
|
@@ -302,16 +302,16 @@ describe GamesDice::Bunch do
|
|
|
302
302
|
end
|
|
303
303
|
end
|
|
304
304
|
|
|
305
|
-
it '
|
|
306
|
-
expect(bunch.min).to
|
|
307
|
-
expect(bunch.max).to
|
|
305
|
+
it 'calculate correct min, max = 1,20' do
|
|
306
|
+
expect(bunch.min).to be 1
|
|
307
|
+
expect(bunch.max).to be 20
|
|
308
308
|
end
|
|
309
309
|
|
|
310
|
-
it '
|
|
310
|
+
it 'have a mean value of 13.825' do
|
|
311
311
|
expect(bunch.probabilities.expected).to be_within(1e-9).of 13.825
|
|
312
312
|
end
|
|
313
313
|
|
|
314
|
-
it '
|
|
314
|
+
it 'calculate probabilities correctly' do
|
|
315
315
|
prob_hash = bunch.probabilities.to_h
|
|
316
316
|
expect(prob_hash[1]).to be_within(1e-10).of 1 / 400.0
|
|
317
317
|
expect(prob_hash[2]).to be_within(1e-10).of 3 / 400.0
|
|
@@ -333,25 +333,25 @@ describe GamesDice::Bunch do
|
|
|
333
333
|
expect(prob_hash[18]).to be_within(1e-10).of 35 / 400.0
|
|
334
334
|
expect(prob_hash[19]).to be_within(1e-10).of 37 / 400.0
|
|
335
335
|
expect(prob_hash[20]).to be_within(1e-10).of 39 / 400.0
|
|
336
|
-
expect(prob_hash.values.
|
|
336
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
337
337
|
end
|
|
338
338
|
end
|
|
339
339
|
|
|
340
340
|
describe 'roll 2d20, keep worst value' do
|
|
341
341
|
let(:bunch) do
|
|
342
|
-
|
|
342
|
+
described_class.new(
|
|
343
343
|
sides: 20, ndice: 2, keep_mode: :keep_worst, keep_number: 1
|
|
344
344
|
)
|
|
345
345
|
end
|
|
346
346
|
|
|
347
|
-
it '
|
|
347
|
+
it 'simulate rolling two twenty-sided dice and keeping the best value' do
|
|
348
348
|
[14, 16, 5, 3, 7, 5, 9].each do |expected_total|
|
|
349
349
|
expect(bunch.roll).to eql expected_total
|
|
350
350
|
expect(bunch.result).to eql expected_total
|
|
351
351
|
end
|
|
352
352
|
end
|
|
353
353
|
|
|
354
|
-
it '
|
|
354
|
+
it 'concisely explain each result' do
|
|
355
355
|
['19, 14. Keep: 14',
|
|
356
356
|
'18, 16. Keep: 16',
|
|
357
357
|
'5, 14. Keep: 5',
|
|
@@ -361,16 +361,16 @@ describe GamesDice::Bunch do
|
|
|
361
361
|
end
|
|
362
362
|
end
|
|
363
363
|
|
|
364
|
-
it '
|
|
365
|
-
expect(bunch.min).to
|
|
366
|
-
expect(bunch.max).to
|
|
364
|
+
it 'calculate correct min, max = 1,20' do
|
|
365
|
+
expect(bunch.min).to be 1
|
|
366
|
+
expect(bunch.max).to be 20
|
|
367
367
|
end
|
|
368
368
|
|
|
369
|
-
it '
|
|
369
|
+
it 'have a mean value of 7.175' do
|
|
370
370
|
expect(bunch.probabilities.expected).to be_within(1e-9).of 7.175
|
|
371
371
|
end
|
|
372
372
|
|
|
373
|
-
it '
|
|
373
|
+
it 'calculate probabilities correctly' do
|
|
374
374
|
prob_hash = bunch.probabilities.to_h
|
|
375
375
|
expect(prob_hash[1]).to be_within(1e-10).of 39 / 400.0
|
|
376
376
|
expect(prob_hash[2]).to be_within(1e-10).of 37 / 400.0
|
|
@@ -392,7 +392,7 @@ describe GamesDice::Bunch do
|
|
|
392
392
|
expect(prob_hash[18]).to be_within(1e-10).of 5 / 400.0
|
|
393
393
|
expect(prob_hash[19]).to be_within(1e-10).of 3 / 400.0
|
|
394
394
|
expect(prob_hash[20]).to be_within(1e-10).of 1 / 400.0
|
|
395
|
-
expect(prob_hash.values.
|
|
395
|
+
expect(prob_hash.values.sum).to be_within(1e-9).of 1.0
|
|
396
396
|
end
|
|
397
397
|
end
|
|
398
398
|
end
|