Blackjack with Statistics
Overview
The purpose of this program is to create a Black Jack game that allows for employs actual game play in combination with a Monte Carlo experiment of sorts. The hold data and the results of each individual game are recorded to the SD card in a tab delimited data file. This file is then transferred to the computer via the SD card adapter and read into MATLAB where the data is read in, and analyzed. This produces a bar graph of the user selected hold values vs. the winning percentage of each hold value.
Necessary Parts
- 4GDLuLCD
- Four Push buttons
- SD Card
- SD Card Breakout Board
Pin Outs
uLCD
mbed | uLCD Header | uLCD Cable |
---|---|---|
Vu | 5V | 5V |
GND | GND | GND |
TX(p28) | RX | TX |
RX(27) | TX | RX |
p30 | Reset | Reset |
SD Card Breakout
This link contains the necessary libraries and code examples to properly use the SD File System. However, there is a difference between this library and the one we used. This standard library does not utilize the chip detect function, therefore; the p14 connection shown below is not necessary for implementation. The statistics for this are stored in a file called stats.txt.
mbed | SD Card Reader |
---|---|
p8 | CS |
p5 | DI |
Vout (3.3V) | VCC |
p7 | SCK |
GND | GND |
p6 | DO |
p14 | CD |
Pushbuttons
The pushbuttons were cast for multiple purposes in this game. The first two buttons are for betting amounts, for this instance, we hard coded them for values of 10 and 50, which are normal betting values, slightly above the table minimum for smaller casinos. The next two buttons were used for stand/hit, and for play again (y/n). In further development of this code, the first two would also be cast as split and double down.
mbed | choice |
---|---|
p9 | 10 |
p10 | 50 |
p11 | Hit/Yes |
p12 | Stand/No |
Code
Import programECE4180Project
final project
This is the matlab code used to generate the statistics and plot. /media/uploads/bkf34/blackjack4180.m
Image/Video
Below is the assembled product. Shown below is the video of the project working.
Future Development
Adding a line at the beginning of the text file to store the randseed value. This would make sure that there is a different instance of the game every time it is powered on. Implementing the double down and split functions. The latter would almost certainly require a bigger screen, and to improve graphics.
Please log in to post comments.