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
/*
22
* StorageKey
23
* Node with a word member. Comparisons are allowed and are according
24
* to lexicographic order of the words.
25
*
26
* Written by: Bryant Lee
27
* Date: 11/4/04
28
*/
29
30
#ifndef STORAGE_KEY_H
31
#define STORAGE_KEY_H
32
33
#define byte unsigned char
34
35
class StorageKey {
36
public:
37
byte * word;
38
private:
39
unsigned int wordLength;
40
41
//compare
42
//if > m, return positive
43
//if < m, return negative
44
//if == m, return 0
45
int compareTo(const StorageKey &m) const;
46
47
public:
48
//no argument constructor
49
StorageKey();
50
51
//primary constructor
52
StorageKey(byte *inWord, unsigned int inLength);
53
54
//copy constructor
55
StorageKey(const StorageKey &m);
56
57
//destructor
58
~StorageKey();
59
60
//operator =
61
const StorageKey & operator=(const StorageKey &right);
62
63
//relational operators
64
bool operator==(const StorageKey &right) const;
65
bool operator!=(const StorageKey &right) const;
66
bool operator<(const StorageKey &right) const;
67
bool operator>(const StorageKey &right) const;
68
bool operator<=(const StorageKey &right) const;
69
bool operator>=(const StorageKey &right) const;
70
71
//print
72
void print() const;
73
74
/*
75
* This hash actually puts the 0th element at the lsb, then moves left.
76
* Since in the FPeriod program, 0 is actually on the left, this is
77
* somewhat "backwards".
78
*/
79
unsigned long long hash(unsigned int shiftSize) {
80
unsigned int i;
81
unsigned long long result = 0;
82
unsigned int power = 1;
83
84
for(i = 0; i < wordLength; i++) {
85
result += power * word[i];
86
power *= shiftSize;
87
}
88
89
return result;
90
}
91
92
/*
93
* This hash puts the 0th element at the msb and moves right.
94
* Essentially, elements hash to their baseB representation where
95
* B = shiftSize
96
*/
97
unsigned long long hash_baseB(unsigned int shiftSize) {
98
int i;
99
unsigned long long result = 0;
100
unsigned int power = 1;
101
102
for(i = wordLength - 1; i >= 0; i--) {
103
result += power * word[i];
104
power *= shiftSize;
105
}
106
107
return result;
108
}
109
};
110
111
#endif
112
113