Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Weird random result
Message
De
31/08/2022 19:36:47
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., Nouvelle Zélande
 
 
À
31/08/2022 07:05:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01684912
Message ID:
01684921
Vues:
76
J'aime (1)
>>Can anybody explain me why there seems to be a problem with random numbers and a delay?

Certainly seems odd...

Re the randomizing code: if I read it correctly, starting thisform.nTot at 75 then decrementing after each hit means 75 can only ever appear first in the sequence since thisform.nTot then decrements to 74; and 74 can only appear first or second, etc etc. This means you can anticipate a preponderance of lower duplicates that can often follow very similar sequence as nTot decrements towards 1, while higher numbers are infrequent and always earlier than (77-n) in the sequence if they do appear.

To randomize all numbers in a series, I've seen efforts like this that scatter high and low values and eliminate duplicate returns:
=rand(-1)
declare laNumber(75)
for licounter=1 to 75
   laNumber(m.licounter)=m.licounter
endfor
for licounter=1 to 75
   liRandom=int(rand()*(76-m.licounter))+1
  ? lanumber(m.lirandom)
  adel(lanumber,m.liRandom)
  *WAIT timeout 8
ENDFOR
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform