| 1 |
/* |
| 2 |
* Test the <<one of>>...<<shuffle>> algorithm. In particular, this |
| 3 |
* tests for repeats at re-shuffle boundaries. |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <tads.h> |
| 7 |
#include <bignum.h> |
| 8 |
|
| 9 |
|
| 10 |
main(args) |
| 11 |
{ |
| 12 |
local n = args.length() > 1 ? toInteger(args[2]) : 10, trials = 5000; |
| 13 |
|
| 14 |
local lst = new OneOfIndexGen(); |
| 15 |
lst.numItems = n; |
| 16 |
lst.listAttrs = 'shuffle'; |
| 17 |
|
| 18 |
for (local i in 1..trials, local last = nil) |
| 19 |
{ |
| 20 |
local pick = lst.getNextIndex(); |
| 21 |
"<<pick>><<if pick == last>> *** REPEAT!!! ***<<end>><< |
| 22 |
if i < trials>>, "; |
| 23 |
|
| 24 |
last = pick; |
| 25 |
} |
| 26 |
} |