So as a learning experience, I decided to try writing a Blackjack game.
I work for a company called Wireless Knowledge where I do a lot of ASP.NET and mobile web stuff, but I never get a chance to write Windows applications. So as a learning experience, I decided to try writing a Blackjack game. I was impressed with the speed of application development. The basics for this game were complete in about 10 hours. The current bet amount The player's bank The suggested bet The card count
Because it was a learning experience, there are some unnecessary features. But I learned a lot about Windows Forms development in .NET as a result and thought others would find this useful as well.
I wanted to keep the playing area as clutter-free as possible. General controls are located in the status bar at the bottom of the screen. Double-clicking on each of the player's circles will access the user controls.
Setting the number of players resets all player objects so you should do that before you begin play. You'll initially start off playing spot #1, but you can play as many of the hands as you like by changing the player type to human.
Setting the number of decks creates a new shoe and resets the card counts so you should also set that up before play begins.
You can adjust the speed that the computer players play by changing the delay setting. Also, if you have a faster computer and a nice graphics card, there are two lines of code in the main form paint event that make the graphics slightly smoother if you uncomment them.
Muting prevents the shuffling sound from playing when the shoe requires shuffling and speeds up play since the sound is played synchronously (as it should be, otherwise you hear the shuffling while the cards are being dealt).
Auto Deal relieves you from having to click the Deal button for each hand; however, you won't be given a chance to change your bet. Use this for prolonged practice periods before your trip to Vegas.
The keyboard can be used if you prefer and it makes playing even faster.
B Double Down
Double-clicking in each player's circle brings up a dialog where you select the type of player (human/computer), the playing strategy and the card-counting method.
Each player's circle highlights in different colors during play to indicate the suggested move depending on the playing strategy selected. The colors match the colors of the buttons at the bottom of the screen to make it easy to see what the 'correct' move is.
If no playing strategy is selected, the player's circle will highlight in gold just to indicate which player's turn it is.
The numbers next to each player's circle are (in order from top to bottom):
The suggested bet comes from the card-counting method chosen and will be used by all the computer players automatically. For human players, it is only a suggestion and you need to type that in as your bet if you want to use it.Rules
- $10 table minimum (you can actually type in less, but computer players will never go below this amount)
- Double-down on 7 or greater and all soft hands
- Dealer stands on soft-17
- Only one split allowed per hand
- Double-down after a split is allowed
- Split aces receive only one more card per hand
Playing Strategies: Basic Single Deck This is basic single deck strategy. Use this if you set the deck count to 1. Basic Multi Deck This is basic strategy for multiple decks. Use this when you set the deck count to anything other than 1. Aggressive Multi Deck This is my own, multi-deck strategy. This strategy makes aggressive use of splitting and doubling down. Smart Multi Deck This is my own concoction. It is based on the Aggressive strategy, but also takes the card count into consideration for certain situations. High-Low Multi Deck* This is the standard High-Low strategy for blackjack. There is a card counting method by the same name. These can be used together, but they don't have to be.
Card Counting Methods: Hi-Lo High-Low Hi Opt I Hi Opt II Silver Fox Brh I Brh II Canfield Expert Canfield Master KO Omega II Red Seven Revere Adv. Plus Minus Revere Point Count' Unb. Zen 11 Uston Adv. Plus Minus Uston APC Uston SS Wong Halves Zen Count Hi-Lo Ace Side Count HiOptI Ace-Seven Side Count
- I didnt want to bother with Insurance. It is an important side bet that most casinos allow, but it is difficult to implement because it requires two rounds of input from the users: one for insurance and one to play the hand.
- A more graphical way of betting would be nicesay dragging chips from the tray to each player's circle?
- Animated cards might be nice too. Instead of watching them just pop up they could slide out of the shoe and into place. This might slow down the play if the computer or graphics card isn't fast enough so you might need to make this optional.
- A more user-friendly way of setting up the initial player positions, strategies, methods, bank, etc. And a way of persisting these settings between executions would be very nice. Maybe the objects could be serialized? Let me know if you find a graceful, .NET approach to this problem.
- Dynamic rules. Casino rules vary greatly and it would be nice to be able to select a casino and have the rules automatically take effect.
- Add the ability to select the card back. This should be easy since they're all there in the images.resx file. I just never got around to it.
- It would be nice to be able to split more than once, but this would require substantial changes to the UI. You would probably have to move the numbers somewhere else to make room for additional hands.
- Dynamic table minimum. Easy to implement.
- Add a control on the User Controls dialog to adjust the player's bank.
- Add more controls on the User Controls dialog to select whether or not to display the bank, suggested bet and card count.
Credits:I originally borrowed J some card graphics off a gambling site, but then saw Tim Smelser's article in GotDotNet where he loaded the cards32.dll into a resource file and I decided to use that instead so credit to Tim for that. I did add a new card back for the Bellagio Hotel and Casino just to add a bit of class.
*The High-Low playing strategy was pulled from the book "Professional Blackjack" by Stanford Wong so kudos to Stanford for that.