mIRC Homepage

$random

Posted By: ooodo

$random - 06/05/11 11:23 PM

Can u maked $rand more more randomized?
Posted By: Horstl

Re: $random - 06/05/11 11:38 PM

Uh?
If you're serious about $rand being not "random enough", please explicate...
Posted By: Voglea

Re: $random - 07/05/11 01:53 AM

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.
Posted By: Riamus2

Re: $random - 07/05/11 02:05 AM

It isn't random if you're controlling it.
Posted By: ooodo

Re: $random - 07/05/11 07:05 AM

When i using it(in games) i see some regularity in it work. in $read(text.txt) similar problem
Posted By: jaytea

Re: $random - 07/05/11 08:26 AM

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.
Posted By: tontito

Re: $random - 14/05/11 11:05 PM

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
Posted By: Wims

Re: $random - 14/05/11 11:40 PM

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
Posted By: Riamus2

Re: $random - 15/05/11 12:50 AM

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.
© 2021 mIRC Discussion Forums