Alternative Random

By QuickStep on Mar 30, 2005

Read Snippet

/*
One of the hardest mathematical challenges is to create a *perfect* random number.
This is obviously impossible, but it is possible to come very very close.
This here is not an attempt to come close to this, this is just a fun thing. It works just
like the $rand function, so $randa(v1,v2). It isnt really a random function, but any coder could see that, but in some way it can get close.

So again: this is not a *better* $rand function, just for fun
*/
alias randa {
  return $calc($int($calc(($$2 - $$1 + 1) * $calc(($sin($ticks)+1)*0.5))) + $$1)
}

Comments

Sign in to comment.
splatted   -  Apr 02, 2005

Hey, so can someone explain why the normal $rand isn\'t considered random enough? I did hear something about it being predictable, but the details were vague.

 Respond  
Sigh_   -  Apr 01, 2005

Not bad but since the only variable quantity here is $ticks, doing //echo -a $randa(1,10) $randa(1,10) $randa(1,10) will always yield the same random numbers

 Respond  
DarthReven   -  Mar 30, 2005

very nice i like the idea

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.