# Simple random Number

### By anthalus on Apr 11, 2006

Just a random number generator that attempts to bypass the steady-state of a computer. It can be used for other scripts if you follow the directions in this script.

[update] Fixed a small error that I should have caught earlier

``````/* This script produces random numbers of a length that the user sets. The final number can be used in other scripts by changing
the var %rand to set %rand
*/

alias rand {
var %leng = \$\$?="Number of places?"
:check
var %rand = \$rand(0,9)
var %rand = \$str(%rand,4)
var %rand = \$calc(\$int(\$asin(\$rand(1,%rand))))
var %rand = \$calc((%rand * %leng) * (%rand * \$rand(1,9)))
if (\$len(%rand) < %leng) {
goto check
}
var %rand = \$right(%rand,%leng)
; change var to set %rand when used for other scripts
.echo The Random Number is %rand
}
``````

anthalus   -  Apr 24, 2006

I agree that the scoring system needs a total overhaul. I think for some just the definitions of the numbers is the problem, as they are quite vague.

As for the script, yeah it could be a bit neater, but this one was done on the fly, and I have never been one to really like using multistep variable definitions because it is easier to get lost that way.

Surely I could have done something like:

%a = \$rand(0,9), %b = \$str(%a,4), %c = \$calc(\$int(\$asin(\$rand(1,%b))))
and so on and so on....

LIQUID_NiTrO   -  Apr 22, 2006

I suppose you decide that for yourself, based on the overall, all-inclusive quality of the script.
I personally think it should be scored based solely on function. If it works well and is practical, it gets a good score. If the coding could be neater, that\'s something to talk about in a comment, but I don\'t think it should affect the snippet\'s score.
The only exception is if the code is really ugly and the snippet is made to be modified for a person\'s own purposes. Then it SHOULD be judged on neatness and efficiency of the code.

sean   -  Apr 22, 2006

pretty useful but here\'s the thing, what exactally does the score represent? the use of the script or the sleakness in design. that\'s one thing that\'s always confused me about this place. there\'s alot of damn good snippets here but recieved low scores because of various reasons.

this snippet is useful but could be coded much better. so what should the score be??

LIQUID_NiTrO   -  Apr 22, 2006

Pretty useful in my opinion. I think this snippet is under rated.

Doomraider   -  Apr 19, 2006

well of course true random numbers dont exist ;P

anthalus   -  Apr 13, 2006

But, it does not take into account the fact that your computer computes \$rand based on its current state. With the speed of calculations that it can do, \$rand is not truly random.

(7+4+5+5+7)/5=5.6

UK-Sw1ft   -  Apr 11, 2006

alias crand {
if \$1 !isnum { return \$false }
var %i = 1,%b = \$1,%c = 9, %r
while %i <= %b {