29 lines
616 B
Python
29 lines
616 B
Python
|
from random import random
|
||
|
|
||
|
def piece_builder(p):
|
||
|
def piece():
|
||
|
r = random()
|
||
|
if r < p:
|
||
|
return "pile"
|
||
|
return "face"
|
||
|
|
||
|
return piece
|
||
|
|
||
|
piece1 = piece_builder(0.5)
|
||
|
piece2 = piece_builder(0.4)
|
||
|
piece3 = piece_builder(0.2)
|
||
|
|
||
|
def de_builder(steps):
|
||
|
assert sorted(steps) == steps
|
||
|
assert steps[-1] == 1
|
||
|
def de():
|
||
|
r = random()
|
||
|
for i in range(6):
|
||
|
if r < steps[i]:
|
||
|
return i+1
|
||
|
return de
|
||
|
|
||
|
de1 = de_builder([(i+1)*1/6 for i in range(6)])
|
||
|
de2 = de_builder([0.1, 0.2, 0.3, 0.4, 0.5, 1])
|
||
|
de3 = de_builder([0.01, 0.3, 0.4, 0.6, 0.8, 1])
|