Results 1 to 6 of 6

Math Help - MatLab-BlackJack game problem help please!

  1. #1
    Newbie
    Joined
    Mar 2010
    Posts
    2

    MatLab-BlackJack game problem help please!

    Create a Matlab program that allows a user to play blackjack (sometimes called "21"). For those of you unfamiliar with the popular casino game, the rules can be found here and on many other websites. Blackjack essentially is a game of chicken between a player and a dealer to see who can get closest to 21 without going over.

    The player may start with a maximum of 1000 chips and the maximum bet per hand is 100 chips.

    There are some special rules that vary from casino to casino. In your Matlab casino, the following rules apply:
    - If you get dealt a "blackjack" you get paid 3-to-2 instead of 1-to-1. If the dealer has a blackjack too you "push" and do not get paid.
    - The dealer hits on a "soft-17" and stays on a "hard-17."
    - You may "split" your cards only once per turn. Once you split your cards, you may play out both hands normally (you may "hit" until you get to 21 or over, "stay" and receive no more cards, or "double down" on the first two cards of each hand)
    - You may "double down" on your first two cards. If you split your hand, you may double down on the first two cards of both hands.
    - You may take "insurance" equal to half the original bet. If you win the insurance bet you get paid 2-to-1.
    - If you dislike your first two cards, you may "surrender" for half your bet and start another hand.

    The user may decide to play against a dealer who deals (1) an infinite deck or (2) a finite number of decks which the user selects (in Vegas, you can find blackjack tables that use 1-8 decks). If the user chooses option (2), reshuffle the decks after 70% of the cards have been used.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    Is there a question in there?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Mar 2010
    Posts
    2
    Well How do I create this programs with the guidelines given?

    BTW here is the link to the rules to BlackJack: Blackjack - Wikipedia, the free encyclopedia
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by EngineeringFTW View Post
    Create a Matlab program that allows a user to play blackjack (sometimes called "21"). For those of you unfamiliar with the popular casino game, the rules can be found here and on many other websites. Blackjack essentially is a game of chicken between a player and a dealer to see who can get closest to 21 without going over.

    The player may start with a maximum of 1000 chips and the maximum bet per hand is 100 chips.

    There are some special rules that vary from casino to casino. In your Matlab casino, the following rules apply:
    - If you get dealt a "blackjack" you get paid 3-to-2 instead of 1-to-1. If the dealer has a blackjack too you "push" and do not get paid.
    - The dealer hits on a "soft-17" and stays on a "hard-17."
    - You may "split" your cards only once per turn. Once you split your cards, you may play out both hands normally (you may "hit" until you get to 21 or over, "stay" and receive no more cards, or "double down" on the first two cards of each hand)
    - You may "double down" on your first two cards. If you split your hand, you may double down on the first two cards of both hands.
    - You may take "insurance" equal to half the original bet. If you win the insurance bet you get paid 2-to-1.
    - If you dislike your first two cards, you may "surrender" for half your bet and start another hand.

    The user may decide to play against a dealer who deals (1) an infinite deck or (2) a finite number of decks which the user selects (in Vegas, you can find blackjack tables that use 1-8 decks). If the user chooses option (2), reshuffle the decks after 70% of the cards have been used.
    Well:

    Ndeck=6;
    deck=mod(randperm(52*Ndeck),52)+1

    will give you a randomly shuffled of 6 decks

    By the way no one is going to do this for you, you have to do most of it yourself and may be ask more specific questions along the way.


    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    To extend on CB's comment, you will find that the more effort you put into your post the better the resposes will be. Post up some code so we at least know what level you are at and how you are looking to approach the problem. The reason I think that this is so important is that we all have different ways of approaching the same problem. For example, I would not have generated a random list of numbers like CB did, I probably would have gone with a random indexing approach just because thats what I find simplest to picture:

    Code:
    Ndeck=6;
    deck=repmat([1:52],1,Ndeck)
    rand_card_index = round(numel(deck)*rand())
    rand_card = deck(rand_card_index)%get card 
    deck(rand_card) = []%remove card
    Both methods will work, CB's method would probably lead to some tidier code in places but neither is right or wrong. There is no point of us posting up code that isn't going to be of any benefit to yourself.

    Elbarto
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Apr 2010
    Posts
    1
    I built a similar blackjack program just recently with Mathematica and used this place to get all of my info: Play Blackjack Online - Basic Strategy and Free Blackjack

    I would recommend checking out the probability odds charts, the basic rules and stuff like that. They have an excellent card counting guide if you ever get into the advanced math regarding it.

    Hope that helps.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Game Theory: Hotelling game with 3 players
    Posted in the Advanced Applied Math Forum
    Replies: 2
    Last Post: March 26th 2011, 03:08 AM
  2. Matlab DICE GAME ..stressed out
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 20th 2010, 02:21 PM
  3. Mini Blackjack Game
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: December 15th 2009, 01:51 PM
  4. [game theory] Election game
    Posted in the Advanced Math Topics Forum
    Replies: 0
    Last Post: April 22nd 2009, 08:32 AM
  5. Sequential-form game (game tree diagram)
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: October 5th 2008, 07:51 PM

Search Tags


/mathhelpforum @mathhelpforum