-
Notifications
You must be signed in to change notification settings - Fork 1
/
oddsCalculator.py
127 lines (90 loc) · 2.88 KB
/
oddsCalculator.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
CARDS_LEFT_PRE_FLOP = 5
CARDS_LEFT_POST_FLOP = 2
CARDS_LEFT_POST_TURN = 1
PERCENT = 100
numbers = ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"]
suits = {
"C": "♣️",
"D": "♦️",
"H": "♥️",
"S": "♠️",
}
def findPairOdds(knownCards, stage):
cardValues = [card[0] for card in knownCards]
result = {}
for value in cardValues:
if value in result:
result[value] += 1
else:
result[value] = 1
for key in result:
if result[key] > 2:
return 0
elif result[key] == 2:
return 100
if (stage == "preflop"):
return round(PERCENT * CARDS_LEFT_PRE_FLOP * (6 * 44 * 43 * 42 * 41) / (50 * 49 * 48 * 47 * 46), 2)
elif (stage == "postflop"):
return round(PERCENT * CARDS_LEFT_POST_FLOP * (15 * 32) / (47 * 46), 2)
else:
return round(PERCENT * CARDS_LEFT_POST_TURN * 18 / 46, 2)
def findTripsOdds(knownCards, stage):
cardValues = [card[0] for card in knownCards]
result = {}
for value in cardValues:
if value in result:
result[value] += 1
else:
result[value] = 1
for key in result:
if result[key] > 3:
return 0
elif result[key] == 3:
return 100
if (findPairOdds(knownCards, stage) != 100):
return 0
if (stage == "preflop"):
return 18.37
elif (stage == "postflop"):
return round(PERCENT * CARDS_LEFT_POST_FLOP * (2 * 45 ) / (47 * 46), 2)
else:
return round(PERCENT * CARDS_LEFT_POST_TURN * 2 / 46, 2)
def findQuadsOdds(knownCards, stage):
cardValues = [card[0] for card in knownCards]
result = {}
for value in cardValues:
if value in result:
result[value] += 1
else:
result[value] = 1
for key in result:
if result[key] > 4:
return 0
elif result[key] == 4:
return 100
if (findTripsOdds(knownCards, stage) != 100):
return 0
if (stage == "preflop"):
return 0
elif (stage == "postflop"):
return round((PERCENT * CARDS_LEFT_POST_FLOP * 1) / 47, 2)
else:
return round((PERCENT * CARDS_LEFT_POST_TURN * 1) / 46, 2)
def findFlushOdds(knownCards, stage):
cardSuits = [card[1] for card in knownCards]
result = {}
for suit in cardSuits:
if suit in result:
result[suit] += 1
else:
result[suit] = 1
largestNumberOfSuitedCards = max(list(result.values()))
if (largestNumberOfSuitedCards == 5):
return 100
if (stage == "preflop" and largestNumberOfSuitedCards == 2):
return 6.4
if (stage == "postflop" and largestNumberOfSuitedCards == 4):
return 34.97
if (stage == "turn" and largestNumberOfSuitedCards == 4):
return 19.5
return 0