gather some initial statistics

This commit is contained in:
Josh Holtrop 2016-04-14 21:30:14 -04:00
parent 4af4ea43fe
commit 4ca623e0ec

View File

@ -3,10 +3,37 @@
import random
import bingo
TRIALS = 10000
def make_call_list():
call_list = list(range(75))
random.shuffle(call_list)
return call_list
if __name__ == "__main__":
b = bingo.Board()
b.call(1)
b.call(2)
b.call(40)
b.call(50)
b.print()
n_until_bingo = []
n_until_block_of_9 = []
n_until_coverall = []
for trial in range(TRIALS):
board = bingo.Board()
counted_bingo = False
counted_block_of_9 = False
counted_coverall = False
for i, n in enumerate(make_call_list()):
board.call(n)
if not counted_bingo and board.has_bingo():
n_until_bingo.append(i + 1)
counted_bingo = True
if not counted_block_of_9 and board.has_block_of_9():
n_until_block_of_9.append(i + 1)
counted_block_of_9 = True
if not counted_coverall and board.has_coverall():
n_until_coverall.append(i + 1)
counted_coverall = True
break
average_n_until_bingo = sum(n_until_bingo) / len(n_until_bingo)
print("Average number of calls until bingo: %f" % average_n_until_bingo)
average_n_until_block_of_9 = sum(n_until_block_of_9) / len(n_until_block_of_9)
print("Average number of calls until block of 9: %f" % average_n_until_block_of_9)
average_n_until_coverall = sum(n_until_coverall) / len(n_until_coverall)
print("Average number of calls until coverall: %f" % average_n_until_coverall)