The purpose of this project was to test the built-in capabilities of Microsoft Excel tool (without using VBA) to perform non-routine tasks. A simplified, single-player version of the popular blackjack game was developed for this purpose.
The goal of the participant is to get as close to 21 as possible, without going over.
Whether an ace is worth 1 or 11 depends on the player. Face cards are worth 10 and any other card is worth its pip value.
The player goes first and decides whether to "stand" (not ask for another card) or "hit" (ask for another card in order to reach 21). Hence, a player may stand on their two cards or ask the dealer for additional cards, one at a time, until they either decide to stand on the total (if it is under 21) or go "bust" (if it is over 21).
Manually recalculating the cells in the sheets is the main option used in the implementation of the game. This option prevents circular references between functions and performs calculations only when the user manually presses the F9
key.
There are 5 cards on each player's board, with the player starting with two cards and the dealer with one. A player's card total and corresponding win/loss message will be displayed when the F9
key is pressed.
Where all the "behind the scenes" calculations are made:
- Shuffling th order of the cards in the pack.
- Distribution of the cards to the dealer and the participant.
- In each draw, the sum of the cards is calculated for each player.
The main functions of the game are:
Changed Ace?
which calculates whether the sum of aces should change from 11 to 1 to allow the game to continue.Sum
which calculates the player's sum and whether he reached the sum of 21 and won, or exceeded it and lost (A tie between the dealer and the player is also considered a loss).
Provides a brief explanation of the game.
Where the game itself takes place, serves as the user interface for the game.
- Microsoft Office Excel 2007, or later.
- Launch the Microsoft Excel spreadsheet on the
Blackjack
sheet. - Set the "Restart" label to
TRUE
and the "Draw more" label toHIT
. - Press
F9
once, then set the "Restart" label toFALSE
.
- To draw more cards, press
F9
(the "Draw more" label should be set toHIT
). - When you are done asking for more cards, change "Draw more" label to
STAND
. - To find out who won, press
F9
one last time (A message stating "you win/lose" will appear in the middle of the game table).
Copyright © 2019, erelado All rights reserved.
This source code is licensed under the GPL-v3.0 license found in the LICENSE file in the root directory of this source tree.