/* TODO: Check manpage for all functions I use and ensure my includes are correct. I don't want to depend on picking up includes via screenhack.h. */
/* TODO: Verify everything in this file is C89. Get rid of things like '//' comments, pack all my declarations upfront, no stdint, etc. */
-/* TODO: Tabs -> Spaces before each commit. */
#include "screenhack.h"
// TODO: Explain that this holds the whole evolution of the CA and the actual displayed visualization is simply a snapshot into this pixmap.
Pixmap evolution_history;
- size_t num_generations;
// TODO: Explain all of these.
unsigned long fg, bg;
/* Misc Commandline Options */
int pixel_size; /* Size of CA cell in pixels (e.g. pixel_size=3 means 3x3 pixels per cell). */
int delay_microsec; /* Requested delay to screenhack framework before next call to WolframAutomata_draw(). */
+ int num_generations; /* Number of generations of the CA to simulate before restarting. */
/* Expository Variables - Not strictly necessary, but makes some code easier to read. */
size_t number_of_cells;
state->number_of_cells = state->xlim / state->pixel_size;
+ /*
+ * The minimum number of generations is 2 since we must allocate enough
+ * space to hold the seed generation and at least one pass through
+ * WolframAutomata_draw(), which is where we check whether or not we've
+ * reached the end of the pixmap.
+ */
+ state->num_generations = get_integer_resource(state->dpy, "num-generations", "Integer");
+ if (state->num_generations < 0) state->num_generations = 2;
+
// TODO: These should be command-line options, but I need to learn how the get_integer_resource() and similar functions work first.
state->display_info = True;
state->ruleset = 30;
- state->num_generations = 3000; // TODO: Enforce that this is >1 in order to hold the seed generation and at least one pass through WolframAutomata_draw(), which is where we check for a full pixmap.
state->current_generation = calloc(1, (sizeof(*(state->current_generation))*state->number_of_cells)); // TODO: Check calloc() call TODO: Can't recall precedence; can I eliminate any parenthesis?
// TODO: Make the starting state a user-configurable option. At least give the user some options like 'random', 'one-middle', 'one edge', etc.
".background: black",
".foreground: white",
"*delay-usec: 2500",
- "*pixel-size: 1", // TODO: Difference between dot and asterisk? Presumably the asterisk matches all resouces of attribute "pixelsize"?
+ // TODO: Difference between dot and asterisk? Presumably the asterisk matches all resouces of attribute "pixelsize"? Apply answer to all new options.
+ "*pixel-size: 2",
+ "*num-generations: 5000",
0
};
static XrmOptionDescRec WolframAutomata_options[] = {
{ "-delay-usec", ".delay-usec", XrmoptionSepArg, 0 },
{ "-pixel-size", ".pixel-size", XrmoptionSepArg, 0 },
+ { "-num-generations", ".num-generations", XrmoptionSepArg, 0 },
{ 0, 0, 0, 0 }
};