-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexplode_test.py
More file actions
32 lines (23 loc) · 839 Bytes
/
explode_test.py
File metadata and controls
32 lines (23 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import icepool
import pytest
abs_tol = 1e-9
def bf_explode_basic(die, depth):
def function(*outcomes):
result = 0
for outcome in outcomes:
result += outcome
if outcome < die.max_outcome():
break
return result
return icepool.map(function, *([die] * (depth + 1)), star=False)
@pytest.mark.parametrize('depth', range(6))
def test_explode_d6(depth):
result = icepool.d6.explode(depth=depth)
result_int = icepool.d6.explode([6], depth=depth)
expected = bf_explode_basic(icepool.d6, depth)
assert result.equals(expected)
assert result_int.equals(expected)
@pytest.mark.parametrize('depth', range(6))
def test_explode_multiple_weight(depth):
result = icepool.d6.explode([5, 6], depth=depth)
assert result.denominator() == 6**(depth + 1)