Thank you for browsing. It is pbird yellow.
This time, I counted the number of times "AA" was distributed to "every 10,000 hands". There are days when AA comes to the extreme and days when it doesn't come at all, but what about the reality ...
↓ Analysis result
How to read this table ・ The x-axis is every 10,000 hands (~ 10000, ~ 20000, ~ 30000, ...) ・ The y-axis is the number of times AA was distributed is.
The dispersion is quite intense, with max 67 times and min 31 times. .. ..
I also checked KK. ↓ Analysis result
The following is the source code. The program is a complete beginner, so if you have any suggestions on how to write better code, please let us know! !!
pokermain.py
from holdcards import Holdcards
from plotgraph import Plotgraph
import os
import glob
import re
path='Write the path here'
hand = "AA" #Hand to check: Can be changed freely
count = 10000 #For each hand you want to check: Can be changed freely
num = lambda val : int(re.sub("\\D", "", val))
filelist = sorted(glob.glob(os.path.join(path,"*.txt"),recursive=True),key = num)
totcards = []
graphdata = []
countdata = []
counthands = []
for item in filelist:
print(item)
with open(item) as f:
data = f.readlines()
card = Holdcards()
h_cards = card.find_holdcards(data)
totcards += h_cards
i = 0
while len(totcards[count*i:count*(i+1)]) == count:
graphdata.append(totcards[count*i:count*(i+1)])
#counthands.append(str(count*i+1)+"~"+str(count*i+len(totcards[count*i:count*(i+1)])))
i += 1
for item in graphdata:
countdata.append(item.count(hand))
print(len(graphdata))
print(countdata)
graph= Plotgraph()
graph.writegraph(countdata,hand,count,len(graphdata)*count)
python: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.tothands = 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
#print(hand + ":" + str(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,countlist,hand,count,tothands):
x = np.arange(len(countlist))
width = 0.75
rects = plt.bar(x, countlist, width)
plt.xlabel("i × "+str(count)+"hands")
plt.ylabel("count of "+hand)
plt.title("hand = "+hand+" , totalhands = "+str(tothands))
for rect in rects:
height = rect.get_height()
plt.annotate('{}'.format(height),
xy=(rect.get_x() + rect.get_width() / 2, height),
size=7,
xytext=(0, 3),
textcoords="offset points",
ha='center', va='bottom')
plt.show()
Recommended Posts