Cleaned up CLI flags for cell size in WolframAutomata source code and README.
[screensavers] / hacks / WolframAutomata / WolframAutomata.c
index e84ba44..36f1c05 100644 (file)
@@ -46,9 +46,9 @@ struct state {
     uint8_t rule_number;
 
     /* At the end of the simulation, the user is given time to admire the     */
     uint8_t rule_number;
 
     /* At the end of the simulation, the user is given time to admire the     */
-    /* output. Delay is available to user as CLI option.                      */
+    /* output. Delay is available to user as CLI option '-admiration-delay'.  */
     Bool admiration_in_progress;
     Bool admiration_in_progress;
-    size_t admiration_delay; /* ...in microseconds.                           */
+    size_t admiration_delay; /* ...in seconds.                                */
 
     /* The following values correspond directly to independent CLI options.   */
     Bool    rule_random;
 
     /* The following values correspond directly to independent CLI options.   */
     Bool    rule_random;
@@ -276,7 +276,7 @@ WolframAutomata_init(Display * dpy, Window win)
     state->dpy_height = xgwa.height;
     state->ypos = 0;
 
     state->dpy_height = xgwa.height;
     state->ypos = 0;
 
-    state->admiration_delay = 5000000;
+    state->admiration_delay = get_integer_resource(state->dpy, "admiration-delay", "Integer");
     state->admiration_in_progress = False;
 
     /* Set foreground and background colors for active/inactive cells. Either */
     state->admiration_in_progress = False;
 
     /* Set foreground and background colors for active/inactive cells. Either */
@@ -307,14 +307,14 @@ WolframAutomata_init(Display * dpy, Window win)
     state->gc = XCreateGC(state->dpy, state->win, GCForeground, &gcv);
 
     /* Set the size of each simulated cell to NxN pixels for cell_size=N.     */
     state->gc = XCreateGC(state->dpy, state->win, GCForeground, &gcv);
 
     /* Set the size of each simulated cell to NxN pixels for cell_size=N.     */
-    if (get_boolean_resource(state->dpy, "random-pixel-size", "Boolean")) {
+    if (get_boolean_resource(state->dpy, "random-cell-size", "Boolean")) {
         /* Although we are choosing the pixel size 'randomly', a truly random */
         /* selection would bias toward large numbers since there are more of  */
         /* them. To avoid this, we select a random number for a bit shift,    */
         /* resulting in a pixel size of 1, 2, 4, 8, 16 or 32, equally likely. */
         state->cell_size = 1 << (random() % 6);
     } else {
         /* Although we are choosing the pixel size 'randomly', a truly random */
         /* selection would bias toward large numbers since there are more of  */
         /* them. To avoid this, we select a random number for a bit shift,    */
         /* resulting in a pixel size of 1, 2, 4, 8, 16 or 32, equally likely. */
         state->cell_size = 1 << (random() % 6);
     } else {
-        state->cell_size = get_integer_resource(state->dpy, "pixel-size", "Integer");
+        state->cell_size = get_integer_resource(state->dpy, "cell-size", "Integer");
     }
     if (state->cell_size < 1) state->cell_size = 1;
     if (state->cell_size > state->dpy_width) state->cell_size = state->dpy_width;
     }
     if (state->cell_size < 1) state->cell_size = 1;
     if (state->cell_size > state->dpy_width) state->cell_size = state->dpy_width;
@@ -482,7 +482,7 @@ WolframAutomata_draw(Display * dpy, Window win, void * closure)
             closure = WolframAutomata_init(dpy, win);
         } else {
             state->admiration_in_progress = True;
             closure = WolframAutomata_init(dpy, win);
         } else {
             state->admiration_in_progress = True;
-            return state->admiration_delay;
+            return 1000000 * state->admiration_delay;
         }
     }
 
         }
     }
 
@@ -503,12 +503,13 @@ WolframAutomata_draw(Display * dpy, Window win, void * closure)
 
 static const char * WolframAutomata_defaults[] = {
     "*delay-usec:         25000",
 
 static const char * WolframAutomata_defaults[] = {
     "*delay-usec:         25000",
+    "*admiration-delay:   5",
     "*num-generations:    5000",
     "*num-generations:    5000",
-    "*pixel-size:         2",
+    "*cell-size:          2",
     "*color-index:        -1",
     "*population-density: 50",
     "*population-single:  False",
     "*color-index:        -1",
     "*population-density: 50",
     "*population-single:  False",
-    "*random-cellsize:    False",
+    "*random-cell-size:   False",
     "*random-delay:       False",
     "*random-length:      False",
     "*random-rule:        False",
     "*random-delay:       False",
     "*random-length:      False",
     "*random-rule:        False",
@@ -518,12 +519,13 @@ static const char * WolframAutomata_defaults[] = {
 
 static XrmOptionDescRec WolframAutomata_options[] = {
     { "-delay-usec",         ".delay-usec",             XrmoptionSepArg, 0      },
 
 static XrmOptionDescRec WolframAutomata_options[] = {
     { "-delay-usec",         ".delay-usec",             XrmoptionSepArg, 0      },
+    { "-admiration-delay",   ".admiration-delay",       XrmoptionSepArg, 0      },
     { "-num-generations",    ".num-generations",        XrmoptionSepArg, 0      },
     { "-num-generations",    ".num-generations",        XrmoptionSepArg, 0      },
-    { "-pixel-size",         ".pixel-size",             XrmoptionSepArg, 0      },
+    { "-cell-size",          ".cell-size",              XrmoptionSepArg, 0      },
     { "-color-index",        ".color-index",            XrmoptionSepArg, 0      },
     { "-population-density", ".population-density",     XrmoptionSepArg, 0      },
     { "-population-single",  ".population-single",      XrmoptionNoArg,  "True" },
     { "-color-index",        ".color-index",            XrmoptionSepArg, 0      },
     { "-population-density", ".population-density",     XrmoptionSepArg, 0      },
     { "-population-single",  ".population-single",      XrmoptionNoArg,  "True" },
-    { "-random-cellsize",    ".random-pixel-size",      XrmoptionNoArg,  "True" },
+    { "-random-cell-size",   ".random-cell-size",       XrmoptionNoArg,  "True" },
     { "-random-delay",       ".random-delay",           XrmoptionNoArg,  "True" },
     { "-random-length",      ".random-num-generations", XrmoptionNoArg,  "True" },
     { "-random-rule",        ".rule-random",            XrmoptionNoArg,  "True" },
     { "-random-delay",       ".random-delay",           XrmoptionNoArg,  "True" },
     { "-random-length",      ".random-num-generations", XrmoptionNoArg,  "True" },
     { "-random-rule",        ".rule-random",            XrmoptionNoArg,  "True" },