Just a quick reference to what is going on.
If you do not seed the random number generator, math.random will grab the content from it’s seed variable and use it.
If you run your app in the simulator, that seed variable will likely contain whatever data last occupied that memory location and you get the illusion that you’re getting different numbers. When you do this on a device, there is a very good likelyhood that the contents of memory will be zeroed out and thus math.random gets seeded with 0 each time, producing the same sequence of random numbers.
I can’t confirm this, but it’s a reasonable concept.
Therefore if you want to make sure you get different numbers every time, you need to do what Peach said above and use
math.randomseed(os.time())
However, if you want the same sequence of numbers over and over, you need to pass a specific integer value to math.randomseed().
If that does not produce the same sequence over and over, it’s likely a bug. [import]uid: 19626 topic_id: 33108 reply_id: 131767[/import]