Thank you for browsing. It is pbird yellow.
Immediately, I'll analyze about a million hands I've played on the famous poker site "PokerStars". This time, we have compiled the starting hands for Texas Hold'em.
A starting hand is a card that is randomly dealt out of 52 cards excluding joker out of all 54 cards of playing cards.
The source code is also included, so please use it as well. I myself am a beginner in programming, so I would be grateful if you could give me some advice. ↓ 1 million hand total result
When the hand logs were aggregated, the appearance rate of each hand seemed to converge. Please see ** here ** for the appearance rate of each hand. * Coming soon.
PokerStars hand logs are stored on your PC. Please see ** here ** for how to extract the hand log. * Coming soon.
This log data is convenient because it is very easy to process the data.
txt:HoldemManager2.2020-07-31-09-22-31.PS.Hand1-1000.txt
PokerStars Zoom Hand #155136535392: Hold'em No Limit ($0.05/$0.10) - 2016/06/24 9:17:52 ET
Table 'Aludra' 6-max Seat #1 is the button
Seat 1: xxx ($8.18 in chips)
Seat 2: xxx ($9.90 in chips)
Seat 3: pbirdyellow ($10 in chips)
Seat 4: xxx ($17.30 in chips)
Seat 5: xxx ($21.93 in chips)
Seat 6: xxx ($10 in chips)
ccc: posts small blind $0.05
pbirdyellow: posts big blind $0.10
*** HOLE CARDS ***
Dealt to pbirdyellow [Qc Ad]
xxx: folds
xxx: folds
xxx: raises $0.15 to $0.25
xxx: folds
xxx: folds
pbirdyellow: raises $0.55 to $0.80
xxx: folds
Uncalled bet ($0.55) returned to pbirdyellow
pbirdyellow collected $0.55 from pot
pbirdyellow: doesn't show hand
*** SUMMARY ***
Total pot $0.55 | Rake $0
Seat 1: xxx (button) folded before Flop
・ ・ ・(Continued below)
The following is the source code. Setting the value of "path" should work. Programming is still at the beginner level, so please point out more and more. If you have any questions about the contents of the code, please contact us by DM etc. from your qiita account or twitter account.
twitter:@pbirdyellow
pokermain.py
from holdcards import Holdcards
from plotgraph import Plotgraph
import os
import glob
path='Write the log path here'
filelist = glob.glob(os.path.join(path,"*.txt"),recursive=True)
totcards = []
graphdata = []
for item in filelist:
with open(item) as f:
data = f.readlines()
card = Holdcards()
h_cards = card.find_holdcards(data)
totcards += h_cards
cardscount = card.count_holdcards(totcards)
graph= Plotgraph()
graph.writegraph(cardscount,card.handlist,card.hands)
Holdcards.py
class Holdcards:
def __init__(self):
self.trump={"A":"14","K":"13","Q":"12","J":"11","T":"10","9":"9","8":"8","7":"7","6":"6","5":"5","4":"4","3":"3","2":"2"}
self.r_trump={"14":"A","13":"K","12":"Q","11":"J","10":"T","9":"9","8":"8","7":"7","6":"6","5":"5","4":"4","3":"3","2":"2"}
self.hands = 0
self.handlist = []
def find_holdcards(self,data):
holdcards = []
for item in data:
if 'Dealt to' in item:
item = item[-7:-2]
if item[1] == item[4]:
if int(self.trump.get(item[0])) > int(self.trump.get(item[3])):
item = item[0] + item[3] + 's'
else:
item = item[3] + item[0] + 's'
else:
if int(self.trump.get(item[0])) > int(self.trump.get(item[3])):
item = item[0] + item[3] + 'o'
elif item[0] == item[3]:
item = item[0] + item[3]
else:
item = item[3] + item[0] + 'o'
holdcards.append(item)
return holdcards
def count_holdcards(self,list):
totlist = []
i = 0
while i < 13:
j=0
rowlist = []
rowhandlist = []
while j < 13:
if i < j:
hand = (self.r_trump.get(str(14-i))+self.r_trump.get(str(14-j))+"s")
count = list.count(hand)
rowlist.append(count)
elif i == j:
hand = (self.r_trump.get(str(14-i))+self.r_trump.get(str(14-j)))
count = list.count(hand)
rowlist.append(count)
else:
hand = (self.r_trump.get(str(14-j))+self.r_trump.get(str(14-i))+"o")
count = list.count(hand)
rowlist.append(count)
self.hands += count
rowhandlist.append(hand)
j += 1
self.handlist.append(rowhandlist)
totlist.append(rowlist)
i += 1
return totlist
Plotgraph.py
import numpy as np
import matplotlib.pyplot as plt
class Plotgraph:
def __init__(self):
pass
def writegraph(self,graphlist,handlist,hands):
column_labels = list('AKQJT98765432')
row_labels = list('AKQJT98765432')
data = np.array(graphlist)
fig,ax = plt.subplots()
heatmap = ax.pcolor(data, cmap=plt.cm.Blues)
ax.set_xticks(np.arange(data.shape[0])+0.5, minor=False)
ax.set_yticks(np.arange(data.shape[1])+0.5, minor=False)
ax.invert_yaxis()
ax.xaxis.tick_top()
ax.set_xticklabels(row_labels, minor=False)
ax.set_yticklabels(column_labels, minor=False)
i = 0
while i < 13:
j = 0
while j < 13:
plt.text(0.25+j,0.75+i,str(handlist[i][j]))
j += 1
i += 1
plt.title("totalhands = "+str(hands), y=-0.1)
fig.colorbar(heatmap, ax=ax)
plt.show()
Recommended Posts