Skip to search.
testdrivendevelopment · Test-driven Development

Group Information

  • Members: 3501
  • Category: Software
  • Founded: Feb 7, 2002
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

  Messages Help
Advanced
Randomness revisited   Message List  
Reply Message #8555 of 34997 |
I know we recently had a thread dealing with randomness (shuffling a deck).
The consensus seemed to be to sweep that issue under the rug and try to
test around it.

What if randomness is an integral part of your code? For example, say that
you want to play a sound from a set at random when a certain event happens.
Take it further and say that the user can select the different sounds and
the probability of each sound being played. How do you use TDD for
something like that?

Sure, you can test that when I set the probability to 1 and another to 0,
the sound with probability 1 gets played. But how do I test the situation
where I have two sounds one with probability 0.8 and the other one 0.2? I
would really prefer not to call the event X times and get a sampling that
way, but right now it's the best idea I can think of.

Any better ideas?


--Noel
Games from Within
http://www.gamesfromwithin.com



Tue Feb 22, 2005 5:13 am

nllopis
Offline Offline
Send Email Send Email

Message #8555 of 34997 |
Expand Messages Author Sort by Date

I know we recently had a thread dealing with randomness (shuffling a deck). The consensus seemed to be to sweep that issue under the rug and try to test around...
Noel Llopis
nllopis Offline Send Email
Feb 22, 2005
5:13 am

... If I had an RNG that I trusted, I'd roll 0 <= x < 1 and select based on x < 20, and would be unlikely to test that further, other than perhaps once by...
Ron Jeffries
ronaldejeffries Offline Send Email
Feb 22, 2005
5:49 am

... Well, my eyeball says I meant x < 0.20 ... :) Ron Jeffries www.XProgramming.com There is economic value in manufacturing identical wheels. There is no ...
Ron Jeffries
ronaldejeffries Offline Send Email
Feb 22, 2005
6:04 am

I think I would go a different way... I'd possibly write a test for the RNG, testing that it produces random results, if necessary, or use someone else's RNG...
Michael Brunton-Spall
michael.brunton-spall... Send Email
Feb 22, 2005
11:00 am

... At first reaction, I like that. Ron Jeffries www.XProgramming.com It is not the strongest of the species that survive, not the most intelligent, but the...
Ron Jeffries
ronaldejeffries Offline Send Email
Feb 22, 2005
11:13 am

... could ... For example: (0, 1, 2, 3, 4, 5, ...) -- Phlip http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces...
Phlip
phlipcpp Offline Send Email
Feb 23, 2005
2:37 pm

... deck). ... happens. ... One TDDs generic randomness by replacing rand() with a mock object. In this case, if you only need a certain level of...
Phlip
phlipcpp Offline Send Email
Feb 23, 2005
2:41 pm

Phlip: "One TDDs generic randomness by replacing rand() with a mock object." What test did you write that drove you to introduce rand() in the first place? I...
danilsuits Offline Send Email Feb 23, 2005
5:45 pm

... Uh, little secret: Sometimes in TDD you write half the test, then write a little code, then finish the test. Sometimes. The goal is staying in absolute...
Phlip
phlipcpp Offline Send Email
Feb 23, 2005
6:10 pm

That's a perfectly valid random sequence. As is 0,1,3,2,4,5.. And so on. The same as you just as likely to win with a Lottery ticket with the numbers...
Michael Brunton-Spall
michael.brunton-spall... Send Email
Feb 23, 2005
2:44 pm

... You flip a coin and get heads 5 times. What are the odds of the 6th flip turning up heads? The odds of having a bomb on board your plane are a billion to...
Phlip
phlipcpp Offline Send Email
Feb 23, 2005
2:56 pm

The odds of a 6th flip turning up heads is 1 in 2. The odds of a single flip is 50% heads, 50% tails (obviously that's not actually true, odds vary depending...
Michael Brunton-Spall
michael.brunton-spall... Send Email
Feb 23, 2005
3:15 pm

It's bad enough we're still on this subject; don't get us off onto the Let's Make a Deal thread now, too! :-p - Brad...
Brad Wilson
bradw_64 Offline Send Email
Feb 23, 2005
3:45 pm

... I got you to say "flip" 9 times. ;-) -- Phlip http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces...
Phlip
phlipcpp Offline Send Email
Feb 23, 2005
3:36 pm

Yeh sorry. I've got Thursday and Friday off to go to London, so it's almost like Friday afternoon for me at the moment :) Thanks for the name of the show I...
Michael Brunton-Spall
michael.brunton-spall... Send Email
Feb 23, 2005
3:52 pm

... (snip) ... What are the odds of that? (sorry, I couldn't resist) Doug...
Seelinger, Douglas Mr.
dougseelinger Offline Send Email
Feb 24, 2005
12:08 am

... Because I was bored, I wrote a little JUnit test for java.util.Random. I cheated a little, instead of 2/10, I used 1/5. It took me 16 minutes to write the...
Gary Brown
gb70840 Offline Send Email
Feb 22, 2005
6:20 am

... Nods! Here is an article deals a bit with that subject. "Randomness without Replacement" http://www.gamedev.net/reference/design/features/randomness/ ...
msew@...
msewmsew Offline Send Email
Feb 24, 2005
3:41 pm

... Sorta, yes. Not sweep the issue under the rug, but rather isolate the randomness and test all the deterministic components. ... The shuffling example was...
William Tanksley, Jr
wtanksle Offline Send Email
Feb 22, 2005
3:50 pm

... I don't think you can TDD a better RNG by testing for randomness. I think you'd do better to hire a mathemetician and TDD conformance to the algorithm. If...
George Dinwiddie
gdinwiddie Offline Send Email
Feb 23, 2005
3:43 am

As far as randomness goes, you can't test for it - it's not a well-defined concept (I remember spending a whole semester in grad school proving that nomatter...
Dan Rawsthorne
drawstho Offline Send Email
Feb 23, 2005
4:31 am

... "Anyone who considers arithmetical methods of random digits is, of course, in a state of sin." -- John von Neumann (quoted in Knuth, Vol.2) Knuth's...
Jim Frohnhofer
fijimf Offline Send Email
Feb 23, 2005
6:53 am

... I have to point out that this is a straw man. In cases where some sort of provable randomness is needed, e.g. for cryptographic algorithms, you come up...
Gary F
gfyho Offline Send Email
Feb 23, 2005
1:53 pm

... No, but you can *measure* certain aspects to compare the quality of different random sequences. Basically, as I recall, it comes down to checking it in...
George Dinwiddie
gdinwiddie Offline Send Email
Feb 24, 2005
12:37 am

... "Did you listen to a word I said?" "You said 'flip'! Hur, Hur, Hur, <snigger>" (Sorry, I recently watched some of "100 greatest cartoons", which showed a ...
Anthony Williams
anthony_w.geo Offline Send Email
Mar 1, 2005
11:07 am
Advanced

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