#include #define TAPE_SIZE 80 #define RULES_SIZE 256 typedef struct { char state; /* current state */ char symbol; /* current symbol */ int head; /* index of head */ char tape[TAPE_SIZE]; /* tape of characters */ int nrules; /* number of rules */ /* state, symbol, new state, new symbol, direction (even right, odd left ) */ char rules[RULES_SIZE][5]; } Machine; Machine m; int nsteps; int main(int argc, char *argv[]){ int i,n=0; FILE *f; if(!(f = fopen(argv[1], "r"))){ fprintf(stderr, "failed to load file\n"); return 1; } printf("%s\n\n", argv[1]); /* read machine description */ printf("initial state: "); fscanf(f,"%c",&m.state); printf("%c\n",m.state); printf("initial tape: "); fscanf(f,"%s",m.tape); printf("%s\n",m.tape); printf("initial position of head: "); fscanf(f,"%d",&m.head); m.head = (m.head+TAPE_SIZE)%TAPE_SIZE; printf("%d\n",m.head); printf("number of rules: "); fscanf(f,"%d",&m.nrules); printf("%d\n",m.nrules); for(i=0; i