-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprob.py
142 lines (117 loc) · 5.24 KB
/
prob.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import os,sys
sys.path.insert(1, './lib')
from time import time
from deck import Deck
from card import Card
from hand import Hand
from re import split
my_cards1 = None
my_cards2 = None
community_cards1 = None
community_cards2 = None
community_cards3 = None
community_cards4 = None
community_cards5 = None
for stage in range(1, 5):
if stage == 1:
cards = raw_input("Enter your cards (7c As): ").upper()
cards_split = split(' ', cards)
my_cards1 = Card(cards_split[0][0], cards_split[0][1])
my_cards2 = Card(cards_split[1][0], cards_split[1][1])
if stage == 2:
community = raw_input("Enter first 3 community cards (3s As Ts): ").upper()
community_split = split(' ', community)
community_cards1 = Card(community_split[0][0], community_split[0][1])
community_cards2 = Card(community_split[1][0], community_split[1][1])
community_cards3 = Card(community_split[2][0], community_split[2][1])
if stage == 3:
community = raw_input("Enter next community card (As): ").upper()
community_split = split(' ', community)
community_cards4 = Card(community_split[0][0], community_split[0][1])
if stage == 4:
community = raw_input("Enter next community card (As): ").upper()
community_split = split(' ', community)
community_cards5 = Card(community_split[0][0], community_split[0][1])
start = time()
total = 10000.0
count_my_straights = 0
count_my_flushes = 0
count_my_four_of_a_kind = 0
count_my_three_of_a_kind = 0
count_my_one_pair = 0
count_my_hand_strength = 0
deck = Deck()
for i in xrange(int(total)):
deck.get_new_deck()
community_cards = []
community_cards.append (community_cards1 or deck.deal())
community_cards.append (community_cards2 or deck.deal())
community_cards.append (community_cards3 or deck.deal())
community_cards.append (community_cards4 or deck.deal())
community_cards.append (community_cards5 or deck.deal())
my_hand = Hand(community_cards)
my_hand.add (my_cards1)
my_hand.add (my_cards2)
if my_hand.is_flush(): count_my_flushes += 1.0
if my_hand.is_straight(): count_my_straights += 1.0
if my_hand.four_of_a_kind(): count_my_four_of_a_kind += 1.0
if my_hand.three_of_a_kind(): count_my_three_of_a_kind += 1.0
if my_hand.one_pair(): count_my_one_pair += 1.0
count_my_hand_strength += my_hand.get_strength()
count_their_straights = 0
count_their_flushes = 0
count_their_four_of_a_kind = 0
count_their_three_of_a_kind = 0
count_their_one_pair = 0
count_their_hand_strength = 0
deck = Deck()
for i in xrange(int(total)):
deck.get_new_deck()
community_cards = []
community_cards.append (community_cards1 or deck.deal())
community_cards.append (community_cards2 or deck.deal())
community_cards.append (community_cards3 or deck.deal())
community_cards.append (community_cards4 or deck.deal())
community_cards.append (community_cards5 or deck.deal())
my_hand = Hand(community_cards)
my_hand.add (deck.deal())
my_hand.add (deck.deal())
if my_hand.is_flush(): count_their_flushes += 1.0
if my_hand.is_straight(): count_their_straights += 1.0
if my_hand.four_of_a_kind(): count_their_four_of_a_kind += 1.0
if my_hand.three_of_a_kind(): count_their_three_of_a_kind += 1.0
if my_hand.one_pair(): count_their_one_pair += 1.0
count_their_hand_strength += my_hand.get_strength()
print "---------------------------------------------"
print "took", time() - start
print "PROBABILITY YOU ", "THEM", "RATIO"
ratio_flush, ratio_straight, ratio_four_of_a_kind, ratio_three_of_a_kind = 1,1,1,1
try:
my_flush = round(count_my_flushes / total, 4)
their_flush = round(count_their_flushes / total, 4)
ratio_flush = my_flush / their_flush
print "count flush ", my_flush, their_flush, ratio_flush
except:
raise
try:
my_straight = round(count_my_straights / total, 4)
their_straight = round(count_their_straights / total, 4)
ratio_straight = my_straight / their_straight
print "count straight ", my_straight, their_straight, ratio_straight
except:
raise
try:
my_four_of_a_kind = round(count_my_four_of_a_kind / total, 4)
their_four_of_a_kind = round(count_their_four_of_a_kind / total, 4)
ratio_four_of_a_kind = my_four_of_a_kind / their_four_of_a_kind
print "count four_of_a_kind ", my_four_of_a_kind, their_four_of_a_kind, ratio_four_of_a_kind
except:
raise
try:
my_three_of_a_kind = round(count_my_three_of_a_kind / total, 4)
their_three_of_a_kind = round(count_their_three_of_a_kind / total, 4)
ratio_three_of_a_kind = my_three_of_a_kind / their_three_of_a_kind
print "count three_of_a_kind ", my_three_of_a_kind, their_three_of_a_kind, ratio_three_of_a_kind
except:
raise
print "TOTAL HAND STRENGTH", count_my_hand_strength, count_their_hand_strength, round(float(count_my_hand_strength) / float(count_their_hand_strength), 4)