Let me describe the system. There are several mobile devices, each independent from each other, and they are generating content for the same record id.
I want to avoid generating the same content for the same record on different devices, for this I though I would use a random and make it so too cluster the content pool based on these randoms.
Suppose you have choices from 1 to 100.
Day 1
- Device#1 will choose for the record#33 between 1-10
- Device#2 will choose for the record#33 between 40-50
- Device#3 will choose for the record#33 between 50-60
- Device#1 will choose for the record#55 between 40-50
- Device#2 will choose for the record#55 between 1-10
-
Device#3 will choose for the record#55 between 10-20
-
Device#1 will choose for the record#11 between 1-10
- Device#2 will choose for the record#22 between 1-10
- Device#3 will choose for the record#99 between 1-10
Day 2
- Device#1 will choose for the record#33 between 90-100
- Device#2 will choose for the record#33 between 1-10
- Device#3 will choose for the record#33 between 50-60
They don’t have access to a central server.
Data available for each of them:
- IMEI (unique per mobile)
- Date of today (same on all devices)
- Record id (same on all devices)
What do you think, how is it possible?
ps. tags can be edited
I agree with AakashM and Frustrated. First can you guarantee that the number of devices is greater than the range of generated data? In fact to be “Random” you really need to have twice the generated content as devices, otherwise at least one device will have to “randomly choose” between one choice. That stated since the IMEI is the only unique data based on the device you will have to use that in your algorithm. The other problem (I suspect) is that the device IDs are not necessarily evenly distributed so any potential mapping of a device ID to a data block would potentially lead to overlap (unless you have a very large range of data to select from) or the values generated would not be evenly distributed across the pool of devices.
That said here is a rough algorithm:
A simple example using the IMEI as a single byte and a data range of 0->2559:
Finally if you want the ranges to differ based on the record you could use that as a second offset as was done in step #2.