Guest User

Poker Simulator Starting Hands

a guest
Jan 17th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.53 KB | None | 0 0
  1. import random
  2.  
  3. # Texas Hold'em Poker Starting Hands Simulator.
  4. # 9 Handed Table.
  5. # Output info : Every player's number of times when starting hands meet a specific criteria
  6. # Written in Python 3.5.1
  7. # Credits : Dolinta Mihai @ hs2000@inbox.ru
  8.  
  9. # All % calculations are for 1.000.000 hands
  10. # Criteria 1 = Any suited Ace..................... ~  3.60% Stability after 600 hands
  11. # Criteria 2 = Pocket Aces........................ ~  0.45% Slight instability after 15000 hands
  12. # Criteria 3 = Any suited 2 cards................. ~ 23.50% Slight instability after 100 hands
  13. # Criteria 4 = Any suited connectors.............. ~  3.92% Good stability after 1000 hands
  14. # Criteria 5 = Any suited & unsuited connectors... ~ 15.69% Slight instability after 2200 hands
  15.  
  16. p1cc = 0
  17. p2cc = 0
  18. p3cc = 0
  19. p4cc = 0
  20. p5cc = 0
  21. p6cc = 0
  22. p7cc = 0
  23. p8cc = 0
  24. p9cc = 0
  25. pcc  = [p1cc, p2cc, p3cc, p4cc, p5cc, p6cc, p7cc, p8cc, p9cc]  
  26.  
  27. rank  = ["2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K", "A"]
  28. color = ["h", "d", "s", "c"]
  29.  
  30. # Change range from 1 to 1000000, this represents the number of hands dealt to all players
  31. # If range is higher than 2, u may want to comment whole function that show players hands (Before 1. Function)
  32. for i in range(2):
  33.     bannedcards  = []
  34.     player1      = []
  35.     player2      = []
  36.     player3      = []
  37.     player4      = []
  38.     player5      = []
  39.     player6      = []
  40.     player7      = []
  41.     player8      = []
  42.     player9      = []
  43.     players      = [player1, player2, player3, player4, player5, player6, player7, player8, player9]
  44.  
  45.     def dealcardtoplayers(player, banned, rank, color):
  46.  
  47.         cardrank  = random.choice(rank)
  48.         cardcolor = random.choice(color)
  49.  
  50.         card = cardrank + cardcolor
  51.  
  52.         if card not in banned:
  53.             player.append(card)
  54.             banned.append(card)
  55.         else:
  56.             dealcardtoplayers(player, banned, rank, color)
  57.         return
  58.  
  59.     for cards in "12":
  60.         for player in players:
  61.             dealcardtoplayers(player, bannedcards, rank, color)
  62.        
  63.     Player1cards   = ""
  64.     Player2cards   = ""
  65.     Player3cards   = ""
  66.     Player4cards   = ""
  67.     Player5cards   = ""
  68.     Player6cards   = ""
  69.     Player7cards   = ""
  70.     Player8cards   = ""
  71.     Player9cards   = ""
  72.     Playercards    = [Player1cards, Player2cards, Player3cards, Player4cards, Player5cards, Player6cards, Player7cards, Player8cards, Player9cards]
  73.  
  74.     for player in players:
  75.         for card in player:
  76.             Playercards[players.index(player)] = Playercards[players.index(player)] + card
  77.  
  78.     #Don't uncomment this with iteration range higher than 2
  79.     #for players in Playercards:
  80.     #   print("Player" + str(Playercards.index(players)+1) + "'s cards are : " + players)
  81.  
  82.     # 1. Function that calculates how much times players hit any suited Ace combinations
  83.     #def criteriacount(Playercards, pcc, rank, color):
  84.     #   for players in Playercards:
  85.     #       if players[0] == "A" or players[2] == "A":
  86.     #           if players[1] == players[3]:
  87.     #               pcc[Playercards.index(players)] = pcc[Playercards.index(players)] + 1
  88.  
  89.     # 2. Function that calculates how much times players hit pocket Aces combination
  90.     #def criteriacount(Playerscards, pcc, rank, color):
  91.     #   for players in Playercards:
  92.     #       if players[0] == "A" and players[2] == "A":
  93.     #           pcc[Playercards.index(players)] = pcc[Playercards.index(players)] + 1
  94.  
  95.     # 3. Function that calculates how much times players hit any 2 suited cards combination
  96.     #def criteriacount(Playerscards, pcc, rank, color):
  97.     #   for players in Playercards:
  98.     #       if players[1] == players[3]:
  99.     #           pcc[Playercards.index(players)] = pcc[Playercards.index(players)] + 1
  100.  
  101.     # 4. Function that calculates how much times players hit any suited connector combination
  102.     #def criteriacount(Playercards, pcc, rank, color):
  103.     #   for players in Playercards:
  104.     #       if players[1] == players[3]:
  105.     #           c1 = players[0]
  106.     #           c2 = players[2]
  107.     #           if rank.index(c1) - rank.index(c2) == -1 or rank.index(c1) - rank.index(c2) == 1 or rank.index(c1) - rank.index(c2) == -12 or rank.index(c1) - rank.index(c2) == 12:
  108.     #               pcc[Playercards.index(players)] = pcc[Playercards.index(players)] + 1
  109.  
  110.     # 5. Function that calculates how much times players hit any unsuited connector combination
  111.     #def criteriacount(Playercards, pcc, rank, color):
  112.     #   for players in Playercards:
  113.     #       c1 = players[0]
  114.     #       c2 = players[2]
  115.     #       if rank.index(c1) - rank.index(c2) == -1 or rank.index(c1) - rank.index(c2) == 1 or rank.index(c1) - rank.index(c2) == -12 or rank.index(c1) - rank.index(c2) == 12:
  116.     #           pcc[Playercards.index(players)] = pcc[Playercards.index(players)] + 1
  117.     #
  118.    
  119.     criteriacount(Playercards, pcc, rank, color)
  120.  
  121. for i in range(len(pcc)):
  122.     print(str(pcc[i]))
Add Comment
Please, Sign In to add comment