ios - Synchronized random numbers -
i have 2 devices, , looking way sync random number generation between them.
more background: 2 devices connect, 1 device sends other file containing data set. data set loaded on both devices. data displayed randomization @ various levels. want display synced between devices, still randomized.
a conceptual example: take stack of pictures. copy of stack sent remote device , stored future use. stacks shuffled same way on both devices drawing first picture on each device result in same output. overly simplified, there far more random numbers required in application optimizations such sharing sort order not applicable...
breaking down: need simple way draw same random number pool on 2 devices. not know how many random draws may occur before devices sync, once synced should predictable draw same number of random numbers since using same data sets, there chance 1 draw more other before proceeding next batch (which require re-sync of random data).
i'm looking avoid having transfer sort orders, position info etc. each entity transferred in data set @ display time (which raises structural concerns since project wasn't designed share info) being able generate same placement, requires random numbers come out in same order.
any thoughts or suggestions appreciated.
you can use lcg algorithm , set same seed generation. because lcg algorithm deterministic, long seed both devices same seed, produce same pseudo-random numbers.
you can find more information on lcg algorithm here:
this lcg used example java.util.random.
Comments
Post a Comment