|
March 14, 2013, 08:14:19 PM Last edit: March 14, 2013, 10:58:44 PM by remotemass |
|
To have a more random number you can multiply it by the number of seconds in between blocks. But I agree, block hash may be a better choice. You don't even need to truncate it, just convert to decimal and do H mod N, with H being the hash of the block created - closing of the game - converted to decimal and N the number of participants of the list of participants by arrival, and you get a random pick, giving you the position of the winner in that list with H mod N.
You just have to rule in advance which block will close the contest, than do this simple calculations, and voila!
Or, of course, you could use a maximum number of participants if you wanted, and expect for the next block created after such last participation, to be able to tell the random pick.
|