Search the web
Sign In
New User? Sign Up
testdrivendevelopment · Test-driven Development
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Testing Something that is Random   Message List  
Reply | Forward Message #8192 of 32013 |
Hi

I was justing thinking of TDD a game of black jack and
was wondering how would you test the 'random-ness' of
a shuffle?

From a clean deck of cards any 'change' in order could
be considered a shuffle. But simply moving a the
order of a few cards would not be a good shuffle.

Any thoughts or ideas?

Cheers
Shane

--
Life is pretty simple: You do some stuff. Most fails.
Some works. You do more of what works. If it works
big, others quickly copy it. Then you do something
else. The trick is the doing something else.
Leonardo da Vinci









__________________________________
Do you Yahoo!?
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com



Sun Jan 30, 2005 9:29 pm

shanemingins
Offline Offline
Send Email Send Email

Forward
Message #8192 of 32013 |
Expand Messages Author Sort by Date

Hi I was justing thinking of TDD a game of black jack and was wondering how would you test the 'random-ness' of a shuffle? From a clean deck of cards any...
Shane Mingins
shanemingins
Offline Send Email
Jan 30, 2005
9:29 pm

... I would in general not test randomness much, relying instead on the random number library to be random. Best way I've found to shuffle is to repeatedly...
Ron Jeffries
ronaldejeffries
Offline Send Email
Jan 30, 2005
9:39 pm

If what you are saying is test individual classes/methods with specific known sequences of cards, but have the release version of the system play the game with...
Steven Gordon
sfman2k
Offline Send Email
Jan 30, 2005
10:05 pm

Again, what is wrong with unit testing with a predetermined known sequence to make sure that each class/method is doing exactly what you think they should and...
Steven Gordon
sfman2k
Offline Send Email
Jan 31, 2005
6:21 am

... No I was thinking along the lines of a Deck with a method shuffle. And so if I coded: Deck deck = new Deck(); deck.shuffle(); ...
Shane Mingins
shanemingins
Offline Send Email
Jan 31, 2005
7:02 am

... I'm not really convinced at all that it's necessary to test down to the order. But if I did want to do that, I'd shuffle decks five and six cards and test...
Ron Jeffries
ronaldejeffries
Offline Send Email
Jan 31, 2005
11:36 am

... I think a test at that order is something closer to an acceptance test -- you can't use it to drive the design, because in order to implement it you have...
William Tanksley, Jr
wtanksle
Offline Send Email
Jan 31, 2005
5:16 pm

... What is it that we're trying to design that it can't drive? What's the story? Ron Jeffries www.XProgramming.com Prediction is very difficult, especially if...
Ron Jeffries
ronaldejeffries
Offline Send Email
Jan 31, 2005
5:51 pm

... Seems to me -- and I know you're the expert -- that testing an expected result of this magnitude (five cards have 5! = 120 shuffles) requires preexisting...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 1, 2005
5:30 am

... Not in card shuffling. Anyway, drip under pressure and all that ... I'm just some guy talking about what I'd do. ... I'm not sure what you're envisioning...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 1, 2005
10:59 am

... Okay, you're the expert on TDD :-). Definitely more so than I. ... Sounds like you've already picked out an algorithm (that's not a problem description,...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 1, 2005
4:16 pm

... As a rule, I'd ignore the randomness issue, trusting that I have or can get a random number generator that will be random. I would instead test sequence of...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 1, 2005
8:42 pm

... Good answer. I would definitely use your answer to help me write an overall "integration" test, but I wouldn't use it for a first TDD test or as a final...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 7, 2005
10:15 pm

... Well, you're the randomness expert, I expect. On the other hand, if I were shuffling a deck by random selection from a declining set of cards, I wouldn't...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 8, 2005
3:00 am

Tankersley: "First, it doesn't address a fear I have: I worry that I'm going to make an algorithmic mistake that destroys or degrades the randomness of the...
danilsuits
Offline Send Email
Feb 8, 2005
5:17 pm

... Me either. But I expect that (a) that defect is of very low probability, and (b) if one did code it, the problem would show up in other tests. I'm also...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 8, 2005
6:18 pm

... Ron: "But I expect that (a) that defect is of very low probability" Can you expand on this: what you think it means for a defect to be of very low...
danilsuits
Offline Send Email
Feb 8, 2005
6:30 pm

... By low probability I mean that some types of defects occur often, and some types rarely. This one looks rare to me. I test where the bugs are likely to be,...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 8, 2005
6:51 pm

... Do you mean "how bad does your code have to be to foul up the randomness?" ... That's pretty bad; most library RNGs have very bad lower order bits, so...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 9, 2005
3:47 pm

Restoring the context: Ron: "if I were shuffling a deck by random selection from a declining set of cards, I wouldn't expect to foul up the randomness much." ...
danilsuits
Offline Send Email
Feb 9, 2005
7:41 pm

... This is true, and is both subtle and potentially dangerous (random distributions aren't only used for games!!). I've also seen people accidentally toss a...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 9, 2005
9:02 pm

... Really? What is the effect on a random integer distribution of eliminating all occurrences of integers containing a 1-bit in one given location? ... ...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 9, 2005
9:26 pm

... Obviously, half of the range is removed. In this case, the bit was the high bit, so all the missing events were in the second half of the event range. In...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 9, 2005
11:30 pm

Ron: "Exactly. Your experience is that you have been bitten by RNG issues, so you test more extensively. Mine is that my ***, while full of many bites, has few...
danilsuits
Offline Send Email
Feb 10, 2005
3:20 pm

... Quite possibly true. I've been around the block quite a few times since 1962, so I flatter myself that I have pretty good reflexes regarding where I'm safe...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 10, 2005
3:49 pm

Billy: "the rest of your app's code is tested without the RNG. Completely without it; I don't mean with a mock RNG (no more than you'd trust a test that used a...
danilsuits
Offline Send Email
Feb 10, 2005
12:36 am

... Hmm. Unit tests check the operation of a single class, not of the entire application or algorithm. Right? Well, people who are unit testing applications...
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 13, 2005
5:48 pm

... There's wisdom in that. Unlike some other problems, an RNG use mistake will probably be easy to fix once it's found, although it won't be easy to find. ......
William Tanksley, Jr
wtanksle
Offline Send Email
Feb 9, 2005
3:58 pm

... Yes, me too. Ron Jeffries www.XProgramming.com I must create a system, or be enslaved by another man's; I will not reason and compare; my business is to...
Ron Jeffries
ronaldejeffries
Offline Send Email
Feb 9, 2005
6:20 pm
First  | < Prev  |  Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help