Welcome to Bridget's Virtual Casino! This is a single-player Blackjack simulator built in C.
- Single-player Blackjack against the computer dealer.
- Implements standard Blackjack rules:
- Dealer must hit if their hand is less than 17.
- Aces can be counted as 1 or 11 depending on the player's advantage.
- Natural Blackjack detection.
- Continuous gameplay with the option to quit at any time.
- Random card dealing using
rand()for an infinite deck simulation.
To run this project, you'll need:
- A C compiler (e.g., GCC).
- Basic familiarity with terminal/command-line usage.
Compile the program using the following command:
gcc -o blackjack blackjack.cRun the executable to start the game:
./blackjack- The dealer and player are each dealt two cards at the start.
- The player chooses to:
hitto draw another card.standto end their turn.quitto exit the game.
- The dealer plays their turn automatically according to Blackjack rules.
- The winner is determined based on the totals of the hands:
- Natural Blackjack wins immediately.
- A hand closer to 21 without exceeding it wins.
- Ties result in a draw.
- Cards are represented as integers (1-10).
rand()simulates an infinite deck with probabilities adjusted for Blackjack.
- Aces are dynamically counted as 1 or 11 depending on the player's best outcome.
- The dealer's second card remains hidden until their turn.
- Comprehensive checks for busts, ties, and Blackjack rules.
deal_card(): Simulates drawing a random card.tally_hand(): Calculates the total of a hand.reset_hand(): Prepares hands for a new round.get_input(): Reads and processes player input.print_cards(): Displays the current cards and totals.check_naturals(): Checks for immediate Blackjack outcomes.
The code uses arrays to represent hands and separate arrays for handling Aces. Modular functions keep the gameplay logic organized and easy to debug.
The game begins with a welcome message and initial card deals:

An example where the player wins by standing with a higher hand than the dealer:

The dealer busts, and the player automatically wins:

An example where the dealer wins by having a higher hand than the player:

- Add a betting system to simulate real casino gameplay.
- Implement a graphical or web-based UI for a more immersive experience.
- Enhance card-dealing randomness using cryptographic libraries.
- Support multiple players.
Bridget Brinkman
GitHub: @F5F0A0