|
Joined: May 2011
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: May 2011
Posts: 2 |
Can u maked $rand more more randomized?
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Uh? If you're serious about $rand being not "random enough", please explicate...
|
|
|
|
Joined: Nov 2009
Posts: 81
Babel fish
|
Babel fish
Joined: Nov 2009
Posts: 81 |
This is my think about true random alias true_random {
:random
var %v1 = $1, %v2 = $$2, %random = $r(%v1,%v2), %list = $(,$+(%,random,.,%v1,.,%v2))
if ($istok(%list,%random,32)) goto random
set -eu1337 $+(%,random,.,%v1,.,%v2) $gettok(%list,$+(-,$iif($calc(%v2 / 2) < 64,$int($v1),64),-),32) %random
return %random
} //echo $true_random(1,10) Just mind latests 50% results and never returns it.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
It isn't random if you're controlling it.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: May 2011
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: May 2011
Posts: 2 |
When i using it(in games) i see some regularity in it work. in $read(text.txt) similar problem
|
|
|
|
Joined: Feb 2006
Posts: 546
Fjord artisan
|
Fjord artisan
Joined: Feb 2006
Posts: 546 |
When i using it(in games) i see some regularity in it work. in $read(text.txt) similar problem that's not an explanation, you need to describe the problem in terms of $rand()'s return values.
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
|
|
|
|
Joined: Feb 2003
Posts: 307
Fjord artisan
|
Fjord artisan
Joined: Feb 2003
Posts: 307 |
If i am not mistaken, after rebooting the OS and stating mirc, the first usage of random always returns the same values and so on.
I have seen this in several programing languages.
Voglea's solution seems to bypass this limitation.
Regards
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
I would be surprised if that were true, and Voglea's solution couldn't be more wrong, first because of what Riamus2 said but also because calling $true_random(1,2) three times result in an endless (goto ![sick sick](/images/graemlins/mirc/sick.gif) ) loop
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Think about it this way. Although there isn't a 3 sided dice, for this example, just assume there is. You would expect to have a 1/3 chance of getting any one number on each roll. Every single roll, no matter how many times you roll, you should have a 33% chance of getting a 1, 33% of getting a 2, and 33% of getting a 3. That's random.
With the suggestion here, it blocks the last 1/2 of rolls from appearing again. What that means is that on roll 1, you have a 33% chance of each number. However, on roll 2 and on, you have a 0% chance of one of the numbers and the other two numbers have a 50% chance. That is not random.
Depending on the need of the script, that may be okay. However, if you need something that is truly random, then that is definitely not it. I would never suggest using such a "random" number for anything like dice or anything else that need to have the possibility of getting the same result multiple times in a row. Whether you believe it or not, it is possible to roll the same number on a 6-sided dice 10 times (or more) in a row. The odds are extremely low, but it is possible. That's what it means to be random. Perhaps some seeded random numbers are not as random as they could be, but that depends on how they are seeded. But they are still going to be more random than this.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|