Facebook
From Crippled Terrapin, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 47
  1. const percent = 6;
  2.  
  3. const chance = percent / 100;
  4. const dreamDrops = 42;
  5. const dropsPerIteration = 263;
  6. const iterationsPerTick = 1000000;
  7. let maxDrop = 0;
  8. let ticks = 0;
  9.  
  10. iterationBatch();
  11.  
  12. function iterationBatch() {
  13.   for(let x = 0; x < iterationsPerTick; x++) {
  14.     iteration();
  15.   }
  16.   ticks++;
  17.  
  18.   console.log(`[${ticks}m]: max = ${maxDrop}`)
  19.   setTimeout(() => iterationBatch(), 0);
  20. }
  21.  
  22. function iteration() {
  23.   let drops = 0;
  24.   for(let i = 0; i < dropsPerIteration; i++) {
  25.     if ( Math.random() <= chance) {
  26.       drops++;
  27.     }
  28.   }
  29.   maxDrop = Math.max(drops, maxDrop);
  30. }