Advertisement
Guest User

Untitled

a guest
Oct 30th, 2024
61
0
105 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. 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
  2.  
  3. 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
  4.  
  5. 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]
  6.  
  7. 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.
  8.  
  9. 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:
  10.  
  11. - convert Gregorian.info(Time.now()) into total seconds
  12.  
  13. - say we want to reseed every 3.25 hours or 11700 secs
  14.  
  15. - if (Gregorian.info(Time.now()) into total secs % 11700) [this is our anchor to ensure the reseed attempt only happens once every 3.25hrs]
  16.  
  17. - then rand() a number between let's say 1100-2000
  18.  
  19. - if that rand() number == 11700, reseed srand(epoch) [arbitrary condition, subject to change]
  20.  
  21. - if not, don't reseed
  22.  
  23. 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!
  24.  
  25. theoretically that should take care of the unpredictably of reseeding with epoch no?
  26.  
  27. [1]https://stackoverflow.com/a/63597147
  28.  
  29. [2]https://stackoverflow.com/a/11758872
  30.  
  31.  
Tags: garmin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement