rand.c

mud/2.4.5/players/lars/rand.c · 558 B

From the archive 2.4.5-for-1.1.tgz

Download the archive   « Back to the archive contents

get() { return 1; }
short() { return "true"; }
init() { add_action("test_random", "test"); }
test_random(str) {
   int i, a, b, s, k, iterations, range;

   if (sscanf(str, "%d %d", iterations, range) != 2) return 0;
   a = allocate(range);
   for (i = 0; i < iterations; i++) {
      a[random(range)]++;
      b++;
   }
   for (i = 0; i < range; i++) {
      write(i + "\t" + a[i] + "\t" + (a[i] * 100/iterations) + "%\n");
      s += a[i];
   }
   write("iterations: "+iterations+"\trange: "+range+"\tcount: "+b+
         "\tsum: "+s+"\n");
   return 1;
}

Site Stats

Snippets: 1791
Codebases: 571