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

http://developer.mbed.org/media/uploads/4180_1/x8185.png.pagespeed.ic.XZ5IOV2PW-.png

mbeduLCD HeaderuLCD Cable
Vu5V5V
GNDGNDGND
TX(p28)RXTX
RX(27)TXRX
p30ResetReset

SD Card Breakout

http://developer.mbed.org/media/uploads/simon/xusd-breakout_i_ma.jpg.pagespeed.ic.ipnOw2rc3y.webp

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.

SD File System Cookbook Page

mbedSD Card Reader
p8CS
p5DI
Vout (3.3V)VCC
p7SCK
GNDGND
p6DO
p14CD

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.

mbedchoice
p910
p1050
p11Hit/Yes
p12Stand/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. /media/uploads/bkf34/0422150047.jpg 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.