legal gambling bro 🤘
- The application loads all strategy files from the
strats
directory. - It initializes each strategy with a set amount of credits (default: 1000).
- The simulation runs for a minimum number of rounds (default: 50) or until the player runs out of credits.
- For each round:
- The player places a bet based on their strategy.
- Cards are dealt to the player and dealer.
- The player makes decisions (hit, stand, etc.) based on their strategy.
- The dealer plays according to standard rules (hit on 16 or below, stand on 17 or above).
- The round result is determined, and credits are adjusted accordingly.
- After all rounds, the application plots the performance of each strategy and prints the final results.
Card
: Represents a playing card with a rank and suit.Deck
: Represents a deck of cards with methods to draw cards.Player
: Represents a player with credits, a hand, and a strategy.BlackjackGame
: Manages the game logic for a single round of blackjack.Strategy
: An abstract base class that all strategies should inherit from.
To create a new strategy:
- Create a new Python file in the
strats
directory (e.g.,my_strategy.py
). - Define a
Strategy
class in this file with the following methods:__init__(self)
: Initialize any strategy-specific variables.decide_bet(self, player_credits)
: Decide the bet amount for the round.decide_action(self, player_hand, dealer_up_card)
: Decide the action to take (hit or stand).decide_split(self, player_hand)
: Decide whether to split a pair (optional).decide_double_down(self, player_hand)
: Decide whether to double down (optional).update_result(self, result)
: Update the strategy based on the round result (optional).
Here's a boilerplate code for a new strategy:
// to b added