Exemplo n.º 1
0
def test_update_priors():
    bd = BayesDice()
    bd.die = 8
    bd.update_priors(4)
    assert bd.data[4] == approx(0.37, abs=1e-1)
    assert bd.data[8] == approx(0.18, abs=1e-1)
    assert bd.data[20] == approx(0.07, abs=1e-1)
    bd.update_priors(7)
    assert bd.data[4] == approx(0.00, abs=1e-1)
    assert bd.data[8] == approx(0.62, abs=1e-1)
    assert bd.data[20] == approx(0.10, abs=1e-1)
Exemplo n.º 2
0
def test_class_works():
    bd = BayesDice()
    assert isinstance(bd, BayesDice)
    assert sum(bd.data.values()) == 1
Exemplo n.º 3
0
def test_choose_die():
    bd = BayesDice()
    bd.choose_die()
    assert bd.die in [4, 6, 8, 12, 20]
Exemplo n.º 4
0
def test_roll_die():
    bd = BayesDice()
    bd.choose_die()
    roll = bd.roll_die()
    assert roll in range(1, bd.die + 1)
Exemplo n.º 5
0
from src.bayesdice import BayesDice

bd = BayesDice()
bd.choose_die()

for i in range(3):
    roll = bd.roll_die()
    bd.update_priors(roll)