mIRC Home    About    Download    Register    News    Help

Print Thread
#231843 06/05/11 11:23 PM
Joined: May 2011
Posts: 2
O
ooodo Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
O
Joined: May 2011
Posts: 2
Can u maked $rand more more randomized?

ooodo #231844 06/05/11 11:38 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Uh?
If you're serious about $rand being not "random enough", please explicate...

ooodo #231845 07/05/11 01:53 AM
Joined: Nov 2009
Posts: 81
V
Babel fish
Offline
Babel fish
V
Joined: Nov 2009
Posts: 81
This is my think about true random

Code:
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.

Voglea #231846 07/05/11 02:05 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It isn't random if you're controlling it.


Invision Support
#Invision on irc.irchighway.net
ooodo #231849 07/05/11 07:05 AM
Joined: May 2011
Posts: 2
O
ooodo Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
O
Joined: May 2011
Posts: 2
When i using it(in games) i see some regularity in it work. in $read(text.txt) similar problem

ooodo #231850 07/05/11 08:26 AM
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: ooodo
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
jaytea #232031 14/05/11 11:05 PM
Joined: Feb 2003
Posts: 307
T
Fjord artisan
Offline
Fjord artisan
T
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

tontito #232032 14/05/11 11:40 PM
Joined: Jul 2006
Posts: 4,185
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,185
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) loop


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
tontito #232034 15/05/11 12:50 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
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

Link Copied to Clipboard