+#include <stdint.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <unistd.h>
#define COLS 80
#define ROWS 25
#define STR(x) _STR (x)
#define _STR(x) #x
+static uint16_t xss; /* xs() state */
+
+static uint16_t
+xs () /* xorshift prng */
+{
+ xss ^= (xss << 1);
+ xss ^= (xss >> 3);
+ xss ^= (xss << 10);
+
+ return xss;
+}
+
static void
clearscr ()
{
{
for (int i = 0; i < COLS * ROWS; i++)
{
- if (rand () % INIT_RATIO)
+ if (xs () % INIT_RATIO)
grid[i] = DEAD;
else
grid[i] = ALIVE;
{
char grid[COLS * ROWS];
- srand (time (0));
+ xss = time (0);
init_grid (grid);
do