This package provides a simple implementation of a Blackjack game with functionalities for card dealing, scoring, splitting hands, doubling down, insurance betting, and more. It allows players to interactively play a round of Blackjack with multiple players.
๐ Installation
You can install the package from GitHub by using devtools:
# Install devtools if not already installed
install.packages("devtools")
# Install Blackjack from GitHub
library(devtools)
devtools::install_github("MonashARP/game-package-wallabies")โจ Features
๐ฎ Interactive multi-player gameplay
๐ Configurable number of decks
โ Official Blackjack rules:
Surrender
Double Down
Insurance
Split Hands
๐ฏ Accurate hand scoring
๐คต Dealer follows house logic
๐ End-of-round results and outcome summary
๐ Getting Started
Hereโs a quick example of how to start a Blackjack game interactively:
library(Blackjack)
# Start a full round of Blackjack
play_blackjack()During the game, youโll be prompted to enter:
Number of players
Number of decks
Whether to hit, stand, surrender, double down, or split (depending on your hand)
๐ฆ Package Structure
| Function | Purpose |
|---|---|
create_board() |
Generates a shuffled deck of cards |
deal_cards() |
Deals cards to players and dealer |
score_hand() |
Calculates the score of a hand |
player_split() |
Splits a hand if the two cards match |
double_down() |
Performs a double-down action |
surrender_hand() |
Executes a surrender decision |
dealer_play() |
Implements the dealerโs turn logic |
insurance_bet() |
Handles insurance option if dealer shows an Ace |
announce_winner() |
Compares scores and determines outcomes |
play_blackjack() |
Runs the full interactive game |
