MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / evolve

Function evolve

test/life.c:23–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void evolve(void *u, int w, int h)
24{
25 unsigned (*univ)[w] = u;
26 unsigned new[h][w];
27
28 for_y for_x {
29 int n = 0;
30 for (int y1 = y - 1; y1 <= y + 1; y1++)
31 for (int x1 = x - 1; x1 <= x + 1; x1++)
32 if (univ[(y1 + h) % h][(x1 + w) % w])
33 n++;
34
35 if (univ[y][x]) n--;
36 new[y][x] = (n == 3 || (n == 2 && univ[y][x]));
37 }
38 for_y for_x univ[y][x] = new[y][x];
39}
40
41void nudge(void *u, int w, int h)
42{

Callers 1

gameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected