gather some initial statistics
This commit is contained in:
parent
4af4ea43fe
commit
4ca623e0ec
39
analysis.py
39
analysis.py
@ -3,10 +3,37 @@
|
|||||||
import random
|
import random
|
||||||
import bingo
|
import bingo
|
||||||
|
|
||||||
|
TRIALS = 10000
|
||||||
|
|
||||||
|
def make_call_list():
|
||||||
|
call_list = list(range(75))
|
||||||
|
random.shuffle(call_list)
|
||||||
|
return call_list
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
b = bingo.Board()
|
n_until_bingo = []
|
||||||
b.call(1)
|
n_until_block_of_9 = []
|
||||||
b.call(2)
|
n_until_coverall = []
|
||||||
b.call(40)
|
for trial in range(TRIALS):
|
||||||
b.call(50)
|
board = bingo.Board()
|
||||||
b.print()
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user