mirror of
https://codeberg.org/emilwilliams/life
synced 2024-11-22 03:54:20 -05:00
fully disable debug compilation, remove code comments
This commit is contained in:
parent
947ff4e765
commit
55c146c927
82
life.c
82
life.c
@ -1,5 +1,5 @@
|
||||
/* @BAKE \
|
||||
cc -O2 -Wshadow -Wall -Wextra -Wpedantic -g -fsanitize=address,undefined,bounds \
|
||||
cc -O2 -Wshadow -Wall -Wextra -Wpedantic \
|
||||
$@ -o $* -lm -DNDEBUG $+ @STOP */
|
||||
|
||||
#include <math.h>
|
||||
@ -110,26 +110,6 @@ DELC board_t * board_dup (board_t * b) {
|
||||
return a;
|
||||
}
|
||||
|
||||
#if 0
|
||||
DELC int board_cmp (board_t * a, board_t * b) {
|
||||
int s = 0;
|
||||
for (int i = 0; i < b->h; ++i) {
|
||||
for (int f = 0; f < b->w; ++f) {
|
||||
s += a->g [i] [f] != b->g [i] [f];
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
DELC void board_invert (board_t * b) {
|
||||
for (int i = 0; i < b->h; ++i) {
|
||||
for (int f = 0; f < b->w; ++f) {
|
||||
b->g [i] [f] = !(b->g [i] [f] == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Must place the cursor at the top left of the already printed board */
|
||||
DELC void board_highlight (board_t * b, int fg, int x, int y) {
|
||||
if (y) { move_down (y); }
|
||||
@ -158,49 +138,6 @@ DELC board_t * board_alloc_text (char * s) {
|
||||
|
||||
/* life */
|
||||
|
||||
#if 0
|
||||
DELC int life_near_loop (board_t * b, int x, int y) {
|
||||
int ** g = b->g, w = b->w, h = b->h;
|
||||
|
||||
int
|
||||
ty = (y-1) % h, lx = (x-1) % w,
|
||||
cy = ( y) % h, cx = ( x) % w,
|
||||
by = (y+1) % h, rx = (x+1) % w;
|
||||
|
||||
return
|
||||
g [ty] [lx] + g [ty] [cx] + g [ty] [rx]
|
||||
+ g [cy] [lx] + (g [cy] [cx] << 5) + g [cy] [rx]
|
||||
+ g [by] [lx] + g [by] [cx] + g [by] [rx];
|
||||
}
|
||||
|
||||
DELC int life_near_lim (board_t * b, int x, int y) {
|
||||
int ** g = b->g, w = b->w, h = b->h;
|
||||
|
||||
int
|
||||
ty = (y-1), lx = (x-1),
|
||||
cy = ( y), cx = ( x),
|
||||
by = (y+1), rx = (x+1),
|
||||
s = g [cy] [cx] << 5;
|
||||
|
||||
if (ty < h) {
|
||||
s += lx < w ? g [ty] [lx] : 0;
|
||||
s += g [ty] [cx] ;
|
||||
s += rx >= 0 ? g [ty] [rx] : 0;
|
||||
}
|
||||
|
||||
s += lx < w ? g [cy] [lx] : 0;
|
||||
s += rx >= 0 ? g [cy] [rx] : 0;
|
||||
|
||||
if (by >= 0) {
|
||||
s += lx < w ? g [by] [lx] : 0;
|
||||
s += g [by] [cx] ;
|
||||
s += rx >= 0 ? g [by] [rx] : 0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
DELC int life_near_lim (board_t * b, int x, int y) {
|
||||
int ** g = b->g, w = b->w, h = b->h, s = 0, i, f, yi, xf;
|
||||
for (i = -1; i < 2; ++i) {
|
||||
@ -239,23 +176,6 @@ DELC void life_update (board_t * a, board_t * b) {
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
DELC void life_update (board_t * a, board_t * b) {
|
||||
int near, me, ** g = a->g;
|
||||
for (int i = 0; i < b->h; ++i) {
|
||||
for (int f = 0; f < b->w; ++f) {
|
||||
near = life_near (b, f, i);
|
||||
me = near & LIFE_ALIVE;
|
||||
near &= LIFE_NEAR_MASK;
|
||||
g [i] [f] =
|
||||
(near == 3)
|
||||
+ ( (me && (near < 2))
|
||||
|| (me && (near > 3))) * LIFE_DEAD;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DELC void life (board_t * b, int step, int wait) {
|
||||
printf (
|
||||
"rect %d:%d\n"
|
||||
|
Loading…
Reference in New Issue
Block a user