Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- no no, it's happening to me too! I had to download a different browser to respond and now the textbox just randomly disappears so I'm typing in a word processor then I'll copy paste. don't know what's happening but yea you're not alone, the forum is freaking out
- anyway, yea that exact stackoverflow post is what lead me to ask the question here. specifically the last answer[1] which actually attempts to answer my question, i.e. what if I could guarantee a unique seed every single time
- calling srand(epoch) multiple times is less about making the output of rand any more "random" - I implemented a rejection sampling for my rand to improve bias[2]
- my goal with calling srand(epoch) every x intervals would be to bolster or safeguard an edge case when the clockface calls rand() outside of onUpdate i.e. after a crash (global initialization of a variable) or when onHide is freeing up resources.
- I don't necessarily care that the interval is static or cryptographically unsafe, rand() is manipulated later to fall within a range of 0 -> arr.size()-1. Now I could attempt to tackle your point of making sure the interval between successive srand calls is unpredictable by doing something like this:
- - convert Gregorian.info(Time.now()) into total seconds
- - say we want to reseed every 3.25 hours or 11700 secs
- - if (Gregorian.info(Time.now()) into total secs % 11700) [this is our anchor to ensure the reseed attempt only happens once every 3.25hrs]
- - then rand() a number between let's say 1100-2000
- - if that rand() number == 11700, reseed srand(epoch) [arbitrary condition, subject to change]
- - if not, don't reseed
- so every 3.25hrs generate a range guarded number, if that number falls within a parameter, reseed with a new epoch that is guaranteed to have grown by at least 11,700 seconds. if not, don't, voila!
- theoretically that should take care of the unpredictably of reseeding with epoch no?
- [1]https://stackoverflow.com/a/63597147
- [2]https://stackoverflow.com/a/11758872
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement