Results 1 to 2 of 2

Thread: Making a mini-sim or game [BJ]

  1. #1


    Did you find this post helpful? Yes | No

    Making a mini-sim or game [BJ]

    So I've been writing a miniature simulator the last few days. Nothing fancy, really. It's mostly a "just-for-fun" project, as well as getting better at coding in general.

    1. Ace is 1 or 11. Basically, I have two arrays, dealer[x] and player[y]. Should I go through each element in the array to check if they have an Ace? Or should I have a boolean variable, like dealerHasAce or playerHasAce. If the variable is TRUE, then ace is counted as 11. If it's FALSE, ace is counted as 1 (if it has an ace). ?? Having a boolean variable would mean it doesn't have to go through each element in the array to find if there is or isn't an ace.

    2. Splitting hands. Should I create player2[], player3[], player4[] arrays for this? Or should I have a single, multidimensional array? ie: player[x][y] where X is the number of hands (x = 1 means hand is not split, x = 2 means he has split once, x = 3 means he has split two times for a total of three hands, etc.), then where y is the value of the card? If multiple arrays are created, it'd seem like a sh*tstorm checking if there are any current elements in player2[], player3[], etc. Whereas in a multi-dimensional array, it could all be nested in a double loop (for i = 1 to 4 : for n = 1 to 12 : player[i][n] ...).

    3. Right now, the code has 10's, J, Q, and K cards. Should I just treat all of them as a "10". Instead of saying there are 24 10's, 24 J's, 24 Q's, 24 K's,...just say there are 96 10's? On one hand, it'd make it better so it doesn't have to convert a "J" to a "10" value every time....but on the other hand, it would also allow for things like LL side-bet....although I'm not sure if I ever plan on getting this "to that level" where side-bets and other stuff is included. After all, it's more of a "just for fun" thing to do.

    4. Right now it only uses basic strategy (splitting/doubling/soft-hand not included), but want to include indices in the future. Is there any "good" way of doing this? The only thing I've thought of is doing something like this:

    Code:
    Function playHand()
    
        if NOT handIsAPair Then
             indexPlay(playerTotal, upCard, TC)
        else
              doSomethingElseForDoublingDownOrSplittingOrSomething()
        end if
    End Function
    
    
    Function indexPlay(pTotal, up, count)
    
    
        if pTotal = 12 AND up = 2 Then
            if count > 6 Then
                stay
            else
                hit
            end if
        elseif pTotal = 12 AND up = 3 then
            if count > 3 Then
                stay
            else
                hit
            end if
        elseif pTotal = 12 AND up = 4 Then
            if count > 1 Then
                stay
            else
                hit
            end if
        elseif pTotal = 12 AND up = 5 Then
            if count > -2 Then
                stay
            else
                hit
            end if
        elseif pTotal = 12 AND up = 6 Then
            if count > -5 Then
                stay
            else
                hit
            end if
        elseif pTotal = 12 AND up = 7 Then
            if count > WHATEVER_12_V_7_INDEX_IS Then
                stay
            else
                hit
            end if
        .
        .
        .
        elseif pTotal = 13 AND up = 2 Then
            if count > -2 Then
                stay
            else
                hit
            end if
        elseif pTotal = 13 AND up = 3 Then
            if count > -4 Then
                stay
            else
                hit
            end if
        .
        .
        .
        // and so on...
        end if
    End Function
    Of course, I could make an array or tables or something of the indices, so instead of hard-coding the 12v2 index at +6, I could just call that something like index[1] for 12v2, index[2] could be 12v3, etc...
    "Everyone wants to be rich, but nobody wants to work for it." -Ryan Howard [The Office]

  2. #2


    Did you find this post helpful? Yes | No
    To answer your questions:
    1. Going through each element in the array to check for ace is not such a big performance hit. Each hand on average has only 3 or 4 cards. An Ace is counted as 1 or 11 depends on which makes a better hand. It has nothing to do with whether the player or dealer has an ace. Not sure what you trying to say there.
    2. The player should have a property called hands, which is a list of hands(array if you use array). Each hand then can have a property to indicate whether it's a splitted hand or not.
    3. 10s-Ks are different cards. If you have a Card object, you can assign a value to each card. If you don't use object, then just create a function that will return a value based on what card you pass in the parameter.
    4. Yes, you should load them from a file/table ect. Hardcoding is never good in programming.

    My suggestions would be to do it in an object oriented way. Have a Player object, which contains a list of Hand objects. Each Hand object would contain a list of Card object. Then the Card object can contain properties such as Suit, Rank, and Value, etc.

Similar Threads

  1. HagFan: BJ mini-tournaments at NY,NY / Vegas
    By HagFan in forum Blackjack Main
    Replies: 0
    Last Post: 06-09-2010, 09:51 PM
  2. lilly: visible card before making cut...
    By lilly in forum International Scene
    Replies: 5
    Last Post: 12-17-2006, 02:55 AM
  3. kc: Even $ RoR calculator added to my mini-site
    By kc in forum Computing for Counters
    Replies: 7
    Last Post: 12-20-2005, 03:31 PM
  4. BJ21addict: Bet ramp/ROR/LV mini-report
    By BJ21addict in forum Blackjack Main
    Replies: 4
    Last Post: 02-13-2004, 09:24 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

About Blackjack: The Forum

BJTF is an advantage player site based on the principles of comity. That is, civil and considerate behavior for the mutual benefit of all involved. The goal of advantage play is the legal extraction of funds from gaming establishments by gaining a mathematic advantage and developing the skills required to use that advantage. To maximize our success, it is important to understand that we are all on the same side. Personal conflicts simply get in the way of our goals.