[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [DL] Card Dealer



Hopefully not getting repetitive here ...

Yes, the easiest way I've seen by looking at card type
programs in C++ is just to create a 52 item array with
each item defined as a card.  Shuffle the deck by
going through each card position, and SWAP it with a
different card in a different position.  By the time
you get to the end of the deck, all the cards should
be randomized.  Anytime you remove a card from the
array, really do it.  Reduce the array by one size,
and put the card in a hand or discard pile.  When you
need to reshuffle, put all the cards back.

Never messed with VB though.  That being said I looked
through a bunch of VB help websites and found this:
http://www.vb-helper.com/HowTo/cards.zip
which I believe is source for a card shuffling
program.
Something you may want to look at.

-Munch

--- Joel Ashman <joel.ashman@home.com> wrote:
> Derek,
> 
> I once wrote a BlackJack program in VB.  To solve
> the same issue, I did
> this:  The deck was a linked list that could be
> 'shuffled' by randomizing
> the pointers.  Then, once the deck was shuffled X
> times, the deck was pushed
> onto a Stack (First In, Last Out).  The First Card
> drawn was Popped of the
> top of the Stack The Deck), then Pushed onto another
> Stack (The Discard
> Pile).  This way, you simulate drawing from the top
> of the deck.  It's not
> very efficient for memory, but the effect was what
> was important.
> 
> What you probably are doing is randomly picking a
> card from a list of 54
> numbers, where a repeat can occur, unless you track
> the previously drawn
> numbers.  The problem with this is you don't
> accurately simulate the
> function of the deck, and mess up any probabilities
> of getting a particular
> card at certain time.
> 
> Hope this helps.
> 
> --Joel


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text