Rand() % 14 only generates the values 6 or 13

Per wikipedia, the multiplier being used in Apple’s MCG random number generator is 16807. This is divisible by 7, so the first random number produced after srand() will have only one bit of entropy mod 14 (that is, it can only take on two values).

It’s a crappy RNG they’ve got there. An easy solution, though, is just to call rand() a few times right after srand, and discard the results.

Leave a Comment