Jump to content
IGNORED

Does reboot ravage rand?


Random Terrain

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...