I need generate random numbers in my iPhone game. I using rand() function. But it isn't enough random. I tried using srand with time(Null). But my random generator was periodic. /dev/random isn't an answer because I need new random number each 0.1 sec.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- back button text does not change
相关文章
- 现在使用swift开发ios应用好还是swift?
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- why 48 bit seed in util Random class?
- How can I add media attachments to my push notific
- How do you detect key up / key down events from a
You could try random() / srandom() instead. Better generator than rand() / srand().
On iOS and OS X, use arc4random instead. Higher quality randomness, and no need to worry about seeding.
However,
rand()
shouldn't be noticably periodic, unless you're callingsrand
each time around. Or using the random numbers incorrectly.Are you building for debug or on the simulator? I know I ran into this kind of issue when building some windows applications in debug, the RNG was automatically seeded with a constant value to produce consistent results. You may want to check what it is actually seeded with, and if you are getting different outputs at all each run.