home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 145.lha / life.readme < prev    next >
Text File  |  1986-11-21  |  22KB  |  430 lines

  1.  
  2.         Amiga Life, The Compleat Intuition Example
  3.  
  4.         Copyright (c) 1987,1988 McManis & McManis Software
  5.         All Rights Reserved.
  6.  
  7.  
  8. 1.0 OVERVIEW
  9.  
  10.     This is an implementation of Life for the Amiga. It incorporates a 
  11. number of features that are unique to this implementation, including 
  12. user settable rules, and multiple species support. The binary is 
  13. freely distributable, use it and enjoy it. The code for this program
  14. is a very complete example of how to use all of the calls to Intuition
  15. as well as many tricks and techniques that are not documented anywhere.
  16. This aspect of the program is not free. See the section below for
  17. more details.
  18.  
  19. 1.1 The Package
  20.  
  21.     First off, you should note that this program is not public domain.
  22. That is, you cannot sell it for a profit without both my permission and
  23. giving me a cut, however you can give the executable away free or as part
  24. of a library collection if you include this file and don't modify it or
  25. the executable in any way.
  26.  
  27.     If you are a user of the Amiga and just like playing with this stuff 
  28. then enjoy this program with my blessings, no further effort on your part
  29. is required. 
  30.  
  31.     If you are a developer of software, or would just like to know how 
  32. this program works, then have I got a deal for you! :-) You can buy the
  33. source and a description of how it works, right down to the last gritty
  34. detail. What you get when you buy it are a non-exclusive license to use
  35. the code in your programs if you choose to, assuming you don't use it 
  36. to write a Life program, and a lot of useful information on how to write
  37. well behaved tools that cooperate with the system. The code is written
  38. to be easy to understand and easily modified. Using it as a framework
  39. for your next project can save you hours. It will save you even more
  40. time when it comes to modifying your program because it adapts easily
  41. and automatically to many aspects of the system environment. Ordering
  42. information is in the appendix.  Something to look for are the various 
  43. things that this program can do and ask yourself, "How does he do that?", 
  44. or "I've been meaning to write code that did that." Anyway, as they 
  45. say on the Ragu commercials "It's in there!" 
  46.  
  47.  
  48. 1.2 Life and Cellular Automata
  49.  
  50.     What is "Life" you ask? Well originally it was a mathematical 
  51. amusement that John Conway figured out to demonstrate a Cellular 
  52. Automaton. A Cellular Automaton is a bunch of cells that relate to
  53. each other through a fixed set of rules. The system as a whole can 
  54. be made to accomplish some task by setting the rules and the patterns
  55. appropriately. And while I can't go into any great detail in this 
  56. file, double click on the menu button while running the program and
  57. flip to page 3 of the About ... requester for some reference works,
  58.  
  59.     The terminology used in this document and throughout the program
  60. is all 'life' oriented. Each blob on the screen is a Cell, a group of 
  61. cells are a growth, and all the cells on the screen constitute a colony.
  62. In general the area on the screen is referred to as the "world" and 
  63. separate off screen area where growths are held temporarily is called
  64. "limbo."
  65.     
  66. 2.0 STARTUP AND OPTIONS
  67.  
  68.     There are two ways you can start Life, via the CLI and via the 
  69. workbench. When you start up Life there are several options you may
  70. wish to pass it. How you pass it options depends on how you start it
  71. up. But before you start it you need to know just what the heck you can
  72. specify as options. 
  73.  
  74.     There are five options that can be specified, these are resolution,
  75. world type, screen font, rules type, and loop limits.
  76.  
  77.     If you start Life from the workbench you can set the various options
  78. by modifying the TOOLTYPES field of the Life icon. Select the icon on the
  79. workbench and then select the "Info" option from the workbench menu. There
  80. will be a line called ToolTypes with an up and down arrow. If there are
  81. no ToolTypes set, nothing will happen when you click on these arrows, if
  82. there are some ToolTypes then they will scroll by when you click on these
  83. arrows. To add one click on the "ADD" box next to the tool type. The line
  84. will be cleared. Now click on the line and your cursor will be placed 
  85. into it. Now type in your option, for example you could type in 
  86. "RESOLUTION=HIGH", without the quotes, which would indicate your 
  87. preference that Life come up in a high resolution screen.
  88. The tool type options are as follows, (brackets indicate you should pick
  89. one choice or the other) ...
  90.  
  91.     RESOLUTION=[HIGH,MEDIUM,LOW]
  92.     FONT=fontname/size
  93.     WORLD=[TORUS,PATCH]
  94.     RULES=[SINGLE,DOUBLE]
  95.     LOOPLIMIT=num
  96.  
  97.     On the other hand, if you start Life from the CLI you will can 
  98. specify these options with command line switches. The syntax from the
  99. command line is :
  100.  
  101.     1> Life -h -L 6 
  102.  
  103. Where in this case you would be selecting high resolution and a loop
  104. limit of 6 generations. The command line switches are as follows :
  105.  
  106.     -h         for High resolution
  107.     -m         for Medium resolution
  108.     -l        for Low resolution
  109.     -L nnn        to set the Loop limit to 'nnn'
  110.     -t        for a Torus world
  111.     -p        for a Patch world
  112.     -f name size    to use font 'name' and size 'size'
  113.     -d        to use dual species rules
  114.     -s        to use single species rules
  115.  
  116.      In both cases it is possible to select a colony file to load 
  117. initially. From the workbench, click on the icon of the colony file, 
  118. hold down the shift key and double click on the Life icon. From the 
  119. command line, simply specify the colony file as the last parameter on
  120. the line. 
  121.  
  122. 3.0 OPERATING THE PROGRAM
  123.  
  124.     After you have started up the program and are looking at a blank
  125. grey screen you may be wondering what to do next. Well the answer is
  126. start creating cells. Cells are placed in a square grid on the screen
  127. that is 8 pixels on a side. To place a cell, position the pointer over
  128. the place you want it to appear and press the left button. A blue cell
  129. will appear. This is referred to as a "Type A" cell. Positioning the
  130. pointer over a Type A cell and pressing the left mouse button will 
  131. change it into a "Type B" cell. Note that the type of the cell is 
  132. only important if you are using Type II rules, see the section on the
  133. Misc menu below for how to set the rules and what it means. Finally,
  134. if you position the mouse over a Type B cell and press the left button
  135. it will be removed. In this way you can add and remove cells anywhere
  136. in the world. After you have some cells you can move the next generation
  137. by pressing the return key, or by selecting Iterate from the control
  138. menu. If you want the program to run continuous generations you can
  139. press the STOP gadget in the title bar (which will turn in to a Run
  140. gadget), or select "Begin" from the control menu. 
  141.  
  142. 4.0 THE MENUS OF LIFE
  143.  
  144.     This program has several menu selectable options that are organized
  145. into four main groups. These groups appear at the top of your screen when
  146. you press the Menu button. They are labeled, "Project", "Edit", "Misc", and
  147. "Control". I will cover each group in this section.
  148.  
  149. 4.1 The Project Menu
  150.  
  151.     The project menu controls the loading and saving of growth and colony
  152. patterns. It also contains other commands that are related to the environment
  153. of this tool. 
  154.  
  155.     The first group of options are "New", "Open Colony", "Save Colony", 
  156. and "Save As Colony." The New command will clear out the current life
  157. array and intialize internal population counters to 0. "Open Colony" will
  158. bring up a file requester asking you to select a colony file to load. You
  159. can move around in the Amiga file system with only the mouse if you choose
  160. or you can go directly to the directory of interest with the string gadgets.
  161. You may enter a file name in the 'File :' box or double click on the name in
  162. the display below. After you are satisfied, click on the Accept button to 
  163. leave the requester or the Cancel! button to abort the operation. "Save
  164. Colony" is the opposite of "Open Colony". It will save the current array 
  165. into the current Colony name, if no name has been selected or you choose 
  166. the "Save As" option, the file requester will be brought up again and a 
  167. new name can be chosen.
  168.  
  169.     The next group are the growth group. These two options, "Open Growth"
  170. and "Save Growth" will load or save selected portions of the world. When
  171. you choose "Open Growth", the file requester will appear and you will be
  172. asked to select a growth file to load. After it has been loaded, you will
  173. have to select one of the "Paste" options in the Edit menu to actually 
  174. place it into the world. Similarly, before you can save a growth you must
  175. have clipped it using one of the "Cut" options in the "Edit" menu. The 
  176. "Edit" menu is described in the next section.
  177.  
  178.     The final group of choices, "Save Defaults", "About ...", and "Quit" 
  179. affect the environment. When you choose "Save Defaults" the settings of 
  180. all the variable Life parameters are saved to the file Life.Def in the 
  181. directory where life resides. When you restart life it will automatically
  182. read these settings and pre-initialize the system appropriately. The 
  183. second option "About ..." brings up a requester that describes the program
  184. a bit and lets you play with some mutually excluded gadgets. Note that you
  185. can also bring up this requester by clicking the menu button twice
  186. quickly. The final option "Quit" is pretty self explanatory.
  187.  
  188. 4.1 The Edit Menu
  189.  
  190.    The Edit menu is where all the manipulations of growths happens. It 
  191. has several familiar functions, and some not so familiar. The first 
  192. group put cells from the world into growth limbo. When you use "Cut"
  193. the cells you select will be removed from the world, when you use "Copy"
  194. a copy of that section will be created in limbo. The next two options
  195. put the growth in limbo back into the world. The "Paste" option is 
  196. opaque, in that the resulting patch is put into the world looking like
  197. it came out. Cells that were living there that aren't in the growth
  198. get removed. The "Insert" option uses an OR function to place the growth
  199. down into the world. Cells that are already in the world remain if 
  200. they are not overlayed by cells from the growth in limbo. All four of
  201. these options cause the cursor to change to a giant 'G' when they are
  202. active. The next option is "Undo" and restores the world to the state
  203. it was in on the previous generation. Note that it is only a single 
  204. level undo function and repeated calls will have no effect. The final
  205. option on this menu is "Transform" and it has three suboptions. These
  206. options operate on the growth that is currently in limbo. The three
  207. operations are "Mirror X", "Mirror Y", and "Rotate 90". The mirror options
  208. simply flip the growth along a centerline in the indicated direction.
  209. In this program "Mirror X" flips the growth along the vertical axis, and
  210. "Mirror Y" flips it along the horizontal axis. The last suboption "Rotate
  211. 90" will rotate the growth 90 degrees clockwise, effectively swapping
  212. the X and Y axis. Note that in all cases the growth remains 'square'.
  213.  
  214. 4.2 The Misc Menu
  215.  
  216.     Clearly this the menu that got all the options that I couldn't
  217. think of a better place to put them. It could also be called preferences
  218. because all but one of the control parameters are set here. 
  219.  
  220.     The first option is "Adjust Colors". This option will bring up a 
  221. color palette that will let you adjust the colors on the screen. Note
  222. that what it actually does is fork the Palette program that is in the
  223. life directory and that changes the colors. Ah the joys of multitasking.
  224. Anyway, the color palette is saved as part of the preferences so if you
  225. prefer green cells to blue ones this is the place to set that up.
  226.  
  227.     The second option is "Rules Type." As life programs go this one is
  228. fairly unique in that can handle two separate species, and the user is
  229. allowed to experiment with different sets of rules. As far as I know 
  230. this is the only one that offers these two features, I know it is the
  231. only one that use matrices to let you set them up. This option actually
  232. has three suboptions, "Type I" and "Type II" rules, and "Set the Rules".
  233. Note that the type of rules are mutually exclusive, selecting one disables
  234. the other and vice versa. Also, if you are displaying a low resolution 
  235. screen you will not be able to adjust the type II rules because the 
  236. requester won't fit. 
  237.  
  238.     Type I rules are the traditional rules of life that operate with only
  239. one species. The default setup sets new cells to be blue, and 'old'
  240. cells that survive a generation to be red. The default type II rules
  241. sets up 'Conway' rules for both the red and blue species but does not
  242. allow the two to intermingle, which brings us to the  third suboption
  243. "Set the Rules".
  244.  
  245.     This allows you to determine who will die and who will live on to
  246. the next generation.  The format looks strange at first but will become
  247. clear after thinking about it for a minute or two. Essentially when
  248. each iteration of a loop occurs a cell at a given co-ordinate can
  249. either be occupied or empty, and it has some number of neighbor cells
  250. that are occupied or empty. In the type I case the calculation is very
  251. simple, the default rules show that if a cell is unoccupied and has
  252. exactly three neighbors, a new cell is born. If the cell is occupied
  253. and has two or three neighbors the cell lives on to the next generation
  254. (getting sunburn in the process). If an occupied cell has only one or
  255. no neighbors it dies of lonelyness, and if it has more than three
  256. neighbors it commits hari keri because it doesn't have enough space. Of
  257. course you can change this. You can make crowded cells turn blue again
  258. by adding blue cells in these crowded spots, you can create spontaneous
  259. generation by adding a blue cell to the unoccupied with zero neighbors
  260. spot. (Pretty boring though to see the screen whoosh full of cells.)
  261. Type II rules use exactly the same principles except expanded to
  262. differentiate between Type A and Type B neighbors. Now each cell can
  263. either be empty, have a Type A cell, or a Type B cell in it. The
  264. possibilities are staggering (actually there are 3^81 possible sets of
  265. rules for Type II life, I've looked at 5).
  266.  
  267.    The next option is more mundane, it is the 'type' of world. You see
  268. the original paper by Conway used an "infinite" plane of cells. Well 
  269. we don't have "infinite" memory so we make do with what we have. The
  270. two suboptions are "Patch" and "Torus" and describe how a cell at the
  271. edge of the screen is treated. In "Patch" mode the edge of the screen
  272. is dead, that is it doesn't change. By default there are no cells there
  273. but you can put cells there if you so choose. They will be exempt from
  274. the rules and continue to exist from generation to generation. The other
  275. option is "Torus", which is the shape you would get if you took a square
  276. piece of paper and made all of the opposite edges touch. Basically, if
  277. a glider goes off one side of the screen it will reappear in the other 
  278. side in short order. This is because the torus world wraps around at all
  279. the edges. What goes off the top comes in off the bottom and what goes
  280. off to the side comes in on the other side. If you want to warp your 
  281. brain consider that all four corners of the screen are neighbors of 
  282. each other, strange but true.
  283.  
  284.     Option four is "debugging" and in general you won't care to use this
  285. option. When the "Debugging On" suboption is selected lots of debugging
  286. messages a spewed about like political rhetoric. If you do buy the 
  287. source however they are invaluable in figuring out what is going on 
  288. where sometimes. To enable these items you need the source.
  289.  
  290.     Option five is the Status Window. Selecting this option will bring
  291. up a separate window that contains statistics on the birth and death
  292. rate of the two species and has a generation meter to tell you how fast
  293. the generations are being calculated and displayed. It also has a
  294. run/stop button to let you control the simulation from there. (I know
  295. it is redundant but it serves to demonstrate a technique in the
  296. source.).
  297.  
  298.     Option six lets you turn the workbench screen on and off. Since 
  299. Life runs in a custom screen, you can choose to free up some memory by
  300. turning off the workbench. Note that this only works if you have started
  301. Life from the workbench. If you start it from a CLI it can't close down
  302. the workbench screen.
  303.  
  304.     Option seven lets you change the resolution of the Screen. This
  305. function has some interesting interactions with the menus and such.
  306. When life is started it builds the menus and requesters it needs. If
  307. you then change the screen resolution to a lower resolution some things
  308. may break. I've tried to keep these to a minimum. The suboption list 
  309. shows the resolutions available. These options are nominally 320 X 200, 
  310. 640 X 400 etc, however if you are running morerows this menu will reflect
  311. the actual size of the screen it will open.
  312.  
  313.     The last option is "Show Pointer", selecting this option will
  314. cause the mouse pointer to disappear. Sometimes this is preferable
  315. to pulling it down to the lower right hand corner of the screen. Note
  316. that it has a shortcut key (Amiga-M), remember this because if the
  317. mouse is invisible it can make selecting menu items problematic at 
  318. best. 
  319.  
  320. 4.3 The Control Menu
  321.  
  322.     The Control Menu is probably the simplest menu to explain. It 
  323. will control the operation of the simulation while the program is
  324. waiting for input. This menu has four options, "Begin", "End", "Iterate",
  325. and "Autostop". The first two will start and stop continuous generations.
  326. At the end of each generation the input queue is check for messages and
  327. if found they are responded to. The third option, "Iterate" simply moves
  328. the simulation forward one generation. As described in the operation
  329. section you can also start a generation by pressing the <Return> key
  330. on your keyboard. The final option "Autostop" controls the detection
  331. of loops. Life will stop iterating as soon as the population of both
  332. species goes to 0, but there are often cases where the current colony
  333. is stable and not 0. In these cases it is preferable to stop iterating
  334. after a set number of generations where the population stays the same.
  335. Note that this shouldn't be '1' because that would preclude gliders
  336. and other moving objects from possibly colliding and continuing the
  337. excitement. The default is 8 generations, you can of course set it
  338. to whatever you chose with the tooltype or command line switch.
  339.  
  340. APPENDIX A - The License Agreement
  341.  
  342.     The Compleat Intuition Example, Source License.
  343.  
  344. The following agreement is entered into between McManis and McManis
  345. Software, the licensor, and _______________________________________,
  346. the licensee, on _______________________, 19__. This agreement supercedes
  347. all previous agreements between licensee and licensor. This agreement
  348. is not transferable. This agreement is non-exclusive.
  349.  
  350. In consideration of the $75 the licensee has paid to the licensor, the 
  351. liscensor conveys the following rights and privledges upon the licensee :
  352.  
  353.     Use of all or part of the source code in the Compleat Intuition
  354.     example, in the development or production of the licensees product 
  355.     without any further royalty or consideration. 
  356.  
  357. The licensee agrees to abide by the following conditions :
  358.  
  359.     The source code will be kept in confidence and not disclosed
  360.     to any other person or company who does not also have in
  361.     their possession a source license with the liscensor.
  362.  
  363.     Allow the source code to come into the possession of unlicensed
  364.     parties through either deliberate or inadvertent action.
  365.  
  366.     
  367.  
  368.  
  369. _________________________________    _________________________________
  370. Chuck McManis,             (Date)       Liscensee                  (Date)
  371. McManis and McManis Software
  372.         
  373.                     _________________________________
  374.                     Licencee (Printed)
  375.  
  376.  
  377. APPENDIX B - Ordering the Source Code
  378.  
  379. To order the source code you will need to print out the license
  380. agreement in appendix A twice, sign both copies and send them with
  381. a check or money order for $75 plus $5 postage and handling to :
  382.  
  383.     McManis & McManis Software, 
  384.         1141 Vasquez Ave
  385.        Sunnyvale CA, 94086
  386.         (408) 749-8815 
  387.  
  388. Your $75 will get you a 3-ring binder containing :
  389.     o A laser printed copy of the source listing.
  390.     o An index indicating where each Intuition call is used.
  391.     o A description of the operation of the source. 
  392.     o A year of updates to the source. 
  393.     o A disk with the code on it as well.
  394.      o And a license to use the source in your own programs.
  395.     
  396.  
  397. The code uses nearly every call that is supported under Intuition in 
  398. version 1.2 or version 1.3 of the OS. It also details many techniques
  399. that are either not documented or documented poorly. It identifies
  400. several bugs in the current version of Intuition and shows you how to
  401. work around them. And it has been written with ease of use in mind, 
  402. specifically, routines are coded such that they can be extracted and
  403. placed into your code quickly. Gadget building routines, a file requester,
  404. the EZMenus(*) package, and a variety of other useful tidbits. I have
  405. spent a couple of hundred hours putting this stuff together. I believe
  406. that you can save ten to twenty hours by using the framework in your
  407. program. So if you are serious about writing tools for the Amiga this
  408. can be a real time saver. I have also tried to use every type of object
  409. Intuition deals with in terms of requesters, gadgets, windows, and menus.
  410.  
  411. --Chuck McManis
  412.  
  413. Electronic addresses :
  414.     BIX - cmcmanis
  415.      Usenet - {any backbone}!sun!cmcmanis
  416.     Arpanet - cmcmanis@sun,com
  417.  
  418. APPENDIX C - Warranty
  419.  
  420. McManis and McManis Software makes no warranty or representation, either
  421. express or implied with respects to this software, its quality, performance,
  422. merchantibility, or fitness or a particular purpose. As a result, this
  423. software is sold on an "as is" basis. The entire risk as to its quality
  424. and performance is with you, the user and not McManis and McManis software.
  425. In no event shall McManis and McManis Software be liable for direct, 
  426. indirect, special, incidental, or consequential damages resulting from 
  427. any defect in the software or its documentation, even if advised of the
  428. possibility of such damages.
  429.  
  430.