SeedRnd(millisecs())

Blitz3D Forums/Blitz3D Programming/SeedRnd(millisecs())

Rook Zimbabwe(Posted 2005) [#1]
OK this is getting really BAD!!! I get the SAME number each time I restart my game. I want RANDOM or at least Psuedo random!!! Can no one fix this???

-RZ


Apocalypse(Posted 2005) [#2]
SeedRnd (Millisecs)


Are you saying that you are seeding the random number generator like this and you still get the same string of numbers?


Erroneouss(Posted 2005) [#3]
0.o Really? Thats....... odd...


big10p(Posted 2005) [#4]
Make sure you put the brackets after Millisecs or will effectively be doing SeedRnd(0), and will get the same numbers every time you run.


Rook Zimbabwe(Posted 2005) [#5]
Look at this: {{{{ CODE EDITED }}}}
; ############################# 
; Board Thingy
;
; If you use something from this a THANK YOU would be nice!
; Rook Zimbabwe aka SSG R. W. Dunn TXSG
; 5 MARCH 2005
; ############################# 
Graphics3D 800,600,32,1
SetBuffer BackBuffer()

SeedRnd=(MilliSecs())

Dim boardarea(11)
Dim boardx(11)
Dim boardy(11)

For fillx = 0 To 10
	;For filly = 0 To 9
	reseed=Rnd(99999)
	SeedRnd(MilliSecs()+reseed)
		colr=Rnd(5)
		boardarea(fillx)=colr
	;Next
Next
While Not KeyHit(1)
Cls
  If KeyDown(57) Then 
		FreeEntity gamePivot		;---------------- added by Blackjumper
    	gamePivot = CreatePivot()	;---------------- added by BlackJumper
		Cls
		For fillx = 0 To 10
			;For filly=0 To 9
				colr=Rnd(5)
				;boardarea(fillx,filly)=colr
				boardarea(fillx)=colr

			;Next
		Next
	EndIf


Text 0,100,"ROW: "+boardarea(0)+boardarea(1)+boardarea(2)+boardarea(3)+boardarea(4)+boardarea(5)+boardarea(6)+boardarea(7)+boardarea(8)+boardarea(9)

Flip

Wend

End 
OK now when I run it I get more random numbers... BUT I HAVE TO RESEED EACH TIME!!!


big10p(Posted 2005) [#6]
Did you read my post? You're not using the brackets with Millisecs so the compiler thinks you're refering to an integer variable called 'millisecs', instead of the function of the same name. ;)

EDIT: Also, don't do 'SeedRnd=(millisecs)' or the compiler thinks you're assigning the value of millisecs variavle to another variable called SeedRnd! 2 Bugs in one line - well done. :P


Rook Zimbabwe(Posted 2005) [#7]
big10p code has been edited... I have to reseed each time before I call a random number or I get the same number. I I take out the seedrnd(millisecs()) before it picks colors I get the same number each time I start the program.

But when I start the program I set seedrnd... correctly... so the initial value should be different each time I start the program.

BUT IT AIN'T!!! :O

The code has been edited... It still runs the same way when you remove the SECOND seedrnd from the
 
        For fillx = 0 To 10
	;For filly = 0 To 9
	;reseed=Rnd(99999)
	;SeedRnd(MilliSecs()+reseed)
		colr=Rnd(5)
		boardarea(fillx)=colr
	;Next
Next
You get the SAME number. Un rem them and new numbers... This is a bug I am sure!
-RZ


Sledge(Posted 2005) [#8]
Read the words that big10p wrote, then go...

; ############################# 
; Board Thingy
;
; If you use something from this a THANK YOU would be nice!
; Rook Zimbabwe aka SSG R. W. Dunn TXSG
; 5 MARCH 2005
; ############################# 
Graphics3D 800,600,32,2
SetBuffer BackBuffer()

SeedRnd MilliSecs()

Dim boardarea(11)
Dim boardx(11)
Dim boardy(11)

For fillx = 0 To 10
	;For filly = 0 To 9
		colr=Rnd(5)
		boardarea(fillx)=colr
	;Next
Next
While Not KeyHit(1)
Cls
  If KeyDown(57) Then 
		FreeEntity gamePivot		;---------------- added by Blackjumper
    	gamePivot = CreatePivot()	;---------------- added by BlackJumper
		Cls
		For fillx = 0 To 10
			;For filly=0 To 9
				colr=Rnd(5)
				;boardarea(fillx,filly)=colr
				boardarea(fillx)=colr

			;Next
		Next
	EndIf


Text 0,100,"ROW: "+boardarea(0)+boardarea(1)+boardarea(2)+boardarea(3)+boardarea(4)+boardarea(5)+boardarea(6)+boardarea(7)+boardarea(8)+boardarea(9)

Flip

Wend

End 



Rook Zimbabwe(Posted 2005) [#9]
That LOUD "thwok" noise you just heard was me slapping myself on the head in frustration of my own stupidity.

Oy!!! Thanks y'all!

-RZ


_PJ_(Posted 2005) [#10]
:-)