Skip to contents

This function runs a simulation of a specified number of Blackjack rounds between an automated player and dealer. The player uses a fixed strategy: they continue drawing cards until reaching a user-defined threshold score (between 12 and 21). The dealer uses a smart strategy defined in dealer_turn_smart().

Usage

simulation_blackjack(threshold = 16, n_sim = 1000, ...)

Arguments

threshold

Numeric value between 12 and 21 indicating the score at which the player stops drawing cards (default is 16)

n_sim

Number of rounds to simulate (default is 1000)

...

Additional arguments (currently unused; reserved for future extensions)

Value

A frequency table summarizing the outcomes of all simulated rounds. It is a table object with three possible values: "Win", "Lose", and "Push".

Details

In each simulated round:

  1. A shuffled Blackjack shoe is created.

  2. Two cards are dealt to both player and dealer.

  3. The player automatically draws until reaching or exceeding the threshold.

  4. The dealer plays according to a smart strategy.

  5. The outcome is determined as "Win", "Lose", or "Push" (draw).

Examples

# Run a short simulation of 10 rounds with a player threshold of 17
set.seed(123)
simulation_result <- simulation_blackjack(threshold = 17, n_sim = 10)
print(simulation_result)
#> Outcome
#> Lose Push  Win 
#>    4    3    3