Modulo (%) wrapping of negative numbers behaves differently on different
platforms. This fixes that.
This commit is contained in:
parent
357f958cd1
commit
3f56f36dfb
4
conway.c
4
conway.c
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user