-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRiddler_Feb1_ThreeDeckMonte.py
67 lines (59 loc) · 1.86 KB
/
Riddler_Feb1_ThreeDeckMonte.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 1 09:26:54 2019
@author: firman.taylor
"""
import numpy as np
numSims = 100000
red = np.array(4*[14] + 4*[9] + 4*[7])
blue = np.array(4*[13] + 4*[11] + 4*[6])
black = np.array(4*[12] + 4*[10] + 4*[8])
redWins = 0
blueWins = 0
for numSim in range(numSims):
np.random.shuffle(red)
np.random.shuffle(blue)
ind = 1
while np.sum(red[:ind] > blue[:ind]) < 5 and np.sum(blue[:ind] > red[:ind]) < 5:
ind += 1
if np.sum(red[:ind] > blue[:ind]) == 5:
redWins += 1
else:
blueWins += 1
if redWins > blueWins:
print('Red wins against Blue ' + str(round(100*redWins/numSims,1)) + '% of the time')
else:
print('Blue wins against Red ' + str(round(100*blueWins/numSims,1)) + '% of the time')
blueWins = 0
blackWins = 0
for numSim in range(numSims):
np.random.shuffle(blue)
np.random.shuffle(black)
ind = 1
while np.sum(blue[:ind] > black[:ind]) < 5 and np.sum(black[:ind] > blue[:ind]) < 5:
ind += 1
if np.sum(blue[:ind] > black[:ind]) == 5:
blueWins += 1
else:
blackWins += 1
if blueWins > blackWins:
print('Blue wins against Black ' + str(round(100*blueWins/numSims,1)) + '% of the time')
else:
print('Black wins against Blue ' + str(round(100*blackWins/numSims,1)) + '% of the time')
blackWins = 0
redWins = 0
for numSim in range(numSims):
np.random.shuffle(black)
np.random.shuffle(red)
ind = 1
while np.sum(black[:ind] > red[:ind]) < 5 and np.sum(red[:ind] > black[:ind]) < 5:
ind += 1
if np.sum(black[:ind] > red[:ind]) == 5:
blackWins += 1
else:
redWins += 1
if blackWins > redWins:
print('Black wins against Red ' + str(round(100*blackWins/numSims,1)) + '% of the time')
else:
print('Red wins against Black ' + str(round(100*redWins/numSims,1)) + '% of the time')