Dealer Turn Logic
dealer_turn.Rd
Simulates the dealer’s turn in Blackjack: the dealer hits until reaching 17 or higher, standing on a hard 17 but hitting on a soft 17.
Value
A list with:
- hand
The final dealer hand after drawing cards.
- deck
The updated deck after removing drawn cards.
- total
The final total value of the dealer's hand.
Details
The dealer will continue to hit on any total <17, and also hit if total=17 with a soft ace (soft 17).
Examples
# Create a shuffled deck
deck <- create_shuffled_deck()
# Deal 2 cards to the dealer
deal_result <- deal_hand(deck, 2)
dealer_hand <- deal_result$hand
deck <- deal_result$deck
# Let the dealer play
result <- dealer_turn(dealer_hand, deck)
#> [1] Dealer's hand: 4♠ J♥ 10♦ Total: 24
result$hand # Final dealer hand
#> card[3]
#> 4♠ J♥ 10♦
result$total # Final score
#> [1] 24