any function in C or Java (Android) could mess up srand()? -


so have c code calculate results based on number generated srand(). if use same seed number, result same.

now have android app load these c code via jni. however, results become different although same seed number being used. have double checked seed number make sure same. however, since both android program , native code pretty complicated, having hard time figure out causing problem.

what sure is, did not use function in java program generate random numbers. presumably srand() not called different seed number every time. can other functions in java or c change random number generated srand()?

thanks!

update: guess question little confusing. clarify, results comparing same platform, different runs. c code use rand() number calculate result based on that. if seed number of srand() same, number rand() should same , hence results should same. somehow use same seed srand(), rand() give me different number... thought on that?

there many different types of random number generators, , not guaranteed same platform platform. if having cross platform 100% predictable solution necessary project, you'll have write own.

it's not bad may sound...

i'd recommend looking random number generation such mersenne twister algorithm (which use in projects), , write small block of code can share amongst projects. gives benefit of being able have multiple generators varying seeds, comes in useful puzzle game, might want predictably random set based on specific seed generate puzzle, clock seeded generator randomizing special fx or other game elements.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -