Modulo (%) wrapping of negative numbers behaves differently on different

platforms. This fixes that.
This commit is contained in:
Bruce Hill 2019-03-18 21:22:39 -07:00
parent 357f958cd1
commit 3f56f36dfb

View File

@ -6,10 +6,10 @@
#include <termbox.h>
#include <unistd.h>
#define CELL(cells, x, y) cells[((y) % H)*W + ((x) % W)]
#define CELL(cells, x, y) cells[(((y)+H) % H)*W + (((x)+W) % W)]
static char rules[2][9] = {{0,0,0,1,0,0,0,0,0}, {0,0,1,1,0,0,0,0,0}};
static int W, H, DEAD = 0, ALIVE = 7;
static unsigned int W, H, DEAD = 0, ALIVE = 7;
static void update(const char *cells, char *future_cells)
{