Commit | Line | Data |
---|---|---|
74edf561 AT |
1 | Overview |
2 | ======== | |
3 | ||
4 | This WolframAutomata hack displays the time evolution of [elementary cellular | |
5 | automata](https://en.wikipedia.org/wiki/Elementary_cellular_automaton). | |
6 | ||
7 | These automata consist of a line of cells, each of which may be either on or | |
8 | off. To ensure every cell has neighbors, the two endpoints of the line connect | |
9 | together, thereby forming a circular universe for the cells to inhabit. This | |
10 | line is drawn horizontally on the screen. | |
11 | ||
12 | Over time, this line of cells evolves according to rules, with some cells | |
13 | switching on or off. Each new iteration is drawn below its predecessor, leading | |
14 | the screen to scroll vertically over time. | |
15 | ||
16 | The rules which govern the time evolution of this system depend only on the | |
17 | current state of a given cell and the state of its two immediate neighbors. | |
18 | These rules are formalized as | |
19 | [Wolfram codes](https://en.wikipedia.org/wiki/Wolfram_code), | |
20 | where the code number is directly convertible into a rule set. | |
21 | ||
22 | For example, the following screenshot demonstrates | |
23 | [Rule 110](https://en.wikipedia.org/wiki/Rule_110), itself Turing complete as | |
24 | discussed at length in a | |
25 | [fascinating paper](https://arxiv.org/pdf/0906.3248.pdf). | |
26 | ||
27 | ![Rule 110 Animated Screenshot](/screensavers/.git/blob_plain/HEAD:/hacks/WolframAutomata/screenshot_rule_110.gif) | |
28 | ||
29 | Commandline flags are provided enabling the user to tweak attributes such as | |
30 | length and speed of simulation, cell size, rule number, colors, starting seed, | |
31 | and other attributes. For example, the screenshot below depicts Rule 73 with | |
32 | different colors than the Rule 110 screenshot. Like the Rule 110 screenshot, it | |
33 | uses `-cell-size 2` and seeds the simulation with only a single active cell. | |
34 | ||
35 | ![Rule 73 Animated Screenshot](/screensavers/.git/blob_plain/HEAD:/hacks/WolframAutomata/screenshot_rule_73.gif) | |
36 | ||
37 | In situations where true randomness would lead to visually unappealing | |
38 | displays, this program provides random selection from curated lists. For | |
39 | example, to avoid randomly selecting visually indistinguishable colors like | |
40 | `dark red` and `brown` to depict on/off cells, the program includes a | |
41 | pre-selected list of color pairs that complement each other and chooses | |
42 | randomly from this list when the `-random-color` flag is passed. Similarly, to | |
43 | avoid the visually uninteresting rules like rule 0, a rule which simply turns | |
44 | every cell off and keeps it off, the program includes a list of rulesets and | |
45 | starting seeds which are visually appealing, selecting randomly from this list | |
46 | when the `-random-rule` flag is passed. | |
47 | ||
48 | ||
49 | Status | |
50 | ====== | |
51 | ||
52 | Complete. Tested on FreeBSD. | |
53 | ||
54 | Nearly works on Linux. The only problem resides in `WolframAutomata_free()`, | |
55 | where the call to `XFreeGC()` results in a linker error. Commenting that line | |
56 | allows WolframAutomata to build and execute on Linux, but creates a memory leak | |
57 | in the X server, resulting in its eventual termination. | |
58 | ||
59 | ||
60 | Instructions | |
61 | ============ | |
62 | ||
63 | The included `Makefile` includes targets for `make all` to build the hack, | |
64 | `make clean` to delete any build detritus, and `make run` to execute the hack. | |
65 | ||
66 | If you are running on FreeBSD, simply run one of those three commands. Anywhere | |
67 | else, edit the `Makefile` to suit your environment per the comments included in | |
68 | that file. Note that the `Makefile` assumes a copy of the screenhack library | |
69 | source code is located at `../screenhack/` relative to this directory. | |
70 | ||
71 | For assistance setting `$(DEFINES)` on non-FreeBSD platforms, consider | |
72 | downloading the XScreensaver source tarball, running `./configure` in the | |
73 | unpacked directory, and examining the resulting `config.h` file. | |
74 | ||
75 | Although WolframAutomata can integrate with XScreensaver, the presence of | |
76 | XScreensaver is not strictly required. WolframAutomata will both build and | |
77 | execute using only the included screenhack library. | |
b020506b AT |
78 | |
79 | ||
80 | Command-Line Flags | |
81 | ================== | |
82 | ||
83 | Whenever related options exist, such as the following two rule-selection | |
84 | options, the related options are listed in order of precedence. | |
85 | ||
86 | Where flags instruct the program to make random selections, these selections | |
87 | are re-randomized every time the simulation is reset, such as after a | |
88 | simulation completes or after resizing the window. | |
89 | ||
90 | ||
91 | CLI: Simulation Seed | |
92 | -------------------- | |
93 | ||
94 | If none of the following options are specified, the starting seed will contain | |
95 | randomly interspersed active/inactive cells at a 30/70, 50/50, or 70/30 ratio, | |
96 | itself also randomly selected. | |
97 | ||
98 | - **`-seed-left`**: Seeds a single active cell on the left side of the | |
99 | display. All other cells are inactive. | |
100 | ||
101 | - **`-seed-center`**: As above, but in the center. | |
102 | ||
103 | - **`-seed-right`**: As above, but on the right side. | |
104 | ||
105 | - **`-seed-density N`**: Generates random seed with `N` percent active cells. | |
106 | ||
107 | ||
108 | CLI: Rule Selection | |
109 | ------------------- | |
110 | ||
111 | If neither of the following two options are passed, rules are randomly selected | |
112 | from `curated_ruleset_list[]` in `WolframAutomata.c`. | |
113 | ||
114 | - **`-true-random-rule`**: Select a rule completely at random, NOT randomly | |
115 | from a curated list. Note that many rules are visually uninteresting. | |
116 | ||
117 | - **`-rule N`**: Select a specific rule where `N` is a Wolfram number. Values | |
118 | from 1-255 inclusive are valid. | |
119 | ||
120 | Note that, although Rule 0 is a valid set of rules, it is reused as a null | |
121 | value by the program and thus is ignored if passed as `-rule 0`. If you want to | |
122 | see Rule 0, choose any starting conditions you desire, then turn off your | |
123 | monitor and enjoy the resulting simulation. | |
124 | ||
125 | ||
126 | CLI: Simulation Speed | |
127 | --------------------- | |
128 | ||
129 | If neither of the following two options are passed, the simulation runs as | |
130 | though `-delay 25000` was passed. | |
131 | ||
132 | - **`-random-delay`**: A random delay is selected, but not truly random. For | |
133 | more details, read `WolframAutomata.c` starting around the comment, "When | |
134 | randomly setting the delay, the problem is to avoid ..." | |
135 | ||
136 | - **`-delay N`**: Request `N` microsecond delay between each frame/generation | |
137 | of the simulation. Note that this is only a request; XScreensaver reserves | |
138 | the right to ignore requested values, and of course we execute at the mercy | |
139 | of the kernel's scheduling. In practice, non-absurd values are reasonably | |
140 | well respected. | |
141 | ||
142 | ||
143 | CLI: Simulation Length | |
144 | ---------------------- | |
145 | ||
146 | If neither of the following two options are passed, the simulation runs as | |
147 | thought `-length 5000` was passed. | |
148 | ||
149 | - **`-random-length`**: A random length smaller than 10,000 generations but | |
150 | large enough to fill the screen is selected. | |
151 | ||
152 | - **`-length N`**: Request `N` generations be simulated on each run. | |
153 | ||
154 | Note that an upper limit of 10,000 generations is enforced in order to avoid | |
155 | `BadAlloc` errors from some X servers. For more details, read | |
156 | `WolframAutomata.c` starting around the comment, "The maximum number of | |
157 | generations is cell_size dependent. This is a soft limit and may be increased | |
158 | if ..." | |
159 | ||
160 | ||
161 | CLI: Cell Dimensions | |
162 | -------------------- | |
163 | ||
164 | Individual cells may be displayed as any square number of pixels (e.g. 1x1, | |
165 | 2x2, etc). Increasing the cell size may help with flickering on high DPI | |
166 | monitors displaying chaotic rulesets. | |
167 | ||
168 | If neither of the following two options are passed, the simulation selects | |
169 | whatever cell size it feels appropriate for the current simulation speed. | |
170 | ||
171 | - **`-random-cell-size`**: Selects cell size of 2^N pixels for an `N` | |
172 | randomly chosen in the inclusive range `0`-`5`. | |
173 | ||
174 | - **`-cell-size N`**: Display each individual cell as an `N`x`N` square of | |
175 | pixels on the screen. | |
176 | ||
177 | ||
178 | CLI: Color | |
179 | ---------- | |
180 | ||
181 | At the moment, the program does not allow the user to specify raw RGB values | |
182 | from the command line. Instead, color pairs are selected from `color_list[]` | |
183 | in `WolframAutomata.c` by specifying an index (starting from `0`) into this | |
184 | array. However, any RGB color the user desires may be added by creating new | |
185 | entries in that array (or editing existing entries) and recompiling. | |
186 | ||
187 | If the following CLI option is not passed, a random color selection is made | |
188 | from `color_list[]` at the start of each new simulation run. | |
189 | ||
190 | - **`-color-index N`**: Select color pair `N` from `color_list[]` in | |
191 | `WolframAutomata.c`. | |
192 | ||
193 | Note that the names provided as comments in `color_list[]` are X11 color names. | |
194 | ||
195 | ||
196 | CLI: Admiration | |
197 | --------------- | |
198 | ||
199 | When the simulation reaches its end as determined by flags like `-length N`, it | |
200 | will pause for a period of time, allowing the viewer to examine it without | |
201 | interference from scrolling. By default, this 'admiration window' is five | |
202 | seconds long. | |
203 | ||
204 | - **`-admiration-delay N`**: At the end of a simulation, pause for `N` | |
205 | seconds before resetting for the next simulation. | |
de7de9e7 AT |
206 | |
207 | ||
208 | XScreensaver Integration | |
209 | ======================== | |
210 | ||
211 | In addition to running as a standalone program, WolframAutomata can be | |
212 | integrated into the XScreensaver framework. | |
213 | ||
214 | To accomplish this integration, begin by installing and configuring | |
215 | XScreensaver via whatever method is appropriate for your operating system. The | |
216 | following instructions assume the filesystem paths used by FreeBSD packages and | |
217 | ports; your paths may differ. After XScreensaver installation, ensure all | |
218 | pertinent config files are created by running `xscreensaver-demo` and | |
219 | configuring it for your system. | |
220 | ||
221 | After XScreensaver is configured and working on your system, ensure that | |
222 | WolframAutomata runs in standalone mode on your system. If you can `make clean | |
223 | run` in the `screensavers/hacks/WolframAutomata/` folder and see the hack's | |
224 | output, you're ready to move on. | |
225 | ||
226 | At this point, copy the hack into your XScreensaver hack directory. For | |
227 | example, with prerequisite steps spelled out: | |
228 | ||
229 | git clone git://git.subgeniuskitty.com/screensavers | |
230 | cd screensavers/hacks/WolframAutomata | |
231 | make clean all | |
232 | cp WolframAutomata /usr/local/bin/xscreensaver-hacks/ | |
233 | ||
234 | Now create the file `WolframAutomata.xml` wherever your system stores | |
235 | XScreensaver config files and populate it with the contents shown below. For | |
236 | example, on FreeBSD: | |
237 | ||
238 | vi /usr/local/share/xscreensaver/config/WolframAutomata.xml | |
239 | ||
240 | TODO: Finish writing this file after the command line options are finalized. | |
241 | ||
242 | The final step integrates WolframAutomata into an individual users's | |
243 | XScreensaver framework. If preferred, it could instead be done in the global | |
244 | XScreensaver config. | |
245 | ||
246 | Add the WolframAutomata entry under the `programs:` label, in the same list as | |
247 | all the other hacks. Position in the list is irrelevant, but ensure you don't | |
248 | paste WolframAutomata's entry into the middle of pre-existing, multi-line | |
249 | entries. | |
250 | ||
251 | vi ~/.xscreensaver | |
252 | ||
253 | programs: \ | |
254 | WolframAutomata -root -party-mode \n\ | |
255 | ||
256 | That's all. Now you can run `xscreensaver-demo` and select WolframAutomata just | |
257 | like any other hack. | |
258 | ||
259 | ||
260 | Screen Tearing | |
261 | ============== | |
262 | ||
263 | Certain combinations of rules and display settings lead to full screen vertical | |
264 | scrolling of alternating light and dark pixels, or other difficult to display | |
265 | patterns. If your display doesn't include some type of vertical refresh | |
266 | synchronization, such output will look terrible. | |
267 | ||
268 | If stuck in this situation, changing the output of WolframAutomata to scroll | |
269 | horizontally may help, or simply increasing the cell size. | |
270 |