lundi 4 janvier 2016

Generate the same semi random number on two machines

I was wondering if there is a way to generate the same semi random number on two machines at the same time. Here is an example of how I am currently getting my randoms.

var randomValue = generateRandom( -200, 200 );

function generateRandom( min, max ) 
{
    min = Math.ceil( min );
    max = Math.floor( max );
    return Math.floor( Math.random() * ( max - min + 1 ) + min );
}

What I can do is send message between the two devices. I don't know if that will help because randomValue is being called within a function. I was thinking maybe we can use a timer or something to generate the value on both machines.




Aucun commentaire:

Enregistrer un commentaire