Created
April 28, 2020 01:14
-
-
Save a11ce/3d178011e0b1122e5911acb538c51a32 to your computer and use it in GitHub Desktop.
tinyLife
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> // by Riley | |
#include <stdlib.h>// a11ce on GitHub | |
#include <unistd.h>// Conway's Game | |
#include <string.h>// of Life | |
#include <time.h> // 2019 | |
#define l for(i j = 0; j < H; j++) \ | |
{for(i k = 0; k < W; k++){ | |
#define e ;}} | |
#define c [j][k] | |
const int H=40; const int W=40; | |
typedef int i; i m[W][H]; i n[W][H]; | |
const i A= 659918; | |
i main(){srand((i)time(NULL)); | |
l m c=rand()%2 e while(1){ | |
l printf("%s%s", (m[j][k]?"O":" "), | |
k+1==W?"\n":""); e l i t = 0; | |
for(i x=-1;x<2;x++){for(i y=-1;y<2;y++) | |
{t += m[j+x][k+y] e t -= m c; | |
n c = ((m c &&(t==2||t==3))|| | |
((!m c) &&t==3)); e memcpy(m,n, | |
sizeof(n)); sleep(1); printf( | |
"\e[1;1H\e[2J%x\n",A);} | |
return 0; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment