Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.11 KB | None | 0 0
  1. import random
  2.  
  3. pokerFile = open("poker-hand-testing.data",'rU')
  4.  
  5. totalCount         = 0
  6. nothingCount       = 0
  7. pairCount          = 0
  8. twoPairCount       = 0
  9. threeOfaKindCount  = 0
  10. straightCount      = 0
  11. flushCount         = 0
  12. fullHouseCount     = 0
  13. fourOfaKindCount   = 0
  14. straightFlushCount = 0
  15. royalFlushCount    = 0
  16. handList = []
  17.  
  18. for line in pokerFile:
  19.     totalCount += 1
  20.  
  21.     handRank = int(line.split(',')[-1])
  22.  
  23.     if handRank == 0:
  24.         nothingCount += 1
  25.     elif handRank == 1:
  26.         pairCount += 1
  27.     elif handRank == 2:
  28.         twoPairCount += 1
  29.     elif handRank == 3:
  30.         threeOfaKindCount += 1
  31.     elif handRank == 4:
  32.         straightCount += 1
  33.     elif handRank == 5:
  34.         flushCount += 1
  35.     elif handRank == 6:
  36.         fullHouseCount += 1
  37.     elif handRank == 7:
  38.         fourOfaKindCount += 1
  39.     elif handRank == 8:
  40.         straightFlushCount += 1
  41.     elif handRank == 9:
  42.         royalFlushCount += 1
  43.        
  44. print "Total hands in file: ",totalCount
  45. print "Count of hands: ",nothingCount,pairCount,twoPairCount,\
  46.       threeOfaKindCount,straightCount,flushCount,fullHouseCount,\
  47.       fourOfaKindCount,straightFlushCount,royalFlushCount
  48.  
  49. totalCountFP = float(totalCount)
  50.  
  51. print "Probability:"
  52. print " of nothing:          %6.2f %%" % (100*      nothingCount/totalCountFP)
  53. print " of one pair:         %6.2f %%" % (100*         pairCount/totalCountFP)
  54. print " of two pairs:        %6.2f %%" % (100*      twoPairCount/totalCountFP)
  55. print " of three of a kind:  %6.2f %%" % (100* threeOfaKindCount/totalCountFP)
  56. print " of a straight:       %6.2f %%" % (100*     straightCount/totalCountFP)
  57. print " of a flush:          %6.2f %%" % (100*        flushCount/totalCountFP)
  58. print " of a full house:     %6.2f %%" % (100*    fullHouseCount/totalCountFP)
  59. print " of four of a kind:   %6.2f %%" % (100*  fourOfaKindCount/totalCountFP)
  60. print " of a straight flush: %6.3f %%" % (100*straightFlushCount/totalCountFP)
  61. print " of a royal flush:    %6.4f %%" % (100   *royalFlushCount/totalCountFP)
  62.  
  63. #def getHand():
  64.     playerHand = pokerFile.readline(random.randint(0,1000000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement