commit 26c0729eeef14accf4f7b01512b772b22bbb97af
parent 39ae0f1a1265076cf5e21a0ce05b1f1958f6da55
Author: Wilson Gheen <wilson@wilsonrgheen.com>
Date: Fri, 9 Dec 2022 04:30:33 -0600
Give back terminal once done and test larger arrays
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/life.c b/life.c
@@ -11,7 +11,7 @@
#define WIDTH(x) sizeof(x[0]) * 8
static uint32_t glider[] = {0, 131072, 65536, 458752, 0, 0, 0, 0};
-static uint32_t modGlider[] = {524288, 262144, 1835008, 0, 0, 0, 0, 0};
+static uint32_t modGlider[] = {524288, 262144, 1835008, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
static uint32_t vline[] = {0, 0, 131072, 131072, 131072, 0, 0, 0};
static uint32_t what[] = {0, 0, 393216, 393216, 393216, 393216, 393216, 0};
static uint32_t what2[] = {0, 0, 262144, 262144, 262144, 262144, 262144, 0};
@@ -64,7 +64,7 @@ void print_board(uint32_t board[], int rows, int cols) {
}
uint32_t *get_next_state(uint32_t board[], int rows, int cols) {
- uint32_t m[8];
+ uint32_t m[16];
for(int r=0; r < rows; r++) {
uint32_t newRow = board[r];
/* For a single byte for example, this value will be 1000 0000.*/
@@ -104,15 +104,15 @@ uint32_t *get_next_state(uint32_t board[], int rows, int cols) {
/* }*/
/* printf("\n");*/
/* }*/
- // rows
- static uint32_t tmp[8];
+ static uint32_t tmp[16];
memcpy(tmp, m, sizeof m);
return tmp;
}
void play(uint32_t board[], int rows, int cols) {
tb_init();
- while(1) {
+ int rounds = 52;
+ while(rounds-->0) {
tb_clear();
print_board(board, rows, cols);
sleep(1);
@@ -135,5 +135,6 @@ int main() {
/* uint32_t *mp = play(l);*/
/* uint32_t *np = play(mp);*/
/* play(np);*/
+ tb_shutdown();
return 0;
}