home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / cellsim / v2_5 / doc / cell.doc next >
Encoding:
Text File  |  1990-02-26  |  44.8 KB  |  1,132 lines

  1.  
  2.  
  3.                        Documentation for Cellsim v2.5
  4.                                February 17, 1990
  5.  
  6.  
  7.            ****************************************
  8.                  NOTE
  9.   This file mainly discusses the SunView part of Cellsim.  The Connection
  10. Machine is mentioned only when describing the various CM menus in the
  11. SunView tool.  For information on the CM side of Cellsim, read the
  12. "CM.doc" file.
  13.  
  14.            ****************************************
  15.                    SUMMARY
  16.  
  17.   The Cellsim package is a cellular automaton simulator which runs on
  18. Sun-3, Sun-4 and Sparc workstations (and possibly Sun-2's), with either color
  19. or monochrome display.
  20.  
  21.   In the current version, Cellsim allows the user to choose up to 256 states
  22. per cell, up to a 512 x 512 array of cells, and a choice of various types
  23. of neighborhoods.  It also lets you attach to a Connection Machine through
  24. the network, which gives you very fast CA updates.
  25.  
  26.  
  27.  
  28.  
  29.            ****************************************
  30.              USING THE SIMULATOR
  31.  
  32.  
  33.  
  34.            ****************************************
  35.              COMMAND LINE OPTIONS
  36.  
  37. The simulator may be invoked with a number of different options.
  38.  
  39.   The following command line options are available:
  40.  
  41.      B        Run in black & white mode.
  42.  
  43.      b<number>    Sets the array size to <number>, where <number> is 64,
  44.         128, 256, or 512.  (Default is 64.)
  45.  
  46.      v<number>    Sets the neighborhood type to von-Neumann (5-neighbor, 2-d),
  47.         and sets the number of states per cell: <number> may be 2,
  48.         4, 8, 16, or 256.  (Default is 8.)
  49.  
  50.      m<number>    Similar to v, but sets neighborhood type to Moore (9-neighbor,
  51.         2-d); <number> may be 2, 4, 8, or 256.
  52.  
  53.      M<number>  Similar to v and m, but uses the Margolus neighborhood
  54.         (4 spatial neighbors, 2-d, and 1 phase neighbor); <number>
  55.         may be 2, 4, 8, 16, or 256.
  56.      
  57.      l<number>    Similar to v, but sets neighborhood type to linear (1-d).
  58.         By default this includes one cell on each side of the current
  59.         cell, but this may be altered using the `r' option below;
  60.         <number> may be 2, 4, 8, 16, or 256.
  61.  
  62.      r<number>    Sets the radius of the 1-d neighborhood.  <number> may be 1,
  63.         2, or 3; the default is 1.  This option is ignored if the
  64.         neighborhood is not linear.
  65.  
  66.      P<number>    When this option is invoked, the program will set up a socket 
  67.                 connection to receiving port <number>, and send an array of
  68.         state counters to the receiving program at each time step.
  69.         (Sample programs which utilize this feature can be found in
  70.         the "socket" directory.)
  71.  
  72.      H<name>    Used with P if the desired port is on a different host than
  73.         the host on which "cell" is running.  <name> is the name of
  74.         the desired host.
  75.  
  76.      C<name>    Specify the name of a Connection Machine front-end (CMFE).
  77.         This hostname will be used when you select the "Connect"
  78.         item from the "CM" menu.
  79.  
  80.      p<number>    The port-number to use when connecting to the CMFE.
  81.  
  82.     The options may appear in any order.  Also, any or all options may be
  83. omitted on the command line.  
  84.  
  85.     In addition, Sunview frame arguments can be passed in through the command
  86. line to set such things as the position of the window;  see Sunview
  87. documentation for more details.  Note that since Cellsim uses a colormap with
  88. 256 entries, frame-color arguments will have unusual and/or unpredictable
  89. results.
  90.  
  91.  
  92.  
  93.  
  94. COMMAND LINE EXAMPLES: 
  95.  
  96.   The following assume that you have changed the name of the binary version
  97. you wish to run from "cell.sun3" (Sun-3 binary) or "cell.sun4" (Sun-4/Sparc
  98. binary) to "cell".
  99.   
  100.  
  101.   cell
  102.  
  103.      This will set up a 64x64, 2D cellular array with 8 states per cell using
  104.      the von Neumann 5-cell neighborhood. This is the default simulator and
  105.      is equivalent to typing "cell v8 b64".
  106.      
  107.   cell b256 m256 B
  108.      
  109.      This will set up a 256x256, 2D cellular array with 256 states per cell
  110.      using the Moore 9-cell neighborhood, and run in black & white mode.
  111.  
  112.   cell b128 l4 r3 Hhawk P1200
  113.  
  114.      This will set up a length 128, 1D cellular array with 4 states per cell
  115.      using a linear neighborhood of radius 3. The simulator will use a 128x128
  116.      display, displaying a time trace in the vertical direction, and will send
  117.      state counts to port #1200 on machine `hawk'.
  118.  
  119.   cell M4 b128 Ccmfe.lanl.gov
  120.  
  121.      This will set up a 128x128 2D array, using the Margolus neighborhood
  122.      with 256 states per cell, and will try to connect to the CMFE host
  123.      "cmfe.lanl.gov" if you select "Connect" from the "CM" menu.
  124.  
  125.  
  126.            ****************************************
  127.               SIMULATOR COMMANDS
  128.  
  129.   The following commands are available.  Each section below corresponds to a 
  130. button on the control panel.  Each button in turn has a pullright menu which
  131. may contain several items; the items, if they exist, are listed separately
  132. in that section.
  133.  
  134.   Also, several of the commands require input.  There are two different
  135. methods used to obtain the parameters:
  136. - Some of the items will prompt you for the necessary input.  Examples of
  137.   this are loading and saving files (Images, Lookup Tables, etc).
  138. - Other items do not prompt you for parameters, unless you first click on
  139.   the "Set" button.  This is so that, after you have set the parameters
  140.   once, you may then re-select that item later and use the same values for
  141.   the parameters as last time.
  142. Items that require you to use the "Set" button to set their parameters
  143. are marked with a '*'.
  144.  
  145.   Mouse button usage in the control panel:
  146. - Click the LEFT mouse button over a button in order to select the FIRST
  147.   item in that button's menu.  The first item in the menu is usually the
  148.   most commonly used item.
  149. - Click the RIGHT mouse button over a button in order to display the popup
  150.   menu, to select an item (release the right mouse button over the item
  151.   you want).
  152. - Click the MIDDLE mouse button over a button to re-select the last item
  153.   that you selected (using the RIGHT mouse button) from that menu.
  154.  
  155.  
  156. Run: Run the automaton.  
  157.  
  158. << NOTE! This command will not work until you have loaded a specific
  159.    transition function or object file! See the description of the
  160.    "Rule" menu below. >>
  161.  
  162.   For all except the last 3 items, this command is terminated by
  163.   pressing the left mouse button, anywhere in the CA window; all other
  164.   input to the CA is ignored.  The run will stop and display an
  165.   appropriate message if an undefined neighborhood is encountered.
  166.     
  167.   Menu Options:
  168.  
  169.     Run ----------- run continuously, displaying every step.
  170.  
  171.     Skip* --------- prompt for integer N, then run displaying every Nth
  172.             step.  N may be 0, in which case no display occurs;
  173.             this is the fastest run mode available.
  174.  
  175.     Bounded* ------ prompt for integer b, then run one step at a time,
  176.             stopping after b steps.
  177.  
  178.     Skip/Bounded* - combination of Skip and Bounded.
  179.  
  180.     Run/local ----- run the rule locally (on the Sun), when attached
  181.             to the CM.  (When attached to the CM, the "Run"
  182.             item will run the rule on the CM.  "Run/local"
  183.             lets you run things locally instead, without
  184.             having to detach from the CM).
  185.  
  186.     Screenful ----- gives one screenful of display, then stops (mainly
  187.             intended for use in 1-d mode).
  188.  
  189.     Step ---------- do a single step of the automaton. If undefined 
  190.             neighborhoods are encountered, they are displayed
  191.             and the user is given an opportunity to define them.
  192.  
  193.     Skip* ---------- prompt for integer n, then do n steps and stop.
  194.             Will stop and display error message if an undefined 
  195.             neighborhood is found.
  196.  
  197.  
  198. Defaults: Alter some default parameter or behavior of Cellsim.
  199.  
  200.   The first four items under this menu ("image", "Rules", "Cmap", and "CM")
  201. each pop up a new window, which has various items in it to allow you to
  202. adjust the behavior of Cellsim.  When one of these new windows pops up,
  203. you can actually leave the window open off to the side somewhere, or click
  204. on the "Done" button near the bottom of the pop-up window to hide it again.
  205.   The four popup windows, and the items they contain are as follows:
  206.  - "Image" : Defaults related to loading/saving images
  207.      "Save in:"
  208.     toggles whether to save images in the current working directory
  209.     (the default when invoking Cellsim), or to save them in the
  210.     "Image-dir" directory.
  211.      "Save:"
  212.     toggles whether or not to save images in compressed form.  The
  213.     default is to save them compressed.
  214.      "Image-dir:"
  215.     this text-item holds the name of the Image-directory.  When loading
  216.     images, if a file can't be found in the current working directory,
  217.     the Image-dir will be searched as well.  Also, images will be saved
  218.     in the Image-dir, if you've enabled it as described above.
  219.      "Auto-change:"
  220.     Whether or not to automatically change the current image-size
  221.     upon loading an image, based on the filename extension of that
  222.     image.  Recommended filename extensions are discussed later on in
  223.     this file.  For example, when auto-change is enabled (the default),
  224.     then if you load "heat.64x" the image-size will be set to 64,
  225.     regardless of what it is right now.  If the image-size was already
  226.     64, it wouldn't be changed.
  227.     Note that changing the image-size clears out all buffers and the
  228.     current image.
  229.     If you'll be working with image-files that don't have the suggested
  230.     filename extensions, then you should disable auto-change.
  231.      "Done"
  232.     clicking on this button erases the Image-defaults popup window.
  233.  
  234.  - "Rule" : Defaults related to loading/saving rules
  235.      "Save in:"
  236.     whether to save lookup tables (LTs) in the current working directory
  237.     or the Table-directory.
  238.      "Save:"
  239.     whether to save LTs in compressed format or not (the default is to
  240.     save them in compressed form).
  241.      "Table-dir:"
  242.     the value of the Table-directory.  When loading LTs, if the file
  243.     cannot be found in the current directory, it will be looked for
  244.     in the Table-dir.  You can also have Cellsim save LTs in the
  245.     Table-dir, as mentioned above.
  246.      "Fcn-dir:"
  247.     when 256-state update-function files (".o", or object-code files)
  248.     cannot be found in the current directory, they will be looked for
  249.     in this directory.
  250.     Since you can't save ".o" files from within Cellsim, the value
  251.     of Fcn-dir is only used when loading rules.
  252.      "Auto change:"
  253.     whether or not to automatically change neighborhoods/number of states
  254.     when loading a rule.  For example, if auto-change is enabled, then
  255.     when you load "life.m2", Cellsim will automatically switch into
  256.     the 2-state Moore neighborhood, if it's not in that configuration
  257.     already.
  258.     Note that change neighborhoods and/or number of states has the
  259.     following effects:
  260.       - the lookup-table is cleared
  261.       - the current image is AND'ed with a mask so that the image will
  262.         have legal values.  That is, if you switch from a 4-state into
  263.         a 2-state neighborhood, all the cells will be AND'ed with a mask
  264.         so their values will all be 0 or 1.
  265.      "Done"
  266.     clicking on this button will erase the Rule-defaults popup window.
  267.  
  268.  - "Cmap" : defaults related to loading/saving colormaps
  269.      "Save in:"
  270.     whether to save colormaps in the current working directory or
  271.     in the Cmap-directory
  272.      "Save:"
  273.     whether or not to save colormaps in compressed form (true by default).
  274.      "Cmap-dir:"
  275.     the value of the Cmap-dir.  When loading a colormap, this directory
  276.     will be searched when a colormap can't be found in the current
  277.     directory.
  278.     You can also have Cellsim save any colormaps in the Cmap-dir, as
  279.     mentioned above.
  280.  
  281.  - "CM" : defaults related to using the Connection Machine
  282.      "CMFE host:"
  283.     the hostname or number of the Connection Machine Front End (CMFE)
  284.     to attach to.  This is an address of the form "cmfe.your.edu"
  285.     or "128.129.130.131".
  286.      "CMFE port:"
  287.     the port number to connect to on the CMFE.  By default, Cellsim
  288.     uses port # 12700.  You can change that, but you must also tell
  289.     the daemon on the CMFE to use a different port if you decide to
  290.     change it.
  291.      "Run delay:"
  292.     Miracle of miracles, we have a computer that sometimes runs too fast!
  293.     Sometimes, when you're watching something run on the CM's Frame Buffer
  294.     (CMFB), it's too fast to really see what's happening.
  295.     This slider controls a delay between time-steps; if you increase
  296.     the value, things will run more slowly.  On a Sun front-end, this
  297.     value is the number of microseconds to pause between steps.  On a
  298.     Vax front-end, there isn't a microsecond ("usleep") routine in the
  299.     C library; I haven't yet written my own, so for now the Vax will
  300.     spin in a loop for an amount of time proportional to this value.
  301.     But the value won't necessarily be the number of microseconds, on
  302.     a Vax front-end.
  303.      "Display on:"
  304.     This item has 2 sub-items which you can toggle: "CM Frame-buffer"
  305.     and "Sun display".  These toggle whether or not to use the specified
  306.     display when running stuff on the CM.  If you disable the Sun display,
  307.     then you won't see images on the Sun after you've run unless you
  308.     explicitly "Get image" from the "CM" menu in the control-panel.
  309.     When you've enabled the Sun display, the various run commands will
  310.     pretty much behave as they usually do, except when it comes time
  311.     to display an image, the CM will have to send it to the Sun through
  312.     the socket, which is generally **very** slow.  Usually, you should
  313.     only send very few images (e.g. every 100 or 500 or 1000 frames),
  314.     by using the "skip" command.  "Skip" and "Skip/bound" tend to be
  315.     the most common methods of running when using a CM remotely, where
  316.     you don't have access to the frame-buffer.
  317.     Note that the "Run" command behaves differently than usual when you've
  318.     enabled the Sun display and are running on the CM.  Rather than
  319.     displaying every frame, the CM will run without displaying anything
  320.     on the Sun (but it will display frames on the CMFB, if enabled),
  321.     until you click the left mouse button to stop running.  At that time,
  322.     the final image will be sent back to the Sun to be displayed.
  323.     You can enable either, both, or neither of the two displays.
  324.      "Image-dir:"
  325.     When you try to load an image from the CMFE disk into the CM, first
  326.     the directory which the daemon was started in will be searched, and
  327.     then the "Image-dir" will be searched.  Note that this is a *different*
  328.     Image-dir than the one used to search for local images; this one is
  329.     used when loading images directly into CM memory.
  330.      "Fcn-dir:"
  331.     Similary for loading CM C/Paris computed-function files.
  332.      "LT-dir:"
  333.     And for loading lookup-tables into CM memory.
  334.      "Zoom factor:"
  335.     This is the magnification level, if you are using the CMFB.  (It has
  336.     no effect if you are not using a CMFB).  When you move the slider,
  337.     the image gets larger or smaller in real-time.  (The CMFB has hardware
  338.     to do zooming, so it doesn't get slower when it gets bigger, unlike
  339.     the Sun).
  340.      "X pan: and "Y pan:"
  341.     These are translational offsets for the image on the CMFB.  Note that
  342.     they work backward from the way you might expect.  Increasing the
  343.     X pan, for example, shifts the image to the *left*, and increasing
  344.     the Y pan shifts the image ???.  (This is the way the CMFB software
  345.     works, I didn't implement it that way).
  346.      "Done"
  347.     clicking on the "done" button will remove the CM-defaults popup window.
  348.  
  349.   There are also three "normal" menu-items in the "Defaults" menu (that is,
  350. they don't bring up popup windows).  They are:
  351.     Change nhood / #states --- This allows you to enter a neighborhood
  352.             specification string in the same form as the
  353.             command-line arguments, e.g. "v8" or "l256r2" and so
  354.             on.  Note that changing the neighorhood or # of states
  355.             clears the lookup-table, and applies each cell in
  356.             the current image to an "AND" mask, to make sure each
  357.             cell's value is in the new legal range.
  358.     Change image-size ---- change the size of the image, which you will
  359.             be prompted for.  Currently, valid image-sizes are
  360.             64, 128, 256, and 512.  When the image-size is changed,
  361.             the current image is cleared, as well as all of the
  362.             buffers!!  Don't forget that; if you have an image in
  363.             a buffer that you want to keep, first save it to a
  364.             file, and then after changing sizes, load/resize it
  365.             again.
  366.     Change working directory ---- this allows you to change the current
  367.             working directory from within Cellsim.
  368.  
  369.  
  370. Image:    Manipulate the current array of cells in various ways. 
  371.  
  372.   Note that some of these commands also involve the image array, a
  373.   backup array which is used during automaton steps to store the
  374.   previous generation.
  375.         
  376.   Menu Options:
  377.     
  378.     Load ---------- load the current array from a disk file.
  379.  
  380.     Save ---------- save the current array to a disk file.  If enabled,
  381.             images will be saved in compressed format.
  382.  
  383.     Load/Resize --- load current array, from a file of a different size
  384.             than the current array size.  Also prompts for an
  385.             offset, which is the position in the larger array
  386.             corresponding to the origin of the smaller array;
  387.             the default is to center the smaller array.
  388.  
  389.     Save/Resize --- analogous to Load/Resize.
  390.  
  391.     Save/Raster --- save the current array into a file in Sun raster
  392.             format.  The image can then be printed using one
  393.             of the various public-domain Sun raster -> PostScript
  394.             conversion programs available.
  395.  
  396.             Note that when Cellsim is being run in color, the
  397.             raster will have the current colormap as its
  398.             colormap; you will have to run the image through
  399.             the "rasfilter8to1 (1)" program (see the man-page)
  400.             if you want to print it on a monochrome printer.
  401.  
  402.             If you dump the image while running Cellsim in
  403.             black & white mode, then the current "colormap"
  404.             (texture settings) will be used.  Also, when you
  405.             dump the image in black & white mode, the saved
  406.             image will be magnified by the same amount as the
  407.             current image; this is because the textures look
  408.             different at different magnifications, as part of
  409.             the textures get "chopped off" at low magnifications.
  410.             In color, the current magnification has no effect
  411.             on the dumped raster file.
  412.  
  413.     Load/CAM6 ----- load an image that is in CAM6 format.
  414.  
  415.     Save/CAM6 ----- save the current array to a file in CAM6 format.
  416.  
  417.     Enter* --------- clear array and accept a row of sites from the
  418.             keyboard which will be centered as the initial
  419.             configuration.
  420.  
  421.     Clear --------- clear the current array.
  422.  
  423.     Swap ---------- exchange the current and image arrays.
  424.  
  425.     Copy ---------- copy the current array into the image array.
  426.  
  427.     Invert -------- invert the current array (bitwise inversion).
  428.  
  429.  
  430. Rules:    Items related to the lookup-table/update-function
  431.  
  432.   Menu Options:
  433.  
  434.     Load ---------- load in a rule (an LT or obj-code file).
  435.  
  436.     Save ---------- save the LT to a disk file (you cannot save
  437.             computed-function rules from Cellsim).  The
  438.             LT will be saved in compressed form, if that
  439.             option is currently enabled.
  440.  
  441.     Clear --------- set all LT values to "undefined" (no effect when
  442.             using 256 states).
  443.  
  444.     Alter --------- alter an individual value in the LT.
  445.  
  446.     Symmetry ------ set or unset transition rule symmetry.  If enabled, all
  447.             rules entered by the user through Learn, Alter, or 
  448.             "undefined neighborhood" (but NOT through loading 
  449.             transition files) are assumed to be rotation-
  450.             symmetric. Enabled by default.
  451.  
  452.     Generate ------ for use with 1-d, 2-state, r=1 neighborhoods.  
  453.             Given a decimal integer from 0 to 255, will generate
  454.             the corresponding transition rule according to
  455.             Wolfram's numbering scheme. For instance, rule
  456.             number 56 (binary 00110110) would be:
  457.  
  458.             nhood:   111 110 101 100 011 010 001 000
  459.             result:   0   0   1   1   0   1   1   0
  460.  
  461.     Lambda* ------- Use the lambda parameter, as described in Chris
  462.             Langton's article "Studying Artificial Life with
  463.             Cellular Automata" (Physica 22D, 1986), and generate
  464.             a lookup-table based on that setting.
  465.             Lambda is essentially a parameter which describes
  466.             how "full" the table is; it is the percentage of
  467.             entries in the table which are non-zero.  Thus, if
  468.             you set lambda to 20, a random lookup table will be
  469.             generated, in which 20% of the table entries are
  470.             non-zero, or 20% of the possible neighborhoods will
  471.             go to a non-zero state.  This corresponds to a
  472.             lambda value of 0.20 in Langton's article.  Some of
  473.             the most interesting behavior occurs when lambda
  474.             is between 20 and 30; this is when the table is
  475.             full enough that a random initial configuration
  476.             often will not settle down to a fixed value, yet not
  477.             so full that the array would stay very random.
  478.             When the table is generated, the current value of
  479.             the "symmetry" flag (which you can toggle from the
  480.             Trans menu) is examined; thus, you can generate
  481.             symmetric or non-symmetric tables with lambda.
  482.  
  483.     Lambda step* -- "Step" through the lambda parameter space.  This
  484.             requires a parameter n, which can be positive or
  485.             negative.  If n is positive, then n transitions
  486.             in the LT that currently go to zero will be replaced
  487.             by non-zero transitions (the new state to go to is
  488.             picked at random, evenly distributed among the
  489.             non-zero states).  If n is negative, then n
  490.             transitions that currently go to non-zero values will
  491.             be replaced by zero transitions.
  492.  
  493.     Rho* ---------- Similar to lambda, but more generalized.  Instead of
  494.             entering just one parameter, you enter S-1 of them,
  495.             where S is the number of states per cell.
  496.             For example, if you are running with the "v4"
  497.             neighborhood, and select "rho set", you will be
  498.             prompted to enter 3 percentages.  If you enter
  499.             "20 10 12" for example, then a random lookup table
  500.             will be constructed in which 20% of the entries go
  501.             to state 1, 10% of the entries go to state 2, 12%
  502.             of the entries go to state 3, and the remaining 58%
  503.             will go to state 0.
  504.             Rho also looks at the symmetry flag when
  505.             constructing the lookup table.
  506.  
  507.     Edit parm1 ---- Alter the value of the global "parm1" parameter
  508.             which gets passed to your update-function when
  509.             using 256 states.
  510.  
  511.     Edit parm2 ---- Similar to parm1, but for the second parameter.
  512.  
  513.     
  514. Buffer:    Manipulate image buffers in various ways.  
  515.  
  516.   Image buffers are extra memory arrays which can store an array for 
  517.   future use.  Currently there are nine buffers available, numbered 1 
  518.   through 9.  The "image array" (described in Image above) is also
  519.   available to these commands as buffer 0.
  520.  
  521.   Menu Options:
  522.         
  523.     Load ---------- load the current array from the given buffer.
  524.       
  525.     Save ---------- copy the current array into the given buffer.
  526.       
  527.     Swap ---------- exchange the current array and the given buffer.
  528.       
  529.     Xor, Or, And -- perform a bitwise operation between the current array
  530.             and the given buffer, and let the result be the
  531.             new current array.
  532.  
  533.  
  534. Clear: Clear out the 'current' displayed array, or set the time-value to zero.
  535.  
  536.   Menu Options:
  537.  
  538.     Array --------- Clear out the 'current' displayed array.
  539.  
  540.     Zero time ----- Set the current "time" value to zero.
  541.  
  542.  
  543. Learn:    Derive transition rules from a sequence of images by running the CA in 
  544.     `reverse', using the images to derive rules rather than using the 
  545.     rules to derive images. 
  546.  
  547.     This function is invoked as follows:
  548.  
  549.       1.  Construct a `before' array, and Copy it into the `image' array.
  550.           (See options for Image command above.)
  551.  
  552.       2.  Construct an `after' array, and leave it in the `current'
  553.           array.
  554.  
  555.       3.  Invoke the Learn command.  
  556.     
  557.         This procedure will derive the necessary transitions such that
  558.       one step of the automaton will change the `before' array into the
  559.       `after' array.  If this involves redefining a previously defined
  560.       transition, a prompt will appear offering the user a choice as to
  561.       whether the change should be made.
  562.           
  563.             At the end of this command, the `after' array will be copied
  564.       into the image array.  The `before' array is destroyed.  This is 
  565.       so that one may perform several Learn commands in succession solely
  566.       by altering the `current' array and invoking Learn.
  567.  
  568.         Note that the Learn command does not work when you are using
  569.       256 states (computed-function updating); "Learn" has no meaning
  570.       except when using lookup-tables for updating.
  571.  
  572.  
  573. Set: Set a parameter when calling some other function.
  574.  
  575.     Simply click the "Set" button before selecting another item
  576.     (such as "Skip" under the "Run" menu) that requires you to
  577.     set a parameter.
  578.   
  579.  
  580. Zoom:    Changes the magnification of the displayed image.  
  581.  
  582.   The size of the display is determined by the `zoom factor' Z, which
  583.   means that each cell is displayed as a square of Z pixels on a side.
  584.   Note that a smaller zoom factor will give faster running speed, but
  585.   at the expense of making other functions - such as display
  586.   editing - more difficult.
  587.  
  588.   Menu Options:
  589.  
  590.     Toggle -------- if display is full-size, set zoom factor directly to 1;
  591.             otherwise set to full size.
  592.  
  593.     Magnify ------- prompt for an integer z which becomes the new zoom
  594.             factor.
  595.  
  596.  
  597. Closeup: Enter or exit closeup mode.  
  598.  
  599.            When in closeup mode, the center 32x32 of the array is magnified to 
  600.            take up the entire window.  Particularly useful when editing larger 
  601.            arrays. Note that while in closeup mode, Zoom:Toggle is allowed but 
  602.            Zoom:Magnify is not.  In 1-D mode, an area on the bottom row of
  603.        the array is magnified, so that you can see the current generation.
  604.  
  605.     
  606. Zoom in/Zoom out:  Adjusts the current magnification.
  607.  
  608.       Zoom in will increase the magnification by one, unless it
  609.       is currently at the maximum.  Zoom out will descrease the
  610.       magnification by one, unless it is already at the minimum (1).
  611.  
  612.     
  613. Draw: Various functions useful for generating images, such as random
  614.       images, lines, and circles.
  615.  
  616.   Menu Options:
  617.         
  618.     Quick random -- randomize entire array, with an equal number of cells
  619.             of each value.  So for example, using a 4-state
  620.             neighborhood, 25% of the cells get value 0, 25% get
  621.             value 1, and so on.
  622.  
  623.     General random* -- this is a much more general random-image generator.
  624.             You will be prompted for the origin of the rectangle
  625.             to change (enter x and y coordinate), the size of
  626.             the rectangle to change (width and height), the
  627.             percentage of cells to change, and the minimum and
  628.             maximum values to set the affected cells to.
  629.             For example, if you enter "5 10" for origin, "20 33"
  630.             for size, "12" for percent, and "2 5" for min/max
  631.             values, then a 20x33 rectangle of cells, with its
  632.             upper-left corner at (5,10) will be affected.  12%
  633.             of the cells will be set to a random value between
  634.             2 and 5, inclusive.  Note that the other 88% of the
  635.             cells will NOT be changed (they will not be zeroed
  636.             out).
  637.             As another example:  if you want to change 20% of the
  638.             cells in a 64x64 array to a value of 2, use an origin
  639.             of "0 0", size of "64 64", percentage of "20", and
  640.             min/max values of "2 2".
  641.  
  642.     
  643. Color:    Allows various manipulations of the color map.  
  644.  
  645.           Colormap items in this program are stored as 6-digit hex values, 
  646.           consisting of 2 digits each for red, green, and blue components 
  647.           (in that order).
  648.       Note that in black & white mode, textures are used instead
  649.       of colors.  The colormap items are used as indices into the
  650.       array of textures.  For example, if entry 2 in the colormap
  651.       table has a value of 5, then cells with a value of 2 will
  652.       be displayed using texture #5.
  653.  
  654.       Also note that currently, in black & white mode, when the image
  655.       is being displayed at a magnification level of 1, all non-zero
  656.       cells are displayed using black, while cells of value zero are
  657.       displayed as white (unless you are running suntools in inverse
  658.       mode, in which case the situation is reversed); this is to increase
  659.       the speed of the simulation.  The colormap has no effect on this.
  660.       At magnifications greater than 1, the colormap has the effect
  661.       described above.  This only applies when running in black & white
  662.       mode; in color, the colormap is used at all magnifications.
  663.  
  664.   Menu Options:
  665.         
  666.     Load - load a previously saved colormap from a file.
  667.       
  668.     Save - save the current colormap to a file.
  669.       
  670.     Alter - alter an entry in the current colormap.
  671.  
  672.     
  673. Planes:    Allows various bitplane manipulations.  
  674.  
  675.     All of these commands (except for Reset) prompt for a plane mask,
  676.     which should be in hexadecimal, the bits of which specify the
  677.     planes to be affected.  For instance, a mask of 2 (0010) denotes
  678.     plane 1 only; a mask of 4B (01001011) denotes planes 0, 1, 3,
  679.     and 6; and so forth.
  680.  
  681.   Menu Options:
  682.         
  683.     Reset - reset display to show all bitplanes.
  684.  
  685.     Display - display only those bitplanes in the given mask.
  686.  
  687.     Clear - clear the given planes.
  688.  
  689.     Invert - invert the given planes.
  690.  
  691.     
  692. CM: Connection Machine routines
  693.  
  694.   See the "CM.doc" file for more information about using Cellsim
  695.   with a Connection Machine.
  696.  
  697.   Menu Options:
  698.  
  699.     Connect to CM - Connect to the Connection Machine Front End (CMFE).
  700.             There must be a daemon process running on that
  701.             CMFE, waiting to accept connections and to attach
  702.             to the CM.
  703.  
  704.     Send image ---- Send the local image (in the 'current' array)
  705.             to the CM.
  706.  
  707.     Get image ----- Get the image currently on the CM, and bring it
  708.             to the Sun as the 'current' array.
  709.  
  710.     Send LT ------- Send Lookup Table to CM (not valid when using
  711.             256 states).
  712.  
  713.     Send cmap ----- Send colormap to the CM, to be used when displaying
  714.             images on the CM frame-buffer
  715.  
  716.     Disconnect ---- Detach from the CM, and disconnect from the CMFE.
  717.             The daemon on the CMFE will resume waiting for a
  718.             client.
  719.  
  720.     Load remote image -- Load an image into the CM array, from the
  721.             CMFE disk.  (The image will not be sent to the
  722.             Sun unless you explicity request it).
  723.  
  724.     Load remote Rule --- Load an LT or object-code file from the
  725.             CMFE disk, into memory on the CM.
  726.  
  727.     Clear CM array ------ Clear out the array on the CM
  728.  
  729.     CM quick random ---- Quick random, which executes on the CM
  730.             instead of on the Sun.
  731.  
  732.     CM general random* -- General random for the CM.
  733.  
  734.  
  735.  
  736. Sequence: Construct and invoke user-defined sequences of actions
  737.  
  738.   You can construct commonly-used sequences of commands.  For example
  739.   if you want to experiment with lambda, you may want to construct
  740.   many different LT's, all with lambda=20, then generate a random
  741.   image, and run for 1000 time-steps.  You could do the following to
  742.   simplify this task:
  743.  
  744.     1. Use "Set" "Rules/Lambda" to set the lambda parameter
  745.     2. Use "Set" "Run/Bound" to set the parameter indicating how
  746.        many steps to run, say 1000.
  747.     3. Click "Set" and then one of the "Sequence" items, say
  748.        "Sequence 2".  This begins defining the sequence.  Everything
  749.        you do now will be added to the sequence.
  750.     4. Click "Rules/Lambda" to generate a new LT using the current
  751.        lambda parameter.
  752.     5. Click "Draw/quick random" to generate a random image.
  753.     6. Click "Run/bounded" to run for 1000 time-steps.
  754.     7. Finally, select "sequence 2" again, to finish defining your
  755.        sequence.
  756.  
  757.   Now, you can just select the "Sequence 2" item to execute everything
  758.   you taught it, namely "lambda -- draw/quick-random -- run/bounded".
  759.  
  760.   Note that if you try to do things like "Image/Load" to load an image
  761.   within a sequence, the image-load function prompts you for a filename.
  762.   Therefore, every time you call your sequence, you will be prompted
  763.   for the filename.
  764.  
  765.   There are 5 user-definable sequences.
  766.  
  767.  
  768. Quit:    Terminates execution of the program.
  769.  
  770.  
  771. Up, Down, Left, Right:
  772.  
  773.   Shift the image in the specified direction. 
  774.          
  775.   The distance shifted is initially 1, but can be reset using the
  776.   Shift button.
  777.       
  778.  
  779. Shift:    Prompts for the shift distance to be used with the direction buttons
  780.     above.
  781.     
  782.     
  783.            ****************************************
  784.         ENVIRONMENT VARIABLES AND DEFAULT DIRECTORIES
  785.  
  786.   Depending on who compiled the version of Cellsim you are running, it
  787. may look in certain default directories for files it cannot find in the
  788. current directory.  Typically, these defaults will be the directories
  789. containing images, transition tables or update rules, and colormaps that
  790. are supplied with Cellsim.
  791.   However, you may wish to change these defaults, or disable them.  This
  792. can be done by setting environment variables before invoking Cellsim.
  793. There are four environment variables that can be used:
  794.      IMAGE_DIR -- Directory in which images will be looked for
  795.      TABLE_DIR -- Transition-table files will be looked for here
  796.      FCN_DIR   -- Update-functions (".o" files) will be looked for here
  797.      CMAP_DIR  -- Directory to search for colormaps
  798.   For example, if you enter "setenv IMAGE_DIR /home/users/joe/Images"
  799. before invoking Cellsim, and then try to load the image "picture.64x",
  800. and Cellsim cannot find that image file in the current directory, it
  801. will then try to load the image in from "/home/users/joe/Images/picture.64x".
  802.  
  803.   Thus, if you have some directories in which you keep your transition
  804. tables, images, and colormaps, you can avoid having to type pathnames
  805. by setting the appropriate environment variables.  They would typically
  806. be set in your .login file, although you can do it manually.
  807.  
  808.   Note that default-directory searching can be disabled, by setting the
  809. environment variables to null values.  For example, if you execute
  810. "setenv IMAGE_DIR", then if an image cannot be found in the current
  811. directory, it will not be looked for anywhere else.
  812.  
  813.            ****************************************
  814.             NEIGHBORHOOD ENCODING
  815.     
  816.   Some of the commands will print out a neighborhood, or ask the user to
  817. enter one.  When this happens, the neighbors should be in the following order,
  818. depending on the neighborhood type in use (c = center, l = left, r = right,
  819. t = top, b = bottom):
  820.  
  821.      VonNeumann:    c, t, r, b, l            (clockwise order)
  822.      Moore:         c, tl, t, tr, r, br, b, bl, l    (also clockwise)
  823.      linear:        left-to-right order, regardless of radius
  824.      Margolus:        c, ccw, opp, cw, phase        (counterclockwise)
  825.  
  826.  
  827.            ****************************************
  828.                DISPLAY EDITING
  829.  
  830.    In addition to the above commands, the user may inspect and alter the
  831. displayed image directly using the mouse. The functions associated with the
  832. mouse buttons depend on the current `mode', which can be changed by clicking
  833. the panel item labeled "Mode".  
  834.  
  835. Three modes are available:
  836.     
  837. Edit:    Allows general editing of the displayed `current' array.
  838.  
  839.     Mouse button functions:
  840.      
  841.           Left ----- Sets the cell under the cursor to a nonzero state.  The
  842.                new state is shown by the color of the cursor, and can
  843.                be changed by keyboard or menu as described below.
  844.             
  845.       Middle --- Erases the cell under the cursor, i.e. sets its state
  846.                to zero.
  847.             
  848.       Right ---- Displays a menu of all nonzero states, and allows the
  849.                user to select a new state for insertions.  Note that
  850.                when using 256 states, the right button has no effect,
  851.                as the menu would be too large to be very useful.
  852.             
  853.       Keyboard - If a key corresponding to a valid nonzero state is
  854.                pressed, this state becomes the new state for
  855.                insertions.  When using 256 states, 2 keypresses
  856.                are required to set the new state, in hexadecimal.
  857.                For example, hitting "c8" will set the state to
  858.                hexadecimal c8 (200 decimal).  Only a single keypress
  859.                is required to set the color when using less than
  860.                256 states.
  861.                
  862.  
  863. Probe:    Allows inspection and alteration of the transition function.  Note
  864.     that none of the probe functions work when using 256 states per cell.
  865.     (This will hopefully be changed in the next release).
  866.  
  867.     Mouse button functions:
  868.  
  869.       Left ----- Displays the states of the cell under the cursor and
  870.                its neighbors, and shows the next state for that cell
  871.                according to the current transition table.
  872.                
  873.       Right ---- Just like the left button, but also displays a menu with
  874.                the option `Alter'.  Selecting this option allows the
  875.                user to alter the corresponding entry in the transition
  876.                table.
  877.                
  878.  
  879. Plane Edit:  Allows editing of a single bitplane at a time.
  880.  
  881.     Mouse button functions:
  882.  
  883.       Left ----- Sets the bit in the cell under the cursor in the plane
  884.             currently being edited.
  885.             
  886.       Middle --- Clears the bit in the current cell and plane.
  887.       
  888.       Right ---- Displays a menu of all planes in use, and allows the
  889.             user to select a new plane to edit.
  890.             
  891.       Keyboard - If the number of a valid plane is pressed,
  892.             that plane becomes the current editing plane.
  893.             
  894.  
  895.    In any mode, whenever the cursor is in the display area, the cursor position
  896. (in terms of array cells) and the state of the cell under the cursor will be 
  897. displayed in the upper portion of the control panel.
  898.  
  899.            ****************************************
  900.             AUTOMATIC TERMINATION OF RUNS
  901.  
  902.    You can have Cellsim automatically stop running, under certain simple
  903. conditions.  Namely, you can have Cellsim stop running when the array becomes
  904. empty, or when there is no change in the array between time-steps (e.g.
  905. the dynamics have settled down to a fixed image).  You can enable either
  906. of these stopping conditions with the "Stop on:" cycle in the control panel.
  907. The three possible values are "never", "no change", and "all zero" (where
  908. "never" means do not automatically terminate running).
  909.  
  910.            ****************************************
  911.                DIFFERENCES FOR 1-D MODE
  912.  
  913.   Since the program was originally designed to handle 2-d arrays, some of the 
  914. commands have slightly different effects when running in 1-d mode.  
  915.  
  916. Major differences include:
  917.  
  918.      - The `current' array is considered to be the bottom line of the display
  919.        (rather than the entire display as in 2-d mode).  The remaining lines
  920.        of the display are used to keep a time history of the 1D array.
  921.        
  922.      - The Step and Skip commands shift the time history up one step and place
  923.        the next generation in the bottom line.
  924.        
  925.      - The Screenful command moves the bottom array to the top and does as
  926.        many steps as will fit on one screen, leaving the final generation on
  927.        the bottom line.
  928.        
  929.      - The Run commands (Run, Skip, Bounded, Skip/Bounded) are implemented by
  930.        doing repeated Screenfuls, rather than repeated Steps. They are
  931.        otherwise identical to their 2-d mode functions.
  932.        
  933.      - The Load, Save, Load/Resize, Save/Resize, and Enter commands affect
  934.        only the bottom line of the display.  (Because of this, files Saved
  935.        in 1-d mode give unexpected results when Loaded in 2-d mode, and
  936.        vice-versa.)
  937.        
  938.      - The Learn command, rather than deriving rules to generate the `current'
  939.        array from the `image' array, derives rules to generate the bottom line
  940.        of the display from the second-to-bottom line.
  941.  
  942.  
  943.            ****************************************
  944.             FILE NAME CONVENTIONS
  945.  
  946.   To demonstrate the operation of this program, several example image and
  947. transition files are included.  The filename suffixes are assigned according
  948. to the following conventions:
  949.  
  950.      ".64", ".128", ".256":
  951.         1-d arrays of the indicated size
  952.         
  953.      ".64x", ".128x", ".256x":
  954.         2-d arrays of the indicated size (meant to suggest 64x64, etc.)
  955.         
  956.      ".v2", ".v4", ".v8", ".v16":
  957.         transition rules for the VonNeumann neighborhood, with 2, 4,
  958.         8, and 16 states per cell respectively
  959.         
  960.      ".m2", ".m4":
  961.         transition rules for the Moore neighborhood, with 2 and 4
  962.         states per cell respectively
  963.         
  964.      ".l2", ".l4", ".l8", ".l16":
  965.         transition rules for the linear neighborhood, with 2, 4, 8, and
  966.         16 states per cell respectively.  By themselves, these denote
  967.         rules of radius 1; larger radii can be denoted by adding "r2"
  968.         and "r3", for example, ".l8r2" for a radius 2 neighborhood
  969.         with 8 states per cell.
  970.  
  971.      ".M2", ".M4", ".M8", ".M16"
  972.         transitions rules for the Margolus neighborhood, with 2,
  973.         4, 8, or 16 states per cell.
  974.  
  975.      ".m256.sun3.o", ".m256.sun4.o", ".v256.sun3.o", .l256.sun4.o",
  976.      ".l256r2.sun3.o", and so on
  977.         object-files which contain an update-function for the
  978.         neighorhood specified in the extension.  The ".m256" are
  979.         for moore neighborhood, and so on.  Note that the ".sun3"
  980.         or ".sun4" part of the extension is not necessary if you
  981.         are only going to be using Cellsim on one particular
  982.         Sun model, e.g. ".m256.o" is a valid extension.
  983.         
  984.      ".cmap":    colormap files with 16 entries (standard colormaps from the
  985.         previous versions of Cellsim).
  986.      ".cmap.256":
  987.         colormap files with 256 entries
  988.  
  989.   We recommend that users adhere to these conventions when creating their own
  990. files, for three reasons: first, to make it easier to keep track of which files
  991. go with which options; second, to facilitate the exchange of transition and
  992. image files between users at different sites; third, because if you use these
  993. conventions, Cellsim will automatically switch into the proper neighborhood
  994. and/or image size when loading a file, if necessary.
  995.  
  996.  
  997.            ****************************************
  998.                  SAMPLE FILES
  999.  
  1000.    Some sample rules and images are supplied with Cellsim.  See the
  1001. file "sample.files" for a partial list of these.
  1002.  
  1003.   We would like to strongly encourage Cellsim users to submit any interesting
  1004. rules they discover, and any images that accompany them.  We would like to
  1005. collect a user-contributed library of rules/images to be distributed with
  1006. later versions of Cellsim.  Images and lookup-tables are most easily submitted
  1007. by compressing them, running them through "uuencode", and then mailing them.
  1008. Rule source-code can just be directly mailed.  Rules and images should be
  1009. sent to the addresses listed below.
  1010.  
  1011.  
  1012.  
  1013.            ****************************************
  1014.                    AUTHORS
  1015.  
  1016.    The SunView version of Cellsim 1.0 was written by Charles Ferenbaugh.
  1017. It was adapted from an earlier Apollo version written by Chris Langton.
  1018.    The changes to bring Cellsim to V1.5 and V2.0 were done by Dave Hiebeler.
  1019.  
  1020. Please send any comments on this code to Chris Langton (cgl@LANL.GOV),
  1021. or Dave Hiebeler (hiebeler@heretic.lanl.gov).
  1022.  
  1023.  
  1024.            ****************************************
  1025.                 GOALS
  1026.  
  1027.   This simulator was developed to serve as a reasonably general, window-based
  1028. tool for experimenting with simple cellular automata. We hope that by putting
  1029. this tool in the public domain, we can provide a means by which researchers at
  1030. a wide variety of sites can experiment with interesting CA rules and images,
  1031. and swap the results among sites. This simulator will not fill everybody's
  1032. needs, nor was it intended to. It was intended to provide what we consider to
  1033. be the minimum necessary functionality to do useful research with cellular
  1034. automata. By providing the source code as well, we hope that researchers will
  1035. expand upon this basic software platform by adding other functions, features,
  1036. and/or speed-hacks.  We have tried to produce code which is reasonably modular
  1037. and well documented so that users should be able to modify the simulator to
  1038. suit their own needs with minimal trouble.
  1039.  
  1040. In the interest of maintaining compatability between versions, we would request
  1041. that anybody who adds a major feature to the simulator send us a copy rather 
  1042. than distributing it themselves. We will make every attempt to integrate any
  1043. and all improvements - with appropriate credit given - into future versions,
  1044. but we would like to do so in a manner which is consistent with our own
  1045. future developmental plans.
  1046.  
  1047. Again, modifications should be sent to cgl@LANL.GOV or
  1048. hiebeler@heretic.lanl.gov.
  1049.  
  1050.  
  1051.            ****************************************
  1052.                  BUGS
  1053.  
  1054.   While in `Run' mode, the program does not respond to SunView frame commands
  1055. such as Close, Move, etc. However, other windows can still be used while the
  1056. program is running an automaton.
  1057.  
  1058.   Also, if the window is hidden and then re-exposed while in Run mode, it
  1059. will not be redrawn completely until the Run is stopped.
  1060.  
  1061.   Transition files are not checked when they are loaded; thus if an improper
  1062. file is loaded, it may cause an invalid state to appear on the screen which
  1063. could cause segmentation faults during subsequent lookups.
  1064.  
  1065.   The speed of updating the display on the Sun is pretty poor when the
  1066. image is magnified.
  1067.   
  1068.   The display plane-mask does not work in B&W mode (it has no effect).
  1069.  
  1070.   "Learn" is not implemented for the Margolus neighborhood.
  1071.  
  1072.   The "Probe" functions do not work when using 256 states (computed-function
  1073. updating).
  1074.  
  1075.   The fact that menus and popup windows don't use the colormap is terribly
  1076. annoying.
  1077.  
  1078.   The CM run-delay needs to be implemented better on Vax front-ends.  Right
  1079. now, how long it delays depends on the speed of the Vax.  What is needed
  1080. is an implementation of the "usleep" routine of Suns.
  1081.  
  1082.   Cellsim should warn you if you change the lookup-table or image, and try
  1083. to run on the CM without sending the changed LT or image.
  1084.  
  1085.   The "stop on" feature doesn't yet work with the Connection Machine.
  1086.  
  1087.            ****************************************
  1088.  
  1089. /*
  1090.  *
  1091.  * Cellsim copyright 1989, 1990 by Chris Langton and Dave Hiebeler
  1092.  * (cgl@lanl.gov, hiebeler@heretic.lanl.gov)
  1093.  *
  1094.  * This package may be freely distributed, as long as you don't:
  1095.  * - remove this notice
  1096.  * - try to make money by doing so
  1097.  * - prevent others from copying it freely
  1098.  * - distribute modified versions without clearly documenting your changes
  1099.  *   and notifying us
  1100.  *
  1101.  * Please contact either of the authors listed above if you have questions
  1102.  * or feel an exception to any of the above restrictions is in order.
  1103.  *
  1104.  * If you make changes to the code, or have suggestions for changes,
  1105.  * let us know!  If we use your suggestion, you will receive full credit
  1106.  * of course.
  1107.  */
  1108.  
  1109. /*****
  1110.  * Cellsim history:
  1111.  *
  1112.  * Cellsim was originally written on Apollo workstations by Chris Langton.
  1113.  *
  1114.  * Sun versions:
  1115.  *
  1116.  * - version 1.0
  1117.  *   by C. Ferenbaugh and C. Langton
  1118.  *   released 09/02/88
  1119.  *
  1120.  * - version 1.5
  1121.  *   by Dave Hiebeler and C. Langton  May - June 1989
  1122.  *   released 07/03/89
  1123.  *
  1124.  * - version 2.0
  1125.  *   by Dave Hiebeler and C. Langton  July - August 1989
  1126.  *   never officially released (unofficially released 09/08/89)
  1127.  *
  1128.  * - version 2.5
  1129.  *   by Dave Hiebeler and C. Langton  September '89 - February 1990
  1130.  *   released 02/26/90
  1131.  *****/
  1132.