Hello,
I just downloaded Rand.inc and I wonder if there might be an error inside it.
First of all.. Yes I read the ReadMe.txt :-D
I just used it as
Rand,7
giving me a number between 0 & 6 but it always gave me the same sequence of numbers, even after I used
invoke GetTickCount
invoke Randomize,eax
invoke Rand,7
the same sequence remained all the time :-(
It started working after I replaced following lines
.IF mti==N+1
invoke Randomize,4357
.ENDIF
with
.IF mti==N+1
invoke GetTickCount
invoke Randomize,eax
.ENDIF
inside the Rand proc.
I just wanted to post my findings *g* - Hope this helps somebody out...
I just downloaded Rand.inc and I wonder if there might be an error inside it.
First of all.. Yes I read the ReadMe.txt :-D
I just used it as
Rand,7
giving me a number between 0 & 6 but it always gave me the same sequence of numbers, even after I used
invoke GetTickCount
invoke Randomize,eax
invoke Rand,7
the same sequence remained all the time :-(
It started working after I replaced following lines
.IF mti==N+1
invoke Randomize,4357
.ENDIF
with
.IF mti==N+1
invoke GetTickCount
invoke Randomize,eax
.ENDIF
inside the Rand proc.
I just wanted to post my findings *g* - Hope this helps somebody out...
You might want to check out an impressive random # generator done by Whiz Kid Technomatic http://www.geocities.com/SiliconValley/Heights/7394/wktmrng.zip
The source is ez to understand and beats C's rand() function in terms of randomness by a mile.
If you want something simpler try:
randomize proc uses ecx edx ebx esi edi ebp
INVOKE GetTickCount
mov rand,eax
ret
randomize endp
random PROC uses ecx edx ebx esi edi ebp first:DWORD,second:DWORD
mov ebx,second
sub ebx,first
inc ebx
xor edx,edx
mov eax,rand
div ebx
add rand,eax
add edx,first
mov eax,edx
ret
random ENDP
rand dd ?
put this in a seperate include file and call
invoke randomize
invoke random,1,50
to get a random # from 1 to 50
rds,
grv
The source is ez to understand and beats C's rand() function in terms of randomness by a mile.
If you want something simpler try:
randomize proc uses ecx edx ebx esi edi ebp
INVOKE GetTickCount
mov rand,eax
ret
randomize endp
random PROC uses ecx edx ebx esi edi ebp first:DWORD,second:DWORD
mov ebx,second
sub ebx,first
inc ebx
xor edx,edx
mov eax,rand
div ebx
add rand,eax
add edx,first
mov eax,edx
ret
random ENDP
rand dd ?
put this in a seperate include file and call
invoke randomize
invoke random,1,50
to get a random # from 1 to 50
rds,
grv