diff options
Diffstat (limited to 'tests/automata_text.c')
-rw-r--r-- | tests/automata_text.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/automata_text.c b/tests/automata_text.c new file mode 100644 index 0000000..574c402 --- /dev/null +++ b/tests/automata_text.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <string.h> + +#define HE he +#define WI wi +#define RULE rule + + +int main(int argc,char *argv[]) { + int i,j; + int rule=atoi(argv[1]); + char str[256];//lel. close enough. + int wi=read(0,str,sizeof(str)-1)*8; + int he=atoi(argv[2]); + char f[HE+1][WI+1]; + f[0][WI/2]=1; + for(i=0;i<HE;i++) { + for(j=0;j<WI;j++) { + if(i==0) f[i][j]=(str[j/8]>>(j%8))%2; + else f[i][j]=(RULE >> ((!!f[(i+HE-1)%HE][(j+WI-1)%WI]<<2) | (!!f[(i+HE-1)%HE][j]<<1) | (!!f[(i+HE-1)%HE][(j+1)%WI])) & 1); + } + } + for(i=0;i<HE;i++) { + for(j=0;j<WI;j++) { + if(f[i][j]) { + printf("%c",f[i][j]+'0'); + } else { + printf(" "); + } + } + printf("\n"); + } + return 0; +} |