Excel Casino War with VBA Macro Code
War, the simplest card game ever thought of and played by children everywhere, is actually being played in casinos.
The rules of the game are as straightforward as they come. The player plays against the dealer (or "house").
The player places a wager
The dealer deals one card to the player and one card to the house.
If the player's card is higher, they win the wager (1 to 1). If the player's card is lower, they lose the wager. Ace is high, 2 is low. The suit of the card doesn't matter.
The player can also choose to make a side bet or bonus bet in which the player is betting that the dealer's first card and the player's first card will tie. The payout on the bonus bet is 10 to 1.
The fun part comes in when the cards have equal value. Then the player has 2 options:
Forfeit and lose half of their wager.
Go to war
If the player chooses to go to war, they must put up an amount equal to their original bet. The dealer then burns three cards from the deck before dealing one more card to themselves and the player. If the player wins, they get their initial bet back and get paid 1 to 1 on their "war" bet. If the dealer wins, the player loses both their original bet and their "war" bet.
The way the math works out, it is always better to choose to go to war rather than surrender. Also, the odds of the value of the cards being the same is less than 10%, so you should not place a side bet.
Those are really the only decisions that you have to make. If you follow those two rules, then the house edge is determined by the number of decks being used. The more decks used, the higher the edge is for the house - and the worse the return is for the player. Excel Casino War uses 6 decks, which puts the house edge at 2.88% according to Wizard of Odds.
After building Excel Blackjack, writing the VBA code for Excel Casino War was comparatively easy because the games are similar in a lot of ways and I was able to reuse a lot of the code.
Excel Workbook with playable game and full access to the VBA macro code.