1Pattern Editing 2--------------- 3 4(Note: the following uses some terminology specific to Life. For definitions, 5see _Winning Ways_ by Berklekamp, Conway, and Guy, or _The Recursive Universe_, 6by Poundstone.) 7 8Overview 9-------- 10The latest revision of Xlife allows more sophisticated editing and maintenance 11of complex patterns. Almost all large Life patterns that exhibit well-defined 12behavior (such as the breeder) are in fact composed of smaller patterns that 13combine in a predictable way. Storing such patterns in a hierarchical manner 14can greatly aid future experimentation as well as synthesis of still more 15complex patterns. This document explains some of the motivation behind the 16new features, and gives several examples of their use. 17 18Goal of New Features 19-------------------- 20It is the goal of the new editing and include features to greatly limit the 21number of Life patterns stored as atomic images (i.e. raw bitmaps or point 22sets). Once a glider gun, for example, has been defined, there should be no 23need to duplicate the pattern. It should instead be possible to refer to it by 24name, as a known mechanism with well-established properties. In fact, the 25glider gun itself exhibits some structure, as it is composed of two period 30 26shuttles that interact to produce gliders. Ultimately, the "interesting" part 27of the period 30 shuttle does not seem to have any structure, and hence must be 28represented a picture, such as the following: 29 30 ..*... 31 .*.*.. 32 *...** 33 *...** 34 *...** 35 .*.*.. 36 ..*... 37 38Unfortunately, it is not enough to merely place such a pattern at the correct 39coordinates. For example, we can rotate this pattern by multiples of 90 40degrees without essentially changing its behavior. While this particular 41pattern has flip symmetry about its horizontal dividing line, other patterns 42may not, so we may additionally wish to take the mirror image of a pattern. 43It would be undesirable to maintain eight separate bitmaps for what is really 44the same pattern, so we would like a facility to perform basic geometric 45transformations on patterns to be included in more complex ones. 46 47A more subtle issue is that of timing. When placed between appropriate 48stabilizing objects (such as eaters or blocks) the above pattern will oscillate 49with a period of 30. Hence, when defining a complex pattern, we may need 50to insist (in addition to any geometric transformations) that it be placed 51within the larger pattern at a particular phase in its cycle. 52 53By controlling position, rotation, flip, and phase shift, we may combine 54patterns in any desired manner. The #I extensions to Xlife make this 55possible, and the new editing features make it (relatively) convenient. 56For specifications of the extended #I format, see the Xlife man page. 57 58Ideally, the new editing features will make it possible to use 59the #I format without ever looking at the description file. The advanced Life 60experimenter may, however, wish to modify #I lines with a text editor in 61order to achieve very specific effects (still more advanced CAD tools would 62eliminate this need). 63 64Examples 65-------- 66 67To attempt the following examples, you should be running Xlife. You must 68have a copy of the file ex.life, supplied with the release, in either the 69directory in which you start up Xlife, or in the pattern directory. 70 71Before trying any of the examples, type 'C' to clear the workspace, if it 72is not already clear. 73 74(1) Experimenting with gun collisions. 75 76Type 'l' to load in a pattern. Backspace over the default directory, if there 77is one (probably the pattern library) and type "ex:gun". This will load the 78pattern "gun" from the file "ex.life" in either the pattern library or current 79directory. The pattern consists of a glider gun before it has produced any 80gliders. 81 82Get a feel for the movement, flip, and rotation operations performed with the 83mouse buttons. All operations are performed with respect to the origin of the 84pattern, which is indicated by a single dot at the smallest scales and becomes 85an X shape at the larger scales (zoom in on it to see this). 86 87In order to place patterns such as glider guns, it is especially important to 88know the direction of the outgoing glider stream. You may preview this 89by generating the loaded pattern with the 'G' command (*not* the 'g' command). 90Initially, you will want to generate enough steps to see the stream, so type 91100 when prompted for the number of steps. 92 93Note that the mouse buttons continue to perform transformations on 94the generated pattern. Place the pattern as desired. It will be incorporated 95into the main universe when any of the commands g, h, o, l, or W are typed. 96To incorporate it without doing anything else, use 'I'. 97 98Now, load another glider gun in the same manner. Place the two guns in 99such a way that their outgoing gliders collide. Not all collisions are 100well behaved, and you may wish to produce a specific collision, such as 101a clean annihilation of gliders. The references mentioned at the top, and some 102of the patterns supplied with Xlife, are a good source of interesting 103collisions. Use 'G' on the second glider gun to control the phase difference 104between the colliding gliders. 105 106Type 'g' to let the pattern go and see what happens. If the collision was 107chosen randomly, there is a good chance that it will merely break down into 108chaos. Some collisions, however, produce interesting effects. 109 110Save your gun collision into a file using the 'W' command. Now type 'C' and 111use 'l' to load it back in. Note that the result is not what you would expect 112from saving the current pattern. That is, even if the pattern did break down 113into chaos, the pattern written by 'W' corresponds to the collision as you set 114it up. If you type 'g' then you should witness the same sequence of events as 115before. 116 117The file written by 'W' is not a raw pattern image, but rather a "load script." 118That is, it gives Xlife enough information to reconstruct your placement of 119loaded patterns. It does not contain any changes made by drawing or erasing 120cells with the mouse, but such changes deviate from the philosophy of pattern 121structuring and should be avoided except when drawing atomic patterns. 122(In any case, the 'S' command is provided for saving the whole image in an 123unstructured way.) 124 125(2) Setting up a glider mirror. 126 127It is possible to reflect a stream of gliders as if by a mirror, using a 128period 30 shuttle with eaters at the ends. The mirror will not work unless 129the stream (from a period 30 gun) and the mirror are perfectly positioned 130and in phase. In general, this may involve some simple yet tedious calculation 131or else a still more tedious process of trial and error. In the 132following, however, we will see how to use the editing features to 133produce the desired effect reasonably simply. 134 135Load in ex:gun, as before, and let it generate (with 'g') until the outgoing 136stream contains 20 or so gliders. This is the stream we will be reflecting. 137 138Now load in ex:mircollision. This pattern consists of a glider poised to 139be reflected from a mirror. Use rotates, flips, and 'G' (one step at a 140time) until the the mirror glider is an exact copy of the glider furthest 141from the gun. Use the mouse to move the loaded pattern so that these two 142gliders occupy exactly the same five cells. It may help to zoom in on the 143pattern. 144 145Now, simply type 'g' and let the pattern go. It you performed the above 146steps correctly, you should see a stream of gliders bouncing off the mirror. 147Add more mirrors, if desired, and save the result into a file using 'W' 148 149*** More Advanced Editing 150-------------------------- 151Skip the following if you are not interested in familiarizing yourself with the 152details of the #I format. 153 154Take a look at the file generated by 'W' in the above. It consists of a 155sequence of #I lines, the first containing ex:gun, and the others containing 156ex:mircollision. The latter lines each have a delay value as their final 157parameter, and these parameters will most likely be in the hundreds, as this 158is the number of steps it takes to make the stream of gliders used as a 159reference. 160 161Note that the mirror is a period 30 oscillator, so we may replace all of 162these numbers by their values mod 30 without affecting the crucial 163phase difference between the mirror(s) and the gun. Do this, and look at the 164pattern in Xlife. Note that it takes less time to load, and that the loaded 165pattern does not contain a long stream of gliders. Type 'g' to verify that the 166mirrors still work (if not, make sure you computed mod correctly). 167 168The resulting pattern will contain spurious gliders. These are the gliders 169that came with the pattern ex:mircollision. Fortunately, ex:mircollision 170contains ex:mirror with no moves, flips,or rotations applied. 171Hence, by replacing all instances of ex:mircollision by ex:mirror in your 172file, you will obtain the same pattern as before, but without the spurious 173gliders. 174 175This illustrates the notion of including extra parts in a pattern for 176reference and eliminating them in the final edit. Use of this technique 177can substantially reduce the need for explicit calculation when constructing 178complex patterns. 179-------------------------- 180*** end of "More Advanced Editing" 181 182(3) Constructing a structured pattern from a template. 183 184Having familiarized yourself with the use of load scripts, you may wish 185to construct structured versions of old patterns you made in the previous 186version of Xlife. This can be done in a bottom-up fashion by loading 187in the raw image and building up subpatterns using the initial image 188as a reference. You first need to identify the the atomic subpatterns in the 189old pattern. For example, in the mirror of the previous example, the atomic 190patterns are two eaters and the period 30 oscillator (shown earlier in this 191document). 192 193The template pattern should not be written into the load script, and this 194may be prevented by using the 'D' command *after* this pattern has been 195*incorporated* into the universe. The effects of having the template written 196to the load script are non-fatal, and may be corrected with a text editor. 197However, it is best to get in the habit of typing 'I' (include pattern), 198'D' (discard load script) immediately upon loading a template. 199 200The mirror in ex.life is already given in a structured way, but it will suffice 201to illustrate the technique. To place the template, load ex:mirror, and type 202'I' and 'D' as mentioned above. Now, load in succession two eaters (ex:eater) 203and the oscillator (ex:oscil) and place each pattern over the corresponding 204part of the old image. Use 'W' to write the load script. 205 206If the original mirror had been stored as a bitmap then you would have 207transformed a seemingly arbitrary set of points into a structured pattern. 208Patterns defined in this way can later be combined into more complex patterns, 209and at any level, the pattern can be seen to be a logical combination of 210well-understood components rather than an amorphous conglomeration of Life 211cells. 212 213(4) Using the 'collect' utility. 214 215One seeming disadvantage of structuring patterns with the 'W' command is that a 216pattern that used to reside in a single file may now be spread over several 217files. There may be too many to easily keep track of them. The new release 218provides a facility for bundling multiple subpatterns into single files using 219pattern blocks. This is described in the xlife manual page's section on 220inclusion, and may be added with a text editor in order to carefully arrange 221interesting patterns in a logical format. For the user who wishes only to use 222these as a means of collecting a structured pattern into a single file, 223however, the 'collect' utility is provided. 224 225Collect takes a pattern name as an argument (with the same default directories 226as in the 'l' command). It writes a file to standard output that contains 227a stand-alone version of the pattern. Usage is: 228 229 collect pattern > destination 230 231where destination is any valid file name with a .l extension. Xlife will 232now read the destination file as an Xlife pattern, and this file can, for 233example, be mailed to others without the need to send multiple files. 234 235Try this on any of the files written by 'W' in examples 1, 2, and 3. 236 237Conclusion 238---------- 239The above examples illustrate techniques for using the new Xlife features to 240create structured patterns. Other techniques may be found that use these 241features. Conversely, the inability to apply some reasonable technique may 242indicate deficiencies inherent in these features. Life experimenters are 243encouraged to send questions, comments, and ideas for changes to 244Paul Callahan <callahan@cs.jhu.edu>. Actual improvements to the source 245code are, of course, especially encouraged. 246 247