Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Gongsta committed Jun 22, 2024
1 parent e8f6e51 commit 78c1881
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 286 deletions.
2 changes: 1 addition & 1 deletion src/abstraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import argparse
from sklearn.cluster import KMeans

USE_KMEANS = True # use kmeans if you want to cluster by equity distribution (more refined, but less accurate)
USE_KMEANS = False # use kmeans if you want to cluster by equity distribution (more refined, but less accurate)
NUM_FLOP_CLUSTERS = 10
NUM_TURN_CLUSTERS = 10
NUM_RIVER_CLUSTERS = 10
Expand Down
22 changes: 12 additions & 10 deletions src/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PokerEnvironment:
Also see the HoldEmHistory class in holdem.py
"""

def __init__(self) -> None:
def __init__(self, input_cards=False) -> None:
self.players: List[Player] = []
self.deck = Deck()

Expand Down Expand Up @@ -41,10 +41,10 @@ def __init__(self) -> None:

# FIXED BALANCES
self.new_player_balance = 2500
self.SMALL_BLIND = 10
self.BIG_BLIND = 20
self.SMALL_BLIND = 100
self.BIG_BLIND = 200

self.INPUT_CARDS = True
self.input_cards = input_cards

self.history = []
self.players_balance_history = [] # List of "n" list for "n" players
Expand Down Expand Up @@ -121,8 +121,10 @@ def count_remaining_players_in_round(self):
def start_new_round(self):
assert len(self.players) >= 2 # We cannot start a poker round with less than 2 players...

if self.INPUT_CARDS:
if self.input_cards:
self.new_player_balance = int(input("Enter the starting balance for the players: "))
self.BIG_BLIND = int(input("Enter the big blind: "))
self.SMALL_BLIND = int(self.BIG_BLIND / 2)
# Reset Players
for player in self.players:
player.playing_current_round = True
Expand Down Expand Up @@ -234,7 +236,7 @@ def play_preflop(self):
player_idx = (self.dealer_button_position + 1 + i) % len(self.players)
card_str = ""
for i in range(2):
if self.INPUT_CARDS and player_idx == 0:
if self.input_cards and player_idx == 0:
card = Card(input(f"Enter the card that was dealt (ex: Ah): "))
else:
card = self.deck.draw()
Expand All @@ -248,7 +250,7 @@ def play_flop(self):
self.deck.draw() # We must first burn one card, TODO: Show on video

for i in range(3): # Draw 3 cards
if self.INPUT_CARDS:
if self.input_cards:
card = Card(input(f"Input the {i}-th community card (ex: 'Ah'): "))
else:
card = self.deck.draw()
Expand All @@ -265,7 +267,7 @@ def play_flop(self):
def play_turn(self):

self.deck.draw()
if self.INPUT_CARDS:
if self.input_cards:
card = Card(input("Input the turn card (ex: '5d'): "))
else:
card = self.deck.draw()
Expand All @@ -280,7 +282,7 @@ def play_turn(self):

def play_river(self):
self.deck.draw()
if self.INPUT_CARDS:
if self.input_cards:
card = Card(input(f"Input the river card (ex: 'Ah'): "))
else:
card = self.deck.draw()
Expand Down Expand Up @@ -341,7 +343,7 @@ def end_round(self):
for idx, player in enumerate(self.players):
if player.playing_current_round:
indices_of_potential_winners.append(idx)
if self.INPUT_CARDS and idx == 1:
if self.input_cards and idx == 1:
# Add opponents hand to calculate showdown winner
self.players[1].clear_hand()
self.players[1].add_card_to_hand(
Expand Down
Loading

0 comments on commit 78c1881

Please sign in to comment.