Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

A (one dimensional) cellular automaton is a function1 F : Σ → Σ with the property that there is a K > 0 such that F (x)i depends only on the 2K + 1 coordinates xi−K , xi−K+1, . . . , xi−1, xi, xi+1, . . . , xi+K . A periodic point of σ is any x such that σ^p (x) = x for some p ∈ N, and a periodic point of F is any x such that F^q (x) = x for some q ∈ N. Given a cellular automaton F, a point x ∈ Σ is jointly periodic if there are p, q ∈ N such that σ^p (x) = F^q (x) = x, that is, it is a periodic point under both functions.

This project aims to explore the nature of one-dimensional Cellular Automata, in the hope of finding the structure of cellular automata through its periodic points.

2034 views
License: MIT
ubuntu2004
1
/*
2
* Copyright (C) 2004 Bryant Lee
3
*
4
* This file is part of FPeriod.
5
*
6
* FPeriod is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* FPeriod is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with FPeriod; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
/* String Ops
22
* Some operations that can be performed on strings
23
*
24
* Written by: Bryant Lee
25
* Date: 10/29/04
26
*/
27
28
#include "StringOps.h"
29
30
#include <string>
31
#include <vector>
32
33
extern int UINTSIZE;
34
35
/* split
36
* Split the string on c
37
*/
38
void split(const string &str, char c, vector<string> &output) {
39
int i = 0, last = -1, strlength = str.length();
40
41
//Assume output is already empty
42
43
for(i = 0; i < strlength; i++) {
44
if(str[i] == c) {
45
if(last != -1) {
46
output.push_back(str.substr(last, i - last));
47
}
48
49
last = -1;
50
}
51
else if(last == -1) {
52
last = i;
53
}
54
}
55
56
if(last != -1) {
57
output.push_back(str.substr(last, strlength - last));
58
}
59
}
60
61
/* trim
62
* Remove leading and trailing whitespace
63
*/
64
void trim(string &str) {
65
unsigned int i = 0;
66
67
while(i < str.length() && str[i] == ' ') {
68
i++;
69
}
70
71
str.erase(0,i);
72
73
i = str.length() - 1;
74
while(i >= 0 && str[i] == ' ') {
75
i--;
76
}
77
78
str.erase(i + 1, str.length() - i + 1);
79
}
80
81
/* alphachar
82
* returns true if c is an upper or lower case letter
83
*/
84
bool alphachar(char c) {
85
return (c >= 65 && c <= 90) || (c >= 97 && c <= 122);
86
}
87
88
/*
89
* Copy the contents of b into a
90
*/
91
void copyWord(byte *a, byte *b, unsigned int length) {
92
unsigned int i = 0;
93
94
for(i = 0; i < length; i++) {
95
a[i] = b[i];
96
}
97
}
98
99
/*
100
* Copy the contents of b into a
101
*/
102
void copyUIntArray(unsigned int *a, unsigned int *b, unsigned int length) {
103
unsigned int i = 0;
104
105
for(i = 0; i < length; i++) {
106
a[i] = b[i];
107
}
108
}
109
110
/* printArray
111
* Print an array to screen
112
*/
113
void printArray(byte *arr, unsigned int length) {
114
unsigned int i = 0;
115
116
for(i = 0; i < length; i++) {
117
cout << (int) arr[i];
118
119
if(i != length - 1)
120
cout << ",";
121
}
122
123
cout << "\n";
124
}
125
126
/*
127
* printUInt
128
* Print the word
129
*/
130
void printUInt(unsigned int word, unsigned int length) {
131
unsigned int i = 0;
132
133
for(i = 0; i < length; i++) {
134
if(word & (1 << i))
135
cout << "1";
136
else
137
cout << "0";
138
}
139
140
cout << "\n";
141
}
142
143
/*
144
* printUIntArray
145
* Print array of Uints
146
*/
147
void printUIntArray(unsigned int word[], unsigned int length) {
148
unsigned int i = 0;
149
int j;
150
151
while(length > 0) {
152
for(j = 0; j < (UINTSIZE < (int)length ? UINTSIZE : (int)length); j++) {
153
if(word[i] & (1 << j))
154
cout << "1";
155
else
156
cout << "0";
157
}
158
cout << " ";
159
160
length -= UINTSIZE;
161
i++;
162
}
163
}
164
165
/*
166
* (used in main.cpp and func.cpp)
167
* Return true when we iterate past end. Return false otherwise.
168
*/
169
bool iterateWord(byte* arr, unsigned int length, unsigned int shiftSize) {
170
unsigned int i = 0;
171
bool ret = false;
172
173
while(i < length) {
174
arr[i]++;
175
if(arr[i] >= shiftSize) {
176
arr[i] = 0;
177
i++;
178
}
179
else
180
break;
181
}
182
183
if(i == length)
184
ret = true;
185
186
return ret;
187
}
188
189
190