Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- pokerFile = open("poker-hand-testing.data",'rU')
- totalCount = 0
- nothingCount = 0
- pairCount = 0
- twoPairCount = 0
- threeOfaKindCount = 0
- straightCount = 0
- flushCount = 0
- fullHouseCount = 0
- fourOfaKindCount = 0
- straightFlushCount = 0
- royalFlushCount = 0
- handList = []
- for line in pokerFile:
- totalCount += 1
- handRank = int(line.split(',')[-1])
- if handRank == 0:
- nothingCount += 1
- elif handRank == 1:
- pairCount += 1
- elif handRank == 2:
- twoPairCount += 1
- elif handRank == 3:
- threeOfaKindCount += 1
- elif handRank == 4:
- straightCount += 1
- elif handRank == 5:
- flushCount += 1
- elif handRank == 6:
- fullHouseCount += 1
- elif handRank == 7:
- fourOfaKindCount += 1
- elif handRank == 8:
- straightFlushCount += 1
- elif handRank == 9:
- royalFlushCount += 1
- print "Total hands in file: ",totalCount
- print "Count of hands: ",nothingCount,pairCount,twoPairCount,\
- threeOfaKindCount,straightCount,flushCount,fullHouseCount,\
- fourOfaKindCount,straightFlushCount,royalFlushCount
- totalCountFP = float(totalCount)
- print "Probability:"
- print " of nothing: %6.2f %%" % (100* nothingCount/totalCountFP)
- print " of one pair: %6.2f %%" % (100* pairCount/totalCountFP)
- print " of two pairs: %6.2f %%" % (100* twoPairCount/totalCountFP)
- print " of three of a kind: %6.2f %%" % (100* threeOfaKindCount/totalCountFP)
- print " of a straight: %6.2f %%" % (100* straightCount/totalCountFP)
- print " of a flush: %6.2f %%" % (100* flushCount/totalCountFP)
- print " of a full house: %6.2f %%" % (100* fullHouseCount/totalCountFP)
- print " of four of a kind: %6.2f %%" % (100* fourOfaKindCount/totalCountFP)
- print " of a straight flush: %6.3f %%" % (100*straightFlushCount/totalCountFP)
- print " of a royal flush: %6.4f %%" % (100 *royalFlushCount/totalCountFP)
- #def getHand():
- playerHand = pokerFile.readline(random.randint(0,1000000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement