Nightmare™
Nightmare™ is the experimental 64-bit PRNG with frightening speed and minimal statistical test results.
The following non-cryptographic PRNG library can be implemented after proprietary license compliance.
Implementation
Nightmare™ was implemented in C (requiring the stdint.h header to define a 64-bit, unsigned integral type for uint64_t).
Each Nightmare™ variant has both a minimum period of at least 2⁶⁴ and reversibility.
#include <stdint.h>
struct nightmare64_state {
uint64_t a;
uint64_t b;
};
struct nightmare512_state {
uint64_t output[8];
uint64_t a;
uint64_t b;
uint64_t c;
uint64_t d;
uint64_t e;
};
uint64_t nightmare64(struct nightmare64_state *s) {
s->a = ((s->a << 27) | (s->a >> 37)) ^ s->b;
s->b += 1111111111;
return s->a;
}
void nightmare512(struct nightmare512_state *s) {
s->a = ((s->a << 25) | (s->a >> 39)) ^ s->b;
s->b += 1111111111111111;
s->c += s->a + (s->b << 3);
s->d += s->c;
s->e += s->a;
s->output[0] = s->a + s->b;
s->output[1] = s->b + s->c;
s->output[2] = s->a ^ s->b;
s->output[3] = s->a + s->c;
s->output[4] = s->b ^ s->c;
s->output[5] = s->d;
s->output[6] = s->a ^ s->c;
s->output[7] = s->e;
}
Reference
The nightmare64 function modifies the state in a struct nightmare64_state instance to generate 1 pseudorandom uint64_t integer as the return value.
Each state variable (a and b) in a struct nightmare64_state instance must be seeded (before generating a deterministic nightmare64 sequence).
The nightmare512 function modifies the state in a struct nightmare512_state instance to generate 8 pseudorandom uint64_t integers in the output array.
Each state variable (a, b, c, d and e) in a struct nightmare512_state instance must be seeded (before generating a deterministic nightmare512 sequence).
Randomness
Each Nightmare™ variant has no FAILED results in at least 1 full set of dieharder -d 102 -g 200 tests (sts_serial from the latest Dieharder 3.31.1 tests).
Furthermore, the following gameplay loop proves the application-specific utility of visual pseudorandomness that fails specific statistical tests in exchange for maximum speed.
Speed
Nightmare™ speed tests generate (and hash) 1 billion pseudorandom uint64_t integers in a #pragma GCC unroll 0 loop.
Each of the following results log the fastest process execution speed (from an AMD A4-9120C with gcc -O3) among several repetitions of the aforementioned test.
nightmare64 was 219ms faster than blastcircuit.
nightmare128 was replaced by abyss128.
nightmare256 was replaced by abyss256.
nightmare512 was 149ms faster than abyss256.