40 lines
1.4 KiB
Python
Executable File
40 lines
1.4 KiB
Python
Executable File
#!/usr/bin/python3
|
|
|
|
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__":
|
|
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)
|