artrag Posted December 7, 2019 Share Posted December 7, 2019 Hi, is it possible in INTYBASIC to set a seed in the random number generator? I would like to generate a repeatable sequence of random numbers, but RND and RANDOM seem to have no initialization Quote Link to comment Share on other sites More sharing options...
intvnut Posted December 7, 2019 Share Posted December 7, 2019 (edited) I'm pretty sure the IntyBASIC random number generator isn't meant to be repeatable. It has a _next_random function that gets called in the interrupt service routine to advance the random generator. If you want a repeatable, replayable random number generator that runs from solely a seed and produces the exact same random numbers every time from that seed, you'll have to code one directly, I think. LFSRs are cheap both in execution time and storage. If you have some RAM to spare, a lagged-Fibonacci generator is also cheap, but requires RAM for the state. And, of course, you need to expand the seed to initialize the lagged-Fibonacci history buffer. I'm guessing you don't want the xkcd approach: And then there's the Doom approach. Edited December 7, 2019 by intvnut clarification 1 Quote Link to comment Share on other sites More sharing options...
artrag Posted December 7, 2019 Author Share Posted December 7, 2019 I love the doom approach... Quote Link to comment Share on other sites More sharing options...
+Lathe26 Posted December 7, 2019 Share Posted December 7, 2019 Technically, the XKCD approach is the same as the Doom approach but the table only has 1 element. Just saying... 2 Quote Link to comment Share on other sites More sharing options...
intvnut Posted December 7, 2019 Share Posted December 7, 2019 2 hours ago, Lathe26 said: Technically, the XKCD approach is the same as the Doom approach but the table only has 1 element. Just saying... 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.