Create a Shuffled Blackjack Shoe
create_shuffled_deck.Rd
Creates a shuffled Blackjack shoe consisting of multiple standard 52-card decks combined.
Each standard deck includes cards from all four suits ("\u2660"
, "\u2665"
, "\u2666"
, "\u2663"
) and 13 ranks (2-10
, J
, Q
, K
, A
).
The function returns a vctrs class "card" record with fields: name, rank, suit_symbol, suit, and is_face.
Value
A [vctrs][vctrs::new_rcrd] "card" record vector of length `52 * noOfDecks`. Each element has fields:
name
- character, e.g., "2♣", "A♠"rank
- character, one of "Two", ..., "Ace"suit_symbol
- character, one of "♠", "♥", "♦", "♣"suit
- character, one of "Spade", "Heart", "Diamond", "Club"is_face
- logical; TRUE for Jack/Queen/King, FALSE otherwise
Details
The returned object is a vctrs record of class "card"
using vctrs::new_rcrd()
.
You can extract the underlying character names with as.character()
, or access fields via vctrs::field()
.
The print.card()
method displays all card names, and format.card()
returns the card's "name" field.
Examples
deck <- create_shuffled_deck()
length(deck) # 208 (4 decks)
#> [1] 208
deck # Prints the deck of cards
#> card[208]
#> 9♥ 7♠ 2♠ 6♠ K♠ A♣ A♦ 6♦ 2♥ 3♦ 2♦ 10♥ 4♦ 9♦ Q♠ 8♥ 2♠ 4♥ 6♥ 8♣ K♥ 8♦ 10♣ Q♣ 5♦ 7♥ 4♠ 5♠ 2♥ A♠ 10♠ 6♦ 5♥ 4♦ 3♦ A♣ 5♦ 5♣ 8♥ 8♠ 9♣ 8♠ 5♣ A♦ J♦ 9♥ 9♠ 6♠ 4♥ J♠ 4♥ 2♠ 6♥ 10♥ 7♦ 4♣ 2♣ 2♠ 7♣ K♠ 4♠ 7♠ 3♥ J♣ Q♣ A♠ Q♣ 8♦ 6♣ 7♦ 10♠ J♣ 9♠ 5♥ 3♦ K♦ J♦ 8♣ 10♦ 10♥ K♦ 8♥ 8♦ 8♣ 10♦ Q♥ A♠ A♠ J♣ J♠ 5♦ 5♣ J♥ 8♠ 7♠ J♦ 2♦ Q♣ 10♠ 4♣ 2♥ 7♦ Q♠ K♣ 3♠ 3♣ 6♠ Q♦ 3♣ 9♣ J♥ Q♠ 10♦ Q♠ Q♦ 8♠ 7♣ 2♣ J♣ 7♠ 4♣ 5♠ 6♥ K♣ 7♥ 10♥ K♣ 3♠ J♥ 4♠ A♥ A♥ 6♦ 5♥ 3♣ 7♥ J♠ 5♠ Q♥ 6♣ 8♣ 5♠ 3♥ 7♦ 8♦ 4♦ K♣ 4♦ 9♠ 6♦ 9♠ 9♦ K♦ 5♣ 2♣ Q♦ 3♥ 10♣ Q♦ Q♥ K♠ 7♣ 9♣ J♠ K♥ 7♣ 3♠ 5♦ Q♥ 6♣ 10♣ 9♥ 10♣ 6♥ 4♠ 2♦ 10♠ K♦ 3♦ 9♣ 3♣ 9♥ K♠ 2♦ 6♠ A♦ 4♣ 3♠ 10♦ A♥ A♥ 6♣ J♦ A♦ 2♣ 9♦ 7♥ K♥ 3♥ 2♥ 8♥ A♣ 4♥ J♥ 5♥ 9♦ A♣ K♥
deck2 <- create_shuffled_deck(noOfDecks = 6)
length(deck2) # 312
#> [1] 312