SeedRnd(millisecs())
Blitz3D Forums/Blitz3D Programming/SeedRnd(millisecs())
| ||
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 |
| ||
SeedRnd (Millisecs) Are you saying that you are seeding the random number generator like this and you still get the same string of numbers? |
| ||
0.o Really? Thats....... odd... |
| ||
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. |
| ||
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 EndOK now when I run it I get more random numbers... BUT I HAVE TO RESEED EACH TIME!!! |
| ||
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 |
| ||
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 NextYou get the SAME number. Un rem them and new numbers... This is a bug I am sure! -RZ |
| ||
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 |
| ||
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 |
| ||
:-) |