Guest User

Untitled

a guest
Jun 15th, 2024
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.76 KB | Source Code | 0 0
  1. import os
  2.  
  3. # Define ranges
  4. ranges = {
  5.     "Open Raise": {
  6.         "LJ": ["77+", "ATs+", "KTs+", "QTs+", "JTs", "T9s", "98s", "87s", "AJo+", "KQo"],
  7.         "HJ": ["22+", "A2s+", "KTs+", "QTs+", "J9s+", "T9s", "98s", "87s", "76s", "65s", "54s", "ATo+", "KJo+"],
  8.         "CO": ["22+", "A2s+", "K3s+", "Q6s+", "J7s+", "T7s+", "97s+", "86s+", "75s+", "64s+", "54s", "A9o+", "KTo+", "QTo+", "JTo"],
  9.         "BU": ["22+", "A2s+", "K2s+", "Q2s+", "J4s+", "T5s+", "95s+", "85s+", "74s+", "63s+", "53s+", "43s", "A2o+", "K7o+", "Q9o+", "J9o+", "T9o", "98o"],
  10.         "SB": ["22+", "A2s+", "K2s+", "Q2s+", "J4s+", "T5s+", "95s+", "85s+", "74s+", "63s+", "53s+", "43s", "A2o+", "K7o+", "Q9o+", "J9o+", "T9o", "98o"]
  11.     },
  12.     "IsoRaise": {
  13.         "HJ": ["22+", "A2s+", "KTs+", "QTs+", "JTs", "T9s", "ATo+", "KJo+"],
  14.         "CO": ["22+", "A2s+", "K9s+", "Q9s+", "J9s+", "T9s", "98s", "87s", "ATo+", "KTo+"],
  15.         "BU": ["22+", "A2s+", "KTs+", "QTs+", "JTs", "T9s", "98s", "87s", "ATo+", "KTo+"],
  16.         "SB": ["99+", "ATs+", "KTs+", "QTs+", "JTs", "ATo+", "KQo"],
  17.         "BB": ["99+", "ATs+", "KTs+", "QTs+", "JTs", "ATo+", "KQo"]
  18.     },
  19.     "3bet": {
  20.         "LJ": ["QQ+", "AKo", "AKs"],
  21.         "HJ": ["JJ+", "AKo", "AKs"],
  22.         "CO": ["JJ+", "AJs+", "KQs", "AQo+"],
  23.     },
  24.     "3bet vs Non Steal": {
  25.         "BU": ["99+", "ATs+", "KTs+", "QTs+", "JTs", "AQo+"],
  26.         "SB": ["99+", "ATs+", "KTs+", "QTs+", "JTs", "AJo+", "KQo"],
  27.         "BB": ["JJ+", "AQs+", "AKo"]
  28.     },
  29.     "3bet vs Steal": {
  30.         "BU": ["88+", "A5s-A2s", "KTs+", "QTs+", "JTs", "T9s", "98s", "87s", "76s", "65s", "54s", "AJo+", "KQo"],
  31.         "SB": ["99+", "ATs+", "KTs+", "QTs+", "JTs", "AJo+", "KQo"],
  32.         "BB": ["TT+", "ATs+", "KJs+", "QTs+", "J9s+", "T9s", "AKo"]
  33.     },
  34.     "Call vs 3b IP": {
  35.         "LJ": ["JJ", "AQo", "AQs"],
  36.         "HJ": ["JJ", "AQs-AJs", "KQs", "AQo"],
  37.         "CO": ["JJ-77", "AQs-ATs", "KTs+", "QTs+", "JTs", "T9s", "98s", "87s", "AQo"],
  38.         "BU": ["JJ-55", "AQs-A2s", "K9s+", "Q9s+", "J9s+", "T9s", "98s", "87s", "76s", "65s", "AQo-AJo", "KQo"]
  39.     },
  40.     "4Bet Bluff OOP": {
  41.         "LJ": ["AQs", "KQs", "AQo"],
  42.         "HJ": ["AQs-AJs", "KQs", "AQo"],
  43.         "CO": ["JJ-TT", "AQs-AJs", "KQs", "AQo"],
  44.         "SB": ["JJ-TT", "AQs-AJs", "KJs+", "AQo-AJo", "KQo"]
  45.     },
  46.     "Cold Call vs Non Steal": {
  47.         "BB": ["TT-22", "AJs-A2s", "KQs-K5s", "Q6s+", "J7s+", "T8s+", "97s+", "86s+", "76s", "65s", "54s", "AQo-ATo", "KQo"]
  48.     },
  49.     "Cold Call vs Steal": {
  50.         "BB": ["99-22", "A9s-A2s", "K9s-K5s", "Q9s-Q6s", "J9s-J7s", "T7s+", "97s+", "86s+", "76s", "65s", "54s", "AQo-ATo", "KJo-KTo", "QTo+", "JTo"]
  51.     },
  52.     "4bet": {
  53.         "LJ": ["QQ+", "AKo", "AKs"],
  54.         "HJ": ["QQ+", "AKo", "AKs"],
  55.         "CO": ["QQ+", "AKo", "AKs"],
  56.         "BU": ["QQ+", "AKo", "AKs"],
  57.         "SB": ["QQ+", "AKo", "AKs"],
  58.         "BB": ["QQ+", "AKo", "AKs"],
  59.     },
  60.     "All-In": {
  61.         "LJ": ["QQ+", "AKo", "AKs"],
  62.         "HJ": ["QQ+", "AKo", "AKs"],
  63.         "CO": ["QQ+", "AKo", "AKs"],
  64.         "BU": ["QQ+", "AKo", "AKs"],
  65.         "SB": ["QQ+", "AKo", "AKs"],
  66.         "BB": ["QQ+", "AKo", "AKs"],
  67.     }
  68. }
  69.  
  70. value_order = "23456789TJQKA"
  71.  
  72. def clear_screen():
  73.     os.system('cls' if os.name == 'nt' else 'clear')
  74.  
  75. def generate_full_range(hand_range):
  76.     result = []
  77.     if hand_range[-1] == '+':
  78.         base_rank = hand_range[:-1]
  79.         if len(base_rank) == 2:  # Pocket pairs
  80.             start_index = value_order.index(base_rank[0])
  81.             result.extend([value_order[i] + value_order[i] for i in range(start_index, len(value_order))])
  82.         else:  # Suited or Offsuit hands
  83.             start_rank = base_rank[0]
  84.             suit_type = base_rank[2]
  85.             start_index = value_order.index(base_rank[1])
  86.             if suit_type == 's':
  87.                 result.extend([start_rank + value_order[i] + 'S' for i in range(start_index, len(value_order)) if start_rank != value_order[i]])
  88.             elif suit_type == 'o':
  89.                 result.extend([start_rank + value_order[i] + 'O' for i in range(start_index, len(value_order)) if start_rank != value_order[i]])
  90.     elif '-' in hand_range:
  91.         upper, lower = hand_range.split('-')
  92.         if len(lower) == 2 and len(upper) == 2:  # Pocket pairs
  93.             lower_index = value_order.index(lower[0])
  94.             upper_index = value_order.index(upper[0])
  95.             result.extend([value_order[i] + value_order[i] for i in range(lower_index, upper_index + 1)])
  96.         else:  # Suited or Offsuit hands
  97.             lower_rank = lower[0]
  98.             suit = lower[2]
  99.             lower_index = value_order.index(lower[1])
  100.             upper_index = value_order.index(upper[1])
  101.             result.extend([lower_rank + value_order[i] + suit.upper() for i in range(lower_index, upper_index + 1)])
  102.     else:
  103.         result.append(hand_range)
  104.     return result
  105.  
  106. def hand_in_range(hand, range_list):
  107.     for range_hand in range_list:
  108.         full_range = generate_full_range(range_hand)
  109.         if hand in full_range:
  110.             return True
  111.     return False
  112.  
  113. def get_related_actions(action):
  114.     if action in ["Open Raise", "IsoRaise", "3bet vs Non Steal", "3bet vs Steal", "3bet"]:
  115.         return ["Open Raise", "IsoRaise", "3bet vs Non Steal", "3bet vs Steal", "3bet"]
  116.     elif action in ["4Bet Bluff OOP", "4bet"]:
  117.         return ["4Bet Bluff OOP", "4bet"]
  118.     elif action in ["Call vs 3b IP", "Cold Call vs Non Steal", "Cold Call vs Steal"]:
  119.         return ["Call vs 3b IP", "Cold Call vs Non Steal", "Cold Call vs Steal"]
  120.     else:
  121.         return []
  122.  
  123. def handle_chosen_action(hole_cards, position):
  124.     # Determine if facing LJ open
  125.     is_facing_lj_open = input("Are you facing a LJ open? (y/n): ").lower() == 'y'
  126.     available_actions = get_possible_actions(hole_cards, position, is_facing_lj_open)
  127.     chosen_actions = []
  128.  
  129.     def is_pocket_pair(hand):
  130.         return hand[0] == hand[1] and len(hand) == 2
  131.  
  132.     def is_suited_connector(hand):
  133.         if len(hand) == 3 and hand[2] == 'S':
  134.             rank1 = value_order.index(hand[0])
  135.             rank2 = value_order.index(hand[1])
  136.             return rank2 - rank1 == 1
  137.         return False
  138.  
  139.     while True:
  140.         if position not in ["LJ", "HJ"] and (is_pocket_pair(hole_cards) or is_suited_connector(hole_cards)):
  141.             if not available_actions or (available_actions == ["See Flop", "Fold"]):
  142.                 raise_call = input("Was there a raise and at least one call before you? (y/n): ").lower()
  143.                 if is_pocket_pair(hole_cards):
  144.                     if raise_call == 'y':
  145.                         print("Special rule: You can call with any pocket pair.")
  146.                         input("Press any key to continue...")
  147.                     else:
  148.                         print("Special rule: Fold pocket pair.")
  149.                 elif is_suited_connector(hole_cards):
  150.                     if position in ["CO", "BU"]:
  151.                         if raise_call:
  152.                             print("Special rule: You can call with suited connectors.")
  153.                             input("Press any key to continue...")
  154.                         else:
  155.                             print("Special rule: Fold suited connector.")
  156.                            
  157.  
  158.         available_actions.append("See Flop")
  159.         print(f"Possible actions for {hole_cards} in {position}:")
  160.         for i, action in enumerate(available_actions, 1):
  161.             print(f"{i}. {action}")
  162.         print("0. Fold")
  163.  
  164.         try:
  165.             choice = int(input("Choose your action by number: "))
  166.             if choice == 0:
  167.                 print("You chose to Fold.")
  168.                 break
  169.             elif 1 <= choice <= len(available_actions):
  170.                 chosen_action = available_actions[choice - 1]
  171.                 print(f"You chose to {chosen_action}.")
  172.                 chosen_actions.append(chosen_action)
  173.  
  174.                 if chosen_action == "Open Raise":
  175.                     if position in ["LJ", "SB"]:
  176.                         print("Open Raise to 3bb.")
  177.                     else:
  178.                         print("Open Raise to 2.5bb.")
  179.                 elif chosen_action == "IsoRaise":
  180.                     ip_oop = input("Are you in position (IP) or out of position (OOP)? ").upper()
  181.                     num_limpers = int(input("Enter the number of limpers: "))
  182.                     if ip_oop == "IP":
  183.                         bet_size = 3 + num_limpers
  184.                         print(f"IsoRaise to {bet_size}bb.")
  185.                     elif ip_oop == "OOP":
  186.                         bet_size = 4 + num_limpers
  187.                         print(f"IsoRaise to {bet_size}bb.")
  188.                     else:
  189.                         print("Invalid input for position. Please enter IP or OOP.")
  190.                 elif chosen_action in ["3bet vs Non Steal", "3bet vs Steal"]:
  191.                     ip_oop = input("Are you in position (IP) or out of position (OOP)? ").upper()
  192.                     num_calls = int(input("Enter the number of callers: "))
  193.                     betted_amount = float(input("Enter the amount betted (in bb): "))
  194.                     if ip_oop == "IP":
  195.                         if input("Are you facing a minraise? (y/n): ").lower() == 'y':
  196.                             raise_size = 4 * betted_amount + num_calls * betted_amount
  197.                         else:
  198.                             raise_size = 3 * betted_amount + num_calls * betted_amount
  199.                         print(f"3bet to {raise_size}bb.")
  200.                     elif ip_oop == "OOP":
  201.                         raise_size = 4 * betted_amount + num_calls * betted_amount
  202.                         print(f"3bet to {raise_size}bb.")
  203.                     else:
  204.                         print("Invalid input for position. Please enter IP or OOP.")
  205.                 elif chosen_action == "4Bet Bluff OOP":
  206.                     num_calls = int(input("Enter the number of callers: "))
  207.                     betted_amount = float(input("Enter the amount betted (in bb): "))
  208.                     raise_size = (3 + num_calls) * betted_amount
  209.                     print(f"4Bet to {raise_size}bb.")
  210.                 elif chosen_action == "4bet":
  211.                     num_calls = int(input("Enter the number of callers: "))
  212.                     betted_amount = float(input("Enter the amount betted (in bb): "))
  213.                     if input("Are you facing a minraise? (y/n): ").lower() == 'y':
  214.                         raise_size = (3 + num_calls) * betted_amount
  215.                     else:
  216.                         raise_size = (2.5 + num_calls) * betted_amount
  217.                     print(f"4Bet to {raise_size}bb.")
  218.                 elif chosen_action == "All-In":
  219.                     print("You chose to go All-In.")
  220.                     break
  221.                 elif chosen_action == "See Flop":
  222.                     print("You chose to see the flop.")
  223.                     break
  224.  
  225.                 # Remove the chosen action and related actions from available actions
  226.                 related_actions = get_related_actions(chosen_action)
  227.                 available_actions = [action for action in available_actions if action not in related_actions and action != "See Flop" and action not in chosen_actions]
  228.             else:
  229.                 print("Invalid choice. Please choose a valid number.")
  230.         except ValueError:
  231.             print("Invalid input. Please enter a number.")
  232.  
  233.         input("Press any key to continue...")
  234.  
  235. def get_possible_actions(hole_cards, position, is_facing_lj_open):
  236.     actions = []
  237.  
  238.     if is_facing_lj_open and position != "BB":
  239.         # Override the 3bet ranges with HJ ranges and exclude Open Raise and IsoRaise
  240.         special_ranges = {
  241.             "3bet vs Non Steal": ranges["3bet"]["HJ"],
  242.             "3bet vs Steal": ranges["3bet"]["HJ"],
  243.             "3bet": ranges["3bet"]["HJ"],
  244.         }
  245.     else:
  246.         special_ranges = None
  247.  
  248.     for action, positions in ranges.items():
  249.         if is_facing_lj_open and action in ["Open Raise", "IsoRaise"]:
  250.             continue  # Skip Open Raise and IsoRaise actions when facing LJ open
  251.         if special_ranges and action in special_ranges:
  252.             if hand_in_range(hole_cards, special_ranges[action]):
  253.                 actions.append(action)
  254.         else:
  255.             if position in positions:
  256.                 if hand_in_range(hole_cards, positions[position]):
  257.                     actions.append(action)
  258.  
  259.     return actions
  260.  
  261. def get_poker_options():
  262.     while True:
  263.         clear_screen()
  264.         hole_cards = input("Enter your hole cards (e.g., AQo) or 'exit' to quit: ").upper()
  265.         if hole_cards == 'EXIT':
  266.             break
  267.         position = input("Enter your position (LJ, HJ, CO, BU, SB, BB): ").upper()
  268.         if position == 'EXIT':
  269.             break
  270.  
  271.         handle_chosen_action(hole_cards, position)
  272.  
  273. # Run the function
  274. get_poker_options()
  275.  
Advertisement
Add Comment
Please, Sign In to add comment