06-11-2008, 05:11 PM
|
#11 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
|
Quote:
Originally Posted by Salathe
I'm not really talking about optimising the code, in the sense of squeezing out that last microsecond of runtime, or saving that extra CPU cycle here and there. My main point was that much of what you wrote appears to have been unnecessary for the functionality of the code. Case in point, the multiple calls to shuffle.
From my understanding (which may be wrong!), shuffling an array multiple times doesn't make the values inside it any more randomly placed than simply shuffling once -- I'd be happy to see any tests done to determine the actual behaviour, if indeed the array is 'more random'. Because of that, I feel that shuffling more than once isn't necessary. Indeed, the entire point of shuffling the array (to randomise the values) is a non-point because the values are selected at random later using mt_rand. What's the advantage of selecting a random value from a shuffled array over selecting a random value from an ordered array? I don't see any, maybe you do.
I'll repeat, I'm not looking to optimise the code for ultimate performance but instead trying to get across the idea of good practises. There's no good point that I can think of (feel free to point any out!) as to why it's a good idea to shuffle the array once, twice, twenty times.
Take out the code block under "shake it around abit" and does the function perform any differently? Are the echoed/returned strings any less random?
|
I got ya ;)
I see what you mean.
It would be best to remove the shuffle() thing.
I guess i just was a happie coder getting a little crazy burning the midnight oil :)
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
|
|
|
|