Question 6 Deck Card Shuffling In Access

bcmarshall

Member
Joined
Jul 17, 2010
Messages
7
Programming Experience
5-10
I'm doing something not generally associated with Access. I'm writing an analytical blackjack program. Anyone familiar with Access knows that it can be instructed to do the things involved, namely count the hand, stand or hit at a certain level, and anything else required to play the game. In fact, the game is already written and plays perfectly. My problem is that I've been unable to come up with a practical and fast shuffling routine, but I have special requirements.

I want the shuffled decks stored in a table for several reasons. I want to be able to compare two moves, say standing vs. hitting a 16 v 10. The only way that's possible is to be able to see what the next card would have been and then making a comparison of the results. Another reason is to be able to save really good or really poor decks so that they can be collected and strategies can be developed which are optimized to bad or good runs of cards.

Can anyone offer a means of shuffling 6 decks and storing the results in a table? I have been able to do it, but the wait is interminable, and I know there are much better ways out there. I just can't think of any!

Thanks for your help.
 
6 Deck Card Shuffling in Access

Wow, that is simple! Is it possible to generate a number that corresponds to a particular shuffle so that I can store the number rather than the entire shuffled deck?
 
Would you mind explaining this a little more? What is randCards? Is that a table name? sixdeck is that a control name, and if so should it be enclosed in square brackets? the <some_numeric_field> notation...can that simply be a number like 312?
 
Erm. I'm not sure if it's possible to reset the random number generator in Access so, for any given key, it always produces the same sequence of random numbers (thus you just store the seed number rrather than the entire sequence) so I'd advocate simply giving the sequence a number and storing the full sequence.. We're only talking 312 records anyway

randCards is a table
sixDeck is a table of all the cards which could possibly be represented by just 2 characters in the "face" column: AH, 1H, 2H.. 9H, 0H, JH, QH, KH.. six times (312 cards)

"control name" - are you actually developing this in Access? Note that these are forums for visual basic.net programming language, not Access. This forum is for discussion of the Jet database engine, better known to people as "Access" because that's the name of the tool Microsoft provide to manipulate those databases.. This forum isnt for help with Access itself, as a program so it's kinda inappropriately named, but noone knows what Jet is..

No, the <some_numeric_field> cannot be a constant number because for reasons of efficiency Jet will only run Rnd() once thus you'll get 837698723645.84357 or whatever for your Rnd() result for all rows. Read the link I sent. You have to Run RND on something that changes every row, so that Jet pulls a random number for every row
 
6 Deck Card Shuffling in Access

Thank you for the links and the time you spent composing a reply.

I know it is possible to save the 312 cards as a single, 624 character string when two characters are assigned to every card. 2S9DJC is an example of how that could be accomplished. I'm wondering whether that is the only or best way, and that's the reason for the question.

So you understand my reasoning, I want to use shoes as a control in some of my experiments, for example making a play one way, and then going back and rerunning exactly the same cards and playing a different way and comparing the results.

Ultimately I'm looking for some simple way to represent that shoe of cards as one string instead of 312 records and convert back and forth. Storing ten shoes gives me 3120 records, and I could easily get to tens of thousands of records. It seems at least 312 times more efficient to store a shoe as a single number if possible.
 
I understand your complaint, though I wouldnt worry about it too much; even a lowly database like access should be able to store millions of records like this, in 3 columns:

shoenumber, sequence, card
1, 1, AS
1, 2, KC
...

but storing it as a single column of 624 characters would be possible.. Text in access is limited to 255 though a memo field should be fine, and not too slow.. I'd probably sue SQLServer instead..
 
I'm more interested in efficiency than beauty. I really don't care if I have a million cards stored in a table as long as I can access them at will and use them the way I would like to for analysis. Of course, it would be nice to minimize the storage requirements which is why I'm toying with the idea of a single string, but I don't see it as critical at all. If I were to use the single string concept, what would be the most efficient way to change 312 table records to the string, and then return the string to 312 table records?
 
That's an excellent resource. Thanks.

I think your advice is ultimately the most logical approach. "...you should probably store and use them in the format that the front end most readily consumes..."

That would simply mean storing shoes as individual records. There is probably not that much, if any, economy of storage through concatenation, and even if it's not much trouble for Access to accomplish, it's extra work for me which really doesn't net me any advantage. That's the tipping point on the balance scale of practicality in my mind.

Believe it or not this has been extremely helpful to me even if I'm sort of back where I started. I've been through the process of exploring unfamiliar territory, and in the end it seems that where I started is probably the best place to stay.

I posted the original question on several different forums, and someone actually put your SQL sequence together into a routine which is extremely fast. It's available for your review here. CardShuffle.mdb

For now it seems my immediate problems are manageable, but I hope you'll remain available to answer other questions as they arise. I really do appreciate the thought, time, and effort you put into this.
 

Latest posts

Back
Top