approximating a shuffle with excell

sagefr0g

Well-Known Member
Canceler said:
It's always fun to read somebody else's code. The Input Boxes worked fine for me, until k_c commented them out in the latest version of his program. (I'm using Excel 2007, which appears to be version 12.0.)
excel 2007 here also ver 12 for object library what ever that is lol....
 

Kasi

Well-Known Member
k_c said:
What is usually done to generate a different set of data is to make the seed dependent upon the system time so every time data is generated it will be with a different seed.k_c
Actually that's what I ended up doing.

But I still didn't win the lottery.

I'm thinking I should sue them for their lousy RNG that can't even win the lottery for me lol.

I'm sure QFIT has a whole other perspective on the flaws.

But, seriously, I love what you can just whip up and, off-topic here, but I also really liked your comp-dependent program. Not that you care or would be surprised in the slightest but it agreed with every comp-dependent EV I have that someone else like you figured out lol.

I was wondering, regarding that, whether somewhere inside your program it would actually know the W/L/T %'s "behind" the EV's? Maybe an enhancement to consider down the road? Sorry, way off topic now.
 

k_c

Well-Known Member
sagefr0g said:
excel 2007 here also ver 12 for object library what ever that is lol....
It seems to work for Canceler. Often the newer versions are backward compatible with older versions but it may have something to do with choices made when Excel was installed.

Are Macros enabled? On my version of Excel they are enabled from the main Excel screen Tools/Macro/Security. Security can be set to High, Medium, or Low. If it's set to high, Macros can't be run. If it's set to Medium when Excel opens you get a warning that the program contains Macros and you can choose to enable them. If it's set to Low, Macros will always be allowed to run. That doesn't seem like the problem though if you are getting a syntax error.

One other question: Do you have Windows Vista?

k_c
 
Last edited:

sagefr0g

Well-Known Member
k_c said:
It seems to work for Canceler. Often the newer versions are backward compatible with older versions but it may have something to do with choices made when Excel was installed.

Are Macros enabled? On my version of Excel they are enabled from the main Excel screen Tools/Macro/Security. Security can be set to High, Medium, or Low. If it's set to high, Macros can't be run. If it's set to Medium when Excel opens you get a warning that the program contains Macros and you can choose to enable them. If it's set to Low, Macros will always be allowed to run. That doesn't seem like the problem though if you are getting a syntax error.

k_c
yes i have macros enabled. i'm gonna try and do both sets of codes over again tomorrow from scratch after looking at a few things in excell and i'll report back.
 

k_c

Well-Known Member
Kasi said:
Actually that's what I ended up doing.

But I still didn't win the lottery.

I'm thinking I should sue them for their lousy RNG that can't even win the lottery for me lol.

I'm sure QFIT has a whole other perspective on the flaws.

But, seriously, I love what you can just whip up and, off-topic here, but I also really liked your comp-dependent program. Not that you care or would be surprised in the slightest but it agreed with every comp-dependent EV I have that someone else like you figured out lol.

I was wondering, regarding that, whether somewhere inside your program it would actually know the W/L/T %'s "behind" the EV's? Maybe an enhancement to consider down the road? Sorry, way off topic now.
It could be done by 'remembering' the percentage of pushes in a variable for each hand strategy. It would take a lot of space (relatively) to display and use more memory. I guess the percentage of pushes would affect variance. If you push 100% of the time, EV=0 and I guess variance=0 too. If you win 50% and lose 50%, EV=0 and variance is higher. Does that sound right? I'm not much with statistics.

k_c
 

Kasi

Well-Known Member
k_c said:
It could be done by 'remembering' the percentage of pushes in a variable for each hand strategy. It would take a lot of space (relatively) to display and use more memory. I guess the percentage of pushes would affect variance. If you push 100% of the time, EV=0 and I guess variance=0 too. If you win 50% and lose 50%, EV=0 and variance is higher. Does that sound right? I'm not much with statistics.

k_c

Don't give me that "you're not much with statistics stuff" lol. because then I feel really, really bad lol.

One reason I was just wondering is whether having such info would allow one to figure out advantage of being dealt a given 1st card. I mean that can't be figured out just from EV tables can it?
 

k_c

Well-Known Member
Kasi said:
Don't give me that "you're not much with statistics stuff" lol. because then I feel really, really bad lol.
Well I think statistics is based more on abstract definitions as opposed to probabilities which is just the chance of something happening.

One reason I was just wondering is whether having such info would allow one to figure out advantage of being dealt a given 1st card. I mean that can't be figured out just from EV tables can it?
I think the only way to know that outside of advanced techniques would be to know the pre-deal shoe comp.

k_c
 

sagefr0g

Well-Known Member
k_c said:
.......
One other question: Do you have Windows Vista?

k_c
yes i have windows vista :eek:

and i have no option for the ver 9 library.... mine is ver 12
 
Last edited:

sagefr0g

Well-Known Member
QFIT said:
It's not random and degrades after about 30,000 numbers.
i've got cvbj & cvcx. and i guess within that is a sort of demo of cvdata and maybe the shuffle track stuff. but once configured it (forgot how i did it) but i think i'd some how set up the demo part of maybe the ST stuff or cvdata or something. but anyway i was getting on my cvbj the graphic depiction like shown below.
well i was just wondering is if i set my cvbj up like that will that graphic depiction be accurate or perhaps not since i guess it is in demo mode?
 

Attachments

QFIT

Well-Known Member
sagefr0g said:
well i was just wondering is if i set my cvbj up like that will that graphic depiction be accurate or perhaps not since i guess it is in demo mode?
If you're talking about the depiction of the contents of the tray and shoe; yes they are accurate without the shuffle-tracking license. It's just that only the standard shuffle is supported.
 

sagefr0g

Well-Known Member
QFIT said:
If you're talking about the depiction of the contents of the tray and shoe; yes they are accurate without the shuffle-tracking license. It's just that only the standard shuffle is supported.
well heck that's pretty much what i was looking for in the first place lol.
thank you much for the info! :grin:
 

k_c

Well-Known Member
sagefr0g said:
yes i have windows vista :eek:

and i have no option for the ver 9 library.... mine is ver 12
I Googled for possible problems with Vista but couldn't find anything specific. The only thing I can think of is to right click when you open Excel and see if there is the option to run as administrator like there is for an .exe. There are things you can't do in Vista without the right privileges and maybe creating a macro is one of them. I've read that simply being logged on as administrator sometimes isn't enough. You have to have active administrative privileges or something. If that isn't it I don't know what it could be.

k_c
 

sagefr0g

Well-Known Member
k_c said:
I Googled for possible problems with Vista but couldn't find anything specific. The only thing I can think of is to right click when you open Excel and see if there is the option to run as administrator like there is for an .exe. There are things you can't do in Vista without the right privileges and maybe creating a macro is one of them. I've read that simply being logged on as administrator sometimes isn't enough. You have to have active administrative privileges or something. If that isn't it I don't know what it could be.

k_c
well i can definately run macros in excel. but no problem k_c and i much appreciate all your efforts. it'll sooner or later work i know. lol that's how it sometimes goes with computers. but i'll try your suggestions anyway. when i get it working i'll definately let you know.
and heck i got to see the code. that alone is cool. and i learned some more stuff about excel. i always wondered about visual basic and excel and all. so hey it's all good!
 
Last edited:

aslan

Well-Known Member
k_c said:
One way to do it:
So Print TheDeck(n) give you the numerical representation of a card from 1 to 52 that is at position n? Or did you say there should be an output of the entire array to a spreadsheet? That I didn't get, or I don't know how to view it. When I run Print TheDeck(n) I get a single number ostensibly between 1 and 52.
 
Last edited:

k_c

Well-Known Member
aslan said:
So Print TheDeck(n) give you the numerical representation of a card from 1 to 52 that is at position n? Or did you say there should be an output of the entire array to a spreadsheet? That I didn't get, or I don't know how to view it. When I run Print TheDeck(n) I get a single number ostensibly between 1 and 52.
n is used to point to the position in the shuffled deck. TheDeck(0) is the top card. TheDeck(1) is the second card. The Deck(2) is the third card and so on. I just wanted to show what would need to be communicated to the spreadsheet from VBA so I put a Stop statement to break the program at the point the array is defined.

This version outputs the ranks to the spreadsheet in column A without stopping execution, assuming no syntax error. It seemed to work for Canceler, but not Sage. If you want make the program stop as before, just uncomment the 'Stop statement so it reads Stop (without the leading aposostrophe.) You could edit the existing code, but I'll just paste all of it.

Code:
Option Explicit

Global TheDeck() As Integer       'allow for up to 8 decks
Global DeckTot As Integer         'keep track of number of cards in deck
Global TimesToShuffle As Integer  'number of times to shuffle deck

Public Function InitDeck() As Integer
Dim i As Integer
Dim j As Integer

If DeckTot = 0 Then Exit Function

    'place the cards in order in the deck
    For i = 0 To DeckTot - 1
        TheDeck(i) = i
    Next i
    
    'if value of card is higher than 51 then
    'subtract 52 to start a new deck
    For i = 0 To DeckTot
        For j = 1 To DeckTot / 52
            If (TheDeck(i) > 51) Then
                TheDeck(i) = TheDeck(i) - 52
            End If
        Next j
    Next i
    
    'return values
    InitDeck = TheDeck(DeckTot)
    
End Function

Public Sub doInitialize(nDecks As Long)
Dim intNumDecks As Integer
    'initialize number of decks (change this value as needed)
    intNumDecks = CInt(nDecks)
    
        'if programmer is trying to use too many
        'decks let him know now and require an input of 1 to 8
        If intNumDecks > 8 Then
            MsgBox "You are trying to use too many decks", vbOKOnly, "Error"
            Shuffle
        End If
    
    'calculate total number of cards
    DeckTot = intNumDecks * 52
End Sub

Public Function CardShuff(intNumCardsDeck As Integer, intTimesToShuffle As Integer) As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim intHolder As Integer
    
    'randomize
    Randomize Timer
    
    'shuffle cards (intTimesToShuffle) times
    'by picking a two random cards and having
    'them trade places in the deck.
    'loop it through each card in the deck.
     For k = 1 To intTimesToShuffle
        For i = 0 To intNumCardsDeck - 1
            j = Int(Rnd * intNumCardsDeck)
            
            intHolder = TheDeck(i)              'these lines
            TheDeck(i) = TheDeck(j)         'swap the cards
            TheDeck(j) = intHolder          'places
        Next i
    Next k
    
    'return values
    CardShuff = TheDeck(DeckTot)
End Function

Public Sub Shuffle()
    Dim nDecks As Long
    
    nDecks = InputBox("Enter number of decks (1 to 8)", "Number of Decks")
    doInitialize nDecks
    ReDim TheDeck(52 * nDecks)
    DeckTot = CInt(52 * nDecks)
    InitDeck
    TimesToShuffle = InputBox("Input number of times to shuffle", "Number of Shuffles")
    
    TheDeck(DeckTot) = CardShuff(DeckTot, TimesToShuffle)
    
    Dim n As Integer
    Dim rank As Integer
    
    Worksheets("Sheet1").Activate
    Worksheets("Sheet1").Range("A1:A416").ClearContents
    For n = 0 To DeckTot - 1
        If TheDeck(n) < 36 Then
            Worksheets("Sheet1").Cells(n + 1, 1).Value = TheDeck(n) \ 4 + 1
        Else
            Worksheets("Sheet1").Cells(n + 1, 1).Value = 10
        End If
    Next n
    'Stop
    'Let n=(cards-1), where cards=52*decks
    'If cards=1, reference top card
    'If cards=2, reference second card
    'If cards=n, reference nth card
    'At this point TheDeck(n) holds these cards
    'If TheDeck(n)=(0 to 3) the card is an ace
    'If TheDeck(n)=(4 to 7) the card is an two
    'If TheDeck(n)=(8 to 11) the card is an three
    'If TheDeck(n)=(12 to 15) the card is an four
    'If TheDeck(n)=(16 to 19) the card is an five
    'If TheDeck(n)=(20 to 23) the card is an six
    'If TheDeck(n)=(24 to 27) the card is an seven
    'If TheDeck(n)=(28 to 31) the card is an eight
    'If TheDeck(n)=(32 to 35) the card is an nine
    'If TheDeck(n)=(36 to 51) the card is an ten
End Sub
k_c
 

aslan

Well-Known Member
I pressed "continue" after I came to the Stop. Does that do the same thing? There was no spreadsheet printout.
 

Canceler

Well-Known Member
k_c said:
This version outputs the ranks to the spreadsheet in column A without stopping execution
This latest version features the return of the Input Boxes! Worked fine for me.
 

sagefr0g

Well-Known Member
Canceler said:
This latest version features the return of the Input Boxes! Worked fine for me.
Canceler are you running Windows Vista? sounds like we have the same version of excel 2007 ver 12 obj library and all. but i'm running it on Vista and it doesn't work...... so far.
 

Canceler

Well-Known Member
sagefr0g said:
Canceler are you running Windows Vista?
Yes.

Are you absolutely clear on opening the VB Editor, inserting a module, and pasting the code into the module? After you've done that, at the very top of the module it says Option Explicit, and at the bottom there's a bunch of green comments followed by End Sub?

Have a seperate workbook for each version of his program, and only one of them open at a time.

Maybe you could say exactly how it's failing. A screen snip of any error message might be good.
 
Top