Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TURMITE_H_
- #define TURMITE_H_
- #include <iostream>
- const char *rand_file() {
- char *filename = new char[1024];
- sprintf(filename, "turmite_%zd.rule", time(NULL));
- return filename;
- }
- void dump_transistions(const char *filename, unsigned int states, unsigned int symbols, uint32_t *transistions) {
- FILE *f = fopen(filename, "w");
- const char *actions = "LRFU";
- fprintf(f, "%d %d\n", states, symbols);
- printf("%d %d\n", states, symbols);
- for(unsigned int s = 0; s < states; s++) {
- for(unsigned int c = 0; c < symbols; c++) {
- int idx = (s * symbols + c) * 3;
- uint32_t next_action = transistions[idx + 0];
- uint32_t next_symbol = transistions[idx + 1];
- uint32_t next_state = transistions[idx + 2];
- printf("%u %u -> %u %u %u\n", s, c, next_action, next_symbol, next_state);
- fprintf(f, "%c %u %u\n", actions[next_action], next_symbol, next_state);
- }
- }
- fclose(f);
- }
- #endif /* !TURMITE_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement