Jump to content



2

Does reboot ravage rand?


6 replies to this topic

#1 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,911 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue Sep 30, 2008 3:53 AM

With or without "dim rand16=z" if I use reboot instead of just jumping back to a label, rand no longer seems to be random. I noticed this when randomly placing playfield pixels on the screen. If I jump back to a label when the reset button is pressed, the playfield pixels are always random, but if I use reboot when the reset button is pressed, I get the same configuration of playfield pixels every time.

I'm using Stella 2.51 in case that matters.

Edited by Random Terrain, Tue Sep 30, 2008 3:56 AM.


#2 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Tue Sep 30, 2008 5:03 AM

Does bB seed RAND by pulling something like INTIM during powerup? If so, this behaviour makes sense.

I suggest jumping to a variable initialization routine rather than rebooting.

#3 Random Terrain ONLINE  

Random Terrain

    Visual batari Basic User

  • 20,911 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Tue Sep 30, 2008 5:16 AM

View PostNukey Shay, on Tue Sep 30, 2008 6:03 AM, said:

Does bB seed RAND by pulling something like INTIM during powerup? If so, this behaviour makes sense.

I suggest jumping to a variable initialization routine rather than rebooting.
I'm just a lowly bB user with a tiny brain. I don't know what bB does. The explanation will have to come from someone with a bigger brain. Whatever the explanation is, it looks like I'll have to avoid reboot. It's fairly 'new' and I never had a chance to become addicted to it, so no big deal if I can't use it.

Thanks.

#4 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Tue Sep 30, 2008 6:07 AM

View PostRandom Terrain, on Tue Sep 30, 2008 7:16 AM, said:

View PostNukey Shay, on Tue Sep 30, 2008 6:03 AM, said:

Does bB seed RAND by pulling something like INTIM during powerup? If so, this behaviour makes sense.

I suggest jumping to a variable initialization routine rather than rebooting.
I'm just a lowly bB user with a tiny brain. I don't know what bB does. The explanation will have to come from someone with a bigger brain. Whatever the explanation is, it looks like I'll have to avoid reboot. It's fairly 'new' and I never had a chance to become addicted to it, so no big deal if I can't use it.

Thanks.
Yes, bB seeds rand with the value of INTIM (after ORAing it with #1 to make sure rand won't be 0). So if reboot is always performed at the same time (in terms of the overall kernel loop), then INTIM will probably have the same value each time.

You could try varying the time with something like the following:

   if switchreset then temp1 = rand : for temp2 = 1 to temp1 : next : reboot
I haven't tried that myself to see how well it works, but it should cause the reboot command to be performed at different times each time the user presses reset.

Michael

#5 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Tue Sep 30, 2008 6:42 AM

Yeah, I had the same problems also. My game picked two random numbers to make a hole in a "wall" and each time they were coming in the same places.

#6 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Tue Sep 30, 2008 7:22 AM

Another strike against rebooting is that display loses sync (so it would jitter on the next frame). You could probably store the current random seed to TIM64T (or one of it's cousins) before rebooting to keep the seed from being identical, tho. Maybe EOR it with some variable like a framecounter to lower the odds even more.

#7 potatohead OFFLINE  

potatohead

    River Patroller

  • 3,655 posts
  • Location:Portland, Oregon

Posted Tue Sep 30, 2008 8:25 AM

Can you take some player input at that time for a new seed?

If you make them do something, while incrementing a counter or something, then their actions will trigger some low level of randomness in that they are not all that likely to do it exactly the same time every time.

Kind of a "press fire, then up, then down to continue" kind of thing.

Edited by potatohead, Tue Sep 30, 2008 8:28 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users