Page 3 of 3 FirstFirst 123
Results 31 to 43 of 43
  1. #31
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    "Do you have any thoughts on a better way to cut the shoe?"

    To do this meaningfully would require adding a "before cut" / "after cut" flag on top of the random number sort and recording the change in an additional field in the tables. However, since it would change the sort simultaneously, it would be difficult to be shown as a sequence, so I guess my answer to the question would be "no".



    For the SendKeys: "If it ain't broke, don't fix it."

    Cheers,

  2. #32
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    95
    Thanks. What I have works just fine at a small time sacrifice, so I'm not unhappy. I now have as close to an exact reproduction of the casino as I'm ever going to get, which was my objective. However, I'm sure you're right. It probably makes absolutely no difference between just the straight shuffle and the one I wasted time messing with. But it does satisfy the nerd-monster within that's driving this whole scheme!

    In the words of Cheryl Crow...if it makes you ha-ppy...

  3. #33
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    95
    It's scary how old this thread is. I created the blackjack program using the supplied shuffle routine. It plays perfectly, splitting cards up to four times, valuing aces as or 11 as the case may be, doubling down as required, and calculating wins and losses for bets placed as well as letting me use the betting progression I choose. I was building the analytics that I need to make this more than a game and then just got sidetracked and shelved the whole thing for all these years. My trip to Las Vegas last week where I won $2000 at the blackjack tables over the course of five days renewed my interest pretty quickly!

    I dug out the work I've done to this point, and updated from Access 2003 to 2007, and then I found that my SendKeys routine I was using to cut the cards doesn't work in the later version, so I'm back asking for some creative help. I know, I know. A shuffle is a shuffle, and random is random, so I technically don't need a cut routine, nor do I need to burn the top card as a dealer does, but I just want to make this as realistic as possible, and that includes cut/burn.

    I came up with an idea that I think will work just fine but can't figure out how to implement it. First, I created a simple expression that generates the point at which the shoe should be cut, Int((260-52+1)*Rnd()+52)+1. The cut card has to be inserted leaving at least a full deck top or bottom, so 312-52=260, while 52 is the lower number. The +1 at the end takes one additional card to include the burn card. I can randomly generate a cut point quite easily. I was using it as a TempVar.

    The name of the table used throughout the system for actual play is tblShoe, so I want to redirect the table generating query to make a new table, call it tblShoe1 or anything else. Once the tblShoe1 is generated and I have 312 shuffled cards I was going to use a couple of more queries to accomplish what I wanted. I wanted to use the SELECT TOP expression in a query to select the cards to be cut away from the top of the table and append them to the actual useful table tblShoe. Let's make it easy and say the cut point is 200, so the first 201 (200 + the burn card) are copied from the table and appended to the main table. Then a second query would delete those 201 cards leaving only the bottom 111 cards populating the table tblShoe1. One more append query would move those cards to the bottom of the actual table, tblShoe, and I should have what I need.

    Thinking this out a little more as I'm writing this I realize that if I take the top n from the table and move it to another table, and then take the remaining bottom n and append them to the new table everything remains in the same order that I started with! Grrrr!

    Theoretically there should be a way to do this, but here's the rub. I have to enter a number in the TOP value to make this work. It rejects an expression, like [TempVars]![Cut] or the actual Int((260-52+1)*Rnd()+52)+1. Does anyone know how to get a query to understand a variable for TOP value? Or, barring that, are there any other ideas on how I can accomplish the cut/burn routine that I'd really like to add? I'm probably being totally anal about this but when I get a wild hair it just bugs me until I can finally solve it. If I can get it to understand the expression I'm pretty sure I can find a way to do what I want. Maybe append the top 201 cards to one table, the bottom 111 to another table, and finally appending the bottom records first and the top records second to the working table. It's clunky but it would work.

    I know this has been on the back burner forever, but I'm back at it again and I really want to do things the way the Casino does. All help will be appreciated.

  4. #34
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    95
    BTW, I'm using Win 10, not XP.

  5. #35
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Interesting thread. I am not a casino goer so do not appreciate some of the terminology nor the intricacies.
    But I was curious as to whether or not there was a minimum/maximum number of cards when "cutting the deck". I found this on wikipedia.

    If you have 312 cards in your shuffled "pile", it seems you could get a random number between your minimum and maximum cards in a cut, then use that number for your TOP N, then use your idea of placing the top cut on the bottom and the original bottom on top.

    If the MinCountInCut is X and the MaxCountInCut is Y where X<Y, then your N (the number of cards in the cut) would have X<=N<=Y.

    Here is a randomNumber function I have used, but you may find, or have, something that works better for you.
    Code:
    Function randomNumber(Lo As Long, Hi As Long) As Long
    10       On Error GoTo randomNumber_Error
    
    20    Randomize
    30    randomNumber = Int((Hi - Lo + 1) * Rnd + Lo)
    
    40       On Error GoTo 0
    randomNumber_Exit:
    50       Exit Function
    
    randomNumber_Error:
    
    60        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure randomNumber of Module AccessMonster"
    70        GoTo randomNumber_Exit
               
    End Function
    Here is some sample code re cutting deck of 312 cards where the cut must be 10 cards or greater. This is just a guess at how this could be done. The value would be the N as above.
    Code:
    Sub testrandomCut()
    'simulate cutting a 312 card deck
    'where min cut is 10 and max cut is 302
        Dim DeckSize As Long: DeckSize = 312
        Dim minCountInCut As Long: minCountInCut = 10
        Dim maxCountInCut As Long: maxCountInCut = DeckSize - minCountInCut
        Dim i As Integer
        For i = 1 To 20
            Debug.Print "For cut (" & i & ") N is at card number: " & randomNumber(minCountInCut, maxCountInCut)
        Next i
    End Sub
    Here are 20 random cut values
    Code:
    For cut (1) N is at card number: 161
    For cut (2) N is at card number: 96
    For cut (3) N is at card number: 134
    For cut (4) N is at card number: 80
    For cut (5) N is at card number: 28
    For cut (6) N is at card number: 106
    For cut (7) N is at card number: 165
    For cut (8) N is at card number: 68
    For cut (9) N is at card number: 66
    For cut (10) N is at card number: 287
    For cut (11) N is at card number: 246
    For cut (12) N is at card number: 106
    For cut (13) N is at card number: 155
    For cut (14) N is at card number: 225
    For cut (15) N is at card number: 13
    For cut (16) N is at card number: 124
    For cut (17) N is at card number: 222
    For cut (18) N is at card number: 65
    For cut (19) N is at card number: 166
    For cut (20) N is at card number: 234
    I hope the above is useful.
    Good luck.

  6. #36
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    95
    Thank you. Of course any expounding of thoughts is useful.

    As I mentioned in my post, the casino does not let you cut closer to either end of the shoe than one deck, so the cut must be between 52 and 260 cards out of the 312 in the shoe. When I refer to a "burn" card, the standard procedure after shuffling the shoe and before commencing the deal is to discard the first card. That's the reason I wrote the following expression. Int((260-52+1)*Rnd()+52)+1. It gives me a random number between those two values and the +1 at the end simulates burning the first card (removing it from play).

    I appreciate the work and thought you put into what you did, and perhaps you can answer the following question. Is there an advantage to the code you presented over the Rnd function that I utilized? Obviously Rnd is native within Access and requires nothing more than the simple expression above. Do you think the coded example is just another way to arrive at the same destination, or do you believe the result is more random from what you presented?

    Do you have any ideas on how to use an expression in the TOP n query? Even if your coding was better, it's still an expression to be evaluated rather than a number to insert into the SQL.

  7. #37
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    95
    Try any simple query and insert TOP (9+1) rows. You'll see that expressions are not accepted.

  8. #38
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    95
    Hey, I just thought of something. You know how you can programmatically set a form's properties, like Forms!Play.Locked? Is it possible in the same way to programmatically set a query's properties?

  9. #39
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I have adjusted the sample based on your post.
    Code:
    Sub testrandomCut()
    'simulate cutting a 312 card deck
    'where min cut is 52 and max cut is 260
        Dim sql As String
        Dim sql1 As String
        Dim sql2 As String
    10  sql1 = "Select top "
    20  sql2 = " fldlist from shuffledDeck"      ' need some field(s)  in the  TOP N selection
        Dim Cut As Long
    30  Dim DeckSize As Long: DeckSize = 312
    40  Dim minCountInCut As Long: minCountInCut = 52
    50  Dim maxCountInCut As Long: maxCountInCut = DeckSize - minCountInCut
        Dim i As Integer
    60  For i = 1 To 20
    70      Cut = randomNumber(minCountInCut, maxCountInCut)
    80      sql = sql1 & Cut + 1 & sql2
    90      Debug.Print "For cut (" & i & ") N is at card number: " & Cut & vbCrLf & vbTab & sql
    100 Next i
    End Sub
    I think this respects your 52 card cut and you +1(burn). It also shows how to use the cut value in a simulated SQL.

    Here are 20 random cuts show the cut card and the related SQL.

    Code:
    For cut (1) N is at card number: 77
        Select top 78 fldlist from shuffledDeck
    For cut (2) N is at card number: 260
        Select top 261 fldlist from shuffledDeck
    For cut (3) N is at card number: 117
        Select top 118 fldlist from shuffledDeck
    For cut (4) N is at card number: 225
        Select top 226 fldlist from shuffledDeck
    For cut (5) N is at card number: 222
        Select top 223 fldlist from shuffledDeck
    For cut (6) N is at card number: 140
        Select top 141 fldlist from shuffledDeck
    For cut (7) N is at card number: 99
        Select top 100 fldlist from shuffledDeck
    For cut (8) N is at card number: 110
        Select top 111 fldlist from shuffledDeck
    For cut (9) N is at card number: 77
        Select top 78 fldlist from shuffledDeck
    For cut (10) N is at card number: 177
        Select top 178 fldlist from shuffledDeck
    For cut (11) N is at card number: 238
        Select top 239 fldlist from shuffledDeck
    For cut (12) N is at card number: 153
        Select top 154 fldlist from shuffledDeck
    For cut (13) N is at card number: 145
        Select top 146 fldlist from shuffledDeck
    For cut (14) N is at card number: 72
        Select top 73 fldlist from shuffledDeck
    For cut (15) N is at card number: 205
        Select top 206 fldlist from shuffledDeck
    For cut (16) N is at card number: 79
        Select top 80 fldlist from shuffledDeck
    For cut (17) N is at card number: 249
        Select top 250 fldlist from shuffledDeck
    For cut (18) N is at card number: 212
        Select top 213 fldlist from shuffledDeck
    For cut (19) N is at card number: 212
        Select top 213 fldlist from shuffledDeck
    For cut (20) N is at card number: 254
        Select top 255 fldlist from shuffledDeck
    Rnd is an intrinsic function in Access.
    The Randomize function will reset the seed value for each value. In other words, the function starts with a new random seed value each time Access executes the function.
    Last edited by orange; 03-03-2018 at 12:03 PM. Reason: adjusted the SQL to include "fldlist"

  10. #40
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I have adjusted the sample based on your post.
    Code:
    Sub testrandomCut()
    'simulate cutting a 312 card deck
    'where min cut is 10 and max cut is 302
        Dim sql As String
        Dim sql1 As String
        Dim sql2 As String
    10  sql1 = "Select top "
    20  sql2 = " from shuffledDeck"
        Dim Cut As Long
    30  Dim DeckSize As Long: DeckSize = 312
    40  Dim minCountInCut As Long: minCountInCut = 52
    50  Dim maxCountInCut As Long: maxCountInCut = DeckSize - minCountInCut
        Dim i As Integer
    60  For i = 1 To 20
    70      Cut = randomNumber(minCountInCut, maxCountInCut)
    80      sql = sql1 & Cut + 1 & sql2
    90      Debug.Print "For cut (" & i & ") N is at card number: " & Cut & vbCrLf & vbTab & sql
    100 Next i
    End Sub
    This respects your 52 card cut and you +1(burn). It also shows how to use the cut value in a simulated SQL.

    Here are 20 random cuts show the cut card and the related SQL.

    Code:
    For cut (1) N is at card number: 73
        Select top 74 from shuffledDeck
    For cut (2) N is at card number: 143
        Select top 144 from shuffledDeck
    For cut (3) N is at card number: 129
        Select top 130 from shuffledDeck
    For cut (4) N is at card number: 145
        Select top 146 from shuffledDeck
    For cut (5) N is at card number: 249
        Select top 250 from shuffledDeck
    For cut (6) N is at card number: 146
        Select top 147 from shuffledDeck
    For cut (7) N is at card number: 191
        Select top 192 from shuffledDeck
    For cut (8) N is at card number: 222
        Select top 223 from shuffledDeck
    For cut (9) N is at card number: 87
        Select top 88 from shuffledDeck
    For cut (10) N is at card number: 75
        Select top 76 from shuffledDeck
    For cut (11) N is at card number: 209
        Select top 210 from shuffledDeck
    For cut (12) N is at card number: 88
        Select top 89 from shuffledDeck
    For cut (13) N is at card number: 186
        Select top 187 from shuffledDeck
    For cut (14) N is at card number: 99
        Select top 100 from shuffledDeck
    For cut (15) N is at card number: 83
        Select top 84 from shuffledDeck
    For cut (16) N is at card number: 173
        Select top 174 from shuffledDeck
    For cut (17) N is at card number: 241
        Select top 242 from shuffledDeck
    For cut (18) N is at card number: 92
        Select top 93 from shuffledDeck
    For cut (19) N is at card number: 122
        Select top 123 from shuffledDeck
    For cut (20) N is at card number: 73
        Select top 74 from shuffledDeck
    Also, I did some testing to see how often the cut is at card 52.
    In 2000 iterations the result was
    ********************************got 52 at iteration 90
    ********************************got 52 at iteration 172
    ********************************got 52 at iteration 346
    ********************************got 52 at iteration 383
    ********************************got 52 at iteration 639
    ********************************got 52 at iteration 895
    ********************************got 52 at iteration 1151
    ********************************got 52 at iteration 1407
    ********************************got 52 at iteration 1663
    ********************************got 52 at iteration 1800
    ********************************got 52 at iteration 1834

    I also tried the cut at 260 and
    ********************************got 260 at iteration 68
    ********************************got 260 at iteration 324
    ********************************got 260 at iteration 580

  11. #41
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    question - why do the random numbers need to be between 1 and 312?

    A simple way than might randomise your decks quickly is to create a table with a random PK (as opposed to the default incremental)

    populate that table with the 312 cards, then sort by PK. If you want to assign a 'position in deck' value use dcount or a subquery to count the number of records where the pk is <=to the current pk

    to reshuffle, delete the records and repopulate.

  12. #42
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Ajax,
    I agree. Simplifies things.

    Could also have a table with 312 card slots with and extra field to hold a Random number. Populate the 312 slots using Deck(1-6 ),Suit (1-4), FaceValue(1-13). Populate the random field and sort by its value. Could use the Cut approach to get a Random Value. Then shift the "deck halves" accordingly.
    Could have a button/routine to update the Random field, then sort etc again for reshuffle.
    Sort on random value sample.

  13. #43
    bcmarshall is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    95
    Thank you so much! I was able to use this with just some slight adjustments, but now my tendency towards the absurd has been satisfied. I mean, I know that it doesn't change anything, but I am reproducing the casino experience within my programming to the best of my ability. I appreciate your help.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Credit Card Info, Where?
    By mastromb in forum Access
    Replies: 3
    Last Post: 05-26-2010, 12:37 AM
  2. Import with a wild card
    By ukgooner in forum Import/Export Data
    Replies: 3
    Last Post: 09-09-2009, 08:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums