Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

thedollarhunter

macrumors member
Original poster
May 9, 2011
80
0
UK
I am trying out different ways of generating random numbers and want to use a seed derived from something like the position of the last touch or some other human influence.

Any other random tricks or tips would be great.
 
Last edited:
Perfect, just what I was looking for :D

Thanks

link to man page for anyone else looking to compare random() v arc4random()

Just use arc4random(). Problem solved.

If you want to know how or why, google the source for arc4random().


Then read this:
http://stackoverflow.com/questions/4253674/seeding-arc4random-in-iphone-sdk

Just because you want to do something, doesn't mean it's sensible. Naive seeding is more harmful than doing something known to work correctly and is simpler.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.