/* ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º º º 8 State Finite Closed 2-Dimensional Cellular Automation º º º º Sierpinski Rule File Maker º º º º (c) 1991 Christopher D. Watkins º º º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ */ #include "stdio.h" #include "dos.h" #include "string.h" #include "defs.h" #include "globals.h" #include "mathb.h" #define State 8 #define MaxState (State-1) typedef char Name[33]; typedef Byte Rule[8][8][8][8][8]; Name RuleFileName; FILE *RuleFile; Rule Rules; Word i, j, k, l, m; int x; Byte o; void WriteRuleFile() { fwrite(Rules, sizeof(Rule), 1, RuleFile); fclose(RuleFile); } void main() { clrscr(); printf("Generating Rule\n"); strcpy(RuleFileName,"RULE2D.CA"); RuleFile=fopen(RuleFileName, "wb"); for(i=0; i<=MaxState; i++) { for(j=0; j<=MaxState; j++) { for(k=0; k<=MaxState; k++) { for(l=0; l<=MaxState; l++) { for(m=0; m<=MaxState; m++) { /* x=abs(i+k+l); */ x=(i+j+k+l); /* x=abs(i+j+k+l+m); */ /* x=k&(i|j|l|m)|(~k)&(i+j); */ o=(x%State)&0xFF; Rules[i][j][k][l][m]=o; } } } } } WriteRuleFile(); }