Cybearg #1 Posted April 18, 2014 In my multicart, I have had issues in the past where the random number generator seems to break between game banks. RevEng, I believe, recommended that I set T1024T=rand before exiting each game. I have been seeding rand in some games with if joy0fire then rand=counter, with counter being a variable that just increments once per frame. A potential issue here is that rand could, in a 1 in 256 chance, be set to 0, which breaks the random number generator and would then push that brokenness into the T1024T and break all random numbers until the 2600 was powered off and on. Furthermore, the same could happen if the rand of T1024T=rand happens to roll a 0. Am I incorrect in this concern? I was reading the documentation for 7800basic (very excited) and noticed this brought up, which reminded me that this was an issue for the 2600 as well. How should I seend rand and T1024T without possibly breaking anything? Quote Share this post Link to post Share on other sites
+RevEng #2 Posted April 19, 2014 When bB starts up it reads in the timer value, binary ORs it with 1, and uses that as the random seed. Because the timer is in a random state during power-up, it's a more or less random value. Your multicart menu had the effect of messing up this scheme, as it allowed the timer to run down to 0 long before the games were selected and started. This is why I suggested you store a rand value in T1024T when exiting the menu into a game, and also when you exited games back to the menu - to keep the rand sequence alive. If you're using a counter to time some human interaction to further seed rand - not a bad idea - you do indeed need to ensure it's not 0 before storing it in rand. Either use an if...then in that case or use "rand = counter | 1". Quote Share this post Link to post Share on other sites
Cybearg #3 Posted April 19, 2014 (edited) If you're using a counter to time some human interaction to further seed rand - not a bad idea - you do indeed need to ensure it's not 0 before storing it in rand. Either use an if...then in that case or use "rand = counter | 1". I'm fairly certain it was your idea, as I highly doubt I would think of something that clever. Noted. The issue is that none of my games have the space to afford even that if statement to ensure no zero is seeded. I'll just need to leave it at rand, then. Edited April 19, 2014 by Cybearg Quote Share this post Link to post Share on other sites
+RevEng #4 Posted April 19, 2014 I may have passed on the idea to you, but I'm pretty sure I read it elsewhere before too. Quote Share this post Link to post Share on other sites