obfuscate is a project where the code of a conway's game of life implementation is obfuscated and formatted as a glider.
x,y,cx,cy,dx,
dy,n,f[8][16]
,b[8][16];main
(){f[0][1]=1;
f[1][2]=1;f[2
][0]=1;f[2][1
]=1;f[2][2]=1
;for(;;){for(cy
=0;cy<8;++cy){
for(cx=0;cx<16
;++cx){printf(
"%c",".*"[f[cy
][cx]]);n=0;for
(dx=-1;dx<=1;++
dx)for(dy=-1; dy<=1;++dy)if (!(dx==0&&dy==
0)){x=((cx+dx )%16+16)%16;y =((cy+dy)%8+8)
%8;if(f[y][x] )n+=1;}b[cy][ cx]=f[cy][cx]?
(n==2||n==3): n==3;}printf( "\n");}memcpy(
f,b,sizeof(f) );printf("\033" "[%dA\033[%dD"
,8,16);usleep (100*1000);}} //*^7shc*7"jh"
conway.c
: the obfuscated version formatted as the glider.src/conway.obfus.c
: the unformatted obfuscated version.src/conway.orig.c
: the original unobfuscated version.src/imgformat.c
: the C code formatter.
running the following commands will build all of the aforementioned files and
put the executables in target
.
$ make
$ ./conway
- I <3 pull requests and bug reports!
- Don't hesitate to tell me my code-fu sucks, but please tell me why.
- Feel free to fork the project and try out your own optimisations.
Obfuscate is licensed under the MIT License.
Copyright (c) 2023 Samarth Kulshrestha.