Click here to Skip to main content
15,914,905 members
Home / Discussions / C#
   

C#

 
AnswerRe: Drawing cards from a deck Pin
CPallini15-Jan-09 2:41
mveCPallini15-Jan-09 2:41 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:01
Tony Pottier15-Jan-09 4:01 
AnswerRe: Drawing cards from a deck Pin
benjymous15-Jan-09 2:50
benjymous15-Jan-09 2:50 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:03
Tony Pottier15-Jan-09 4:03 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 4:16
Tony Pottier15-Jan-09 4:16 
GeneralRe: Drawing cards from a deck Pin
benjymous15-Jan-09 4:55
benjymous15-Jan-09 4:55 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 5:56
Guffa15-Jan-09 5:56 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 5:38
sitebuilderLuc Pattyn15-Jan-09 5:38 
Hi,

the strategy of putting all candidates in a collection, and extracting from there as many as you need in a random way, is correct. However, if you only want to extract a small fraction, it may be more economical to forget the collection, and just try 5 random numbers; whenever one is chosen that has been picked already, just throw the dice again. For 5 out of 52 that will occur in some 10% of the cases.

If on the other hand, you decide to stick with the collection, there is no real need to build it over and over; once done, you can add the chosen items back to the collection. That would change the order, but then you could sort the collection (not sure that would be faster than recreating it), or you could ignore the issue, just relying on the randomness of the picking process. Strict randomness would mean the outcome does not depend on the previous outcome, so all candidates have the same probability, no matter where they are in the collection.

Of course, if you are creating the perfect poker playing app, and are gambling your fortune, you may want to make sure, and follow the official ways...

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles]

I use ListBoxes for line-oriented text (not TextBoxes), and PictureBoxes for pictures (not drawings).


modified on Friday, June 10, 2011 12:23 PM

GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 6:32
Guffa15-Jan-09 6:32 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 6:40
Tony Pottier15-Jan-09 6:40 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 6:42
sitebuilderLuc Pattyn15-Jan-09 6:42 
GeneralRe: Drawing cards from a deck Pin
Guffa15-Jan-09 6:55
Guffa15-Jan-09 6:55 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 6:59
sitebuilderLuc Pattyn15-Jan-09 6:59 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 7:27
Tony Pottier15-Jan-09 7:27 
AnswerRe: Drawing cards from a deck [modified] Pin
Luc Pattyn15-Jan-09 7:31
sitebuilderLuc Pattyn15-Jan-09 7:31 
AnswerRe: Drawing cards from a deck Pin
Henry Minute15-Jan-09 12:34
Henry Minute15-Jan-09 12:34 
GeneralRe: Drawing cards from a deck Pin
Tony Pottier15-Jan-09 12:42
Tony Pottier15-Jan-09 12:42 
QuestionWildcards Pin
boiDev15-Jan-09 2:15
boiDev15-Jan-09 2:15 
AnswerRe: Wildcards Pin
SeMartens15-Jan-09 2:24
SeMartens15-Jan-09 2:24 
AnswerRe: Wildcards [modified] PinPopular
EliottA15-Jan-09 2:52
EliottA15-Jan-09 2:52 
GeneralRe: Jerkface Pin
EliottA15-Jan-09 3:09
EliottA15-Jan-09 3:09 
GeneralRe: Jerkface Pin
DaveyM6915-Jan-09 3:30
professionalDaveyM6915-Jan-09 3:30 
GeneralRe: Jerkface Pin
EliottA15-Jan-09 3:36
EliottA15-Jan-09 3:36 
GeneralRe: Jerkface Pin
DaveyM6915-Jan-09 3:40
professionalDaveyM6915-Jan-09 3:40 
GeneralRe: Jerkface Pin
Pete O'Hanlon15-Jan-09 3:47
mvePete O'Hanlon15-Jan-09 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.