{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420 {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;\red9\green50\blue175;} {\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc2\leveljcn2\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid0\'02\'05.;}{\levelnumbers\'01;}}{\listname ;}\listid1}} {\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}} \margl1440\margr1440\vieww11640\viewh10480\viewkind0 \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \f0\fs36 \cf0 Life \fs24 \ Version 1.0.0, April 1st, 2007\ Game of Life by John Conway\ Implementation by {\field{\*\fldinst{HYPERLINK "mailto:shinyplasticbag@gmail.com"}}{\fldrslt Mark Christian}}\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural {\field{\*\fldinst{HYPERLINK "http://shinyplasticbag.com"}}{\fldrslt \cf0 http://shinyplasticbag.com}}\ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural \f1\b\fs36 \cf1 \'a5\cf0 \'a5 \cf1 \'a5\cf0 \ \cf1 \'a5\cf0 \cf1 \'a5\cf0 \'a5\ \'a5 \'a5 \'a5 \f0\b0\fs24 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs28 \cf0 Introduction \fs24 \ This screen saver is a relatively simple (okay, practically brain-dead) implementation of {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life"}}{\fldrslt Conway's Game of Life}} as a screen saver.\ \ In case you're not familiar with the Game of Life, Wikipedia can rescue you: " \fs25\fsmilli12700 The \f1\b Game of Life \f0\b0 is a {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/Cellular_automaton"}}{\fldrslt \cf2 cellular automaton}} devised by the {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/United_Kingdom"}}{\fldrslt \cf2 British}} {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/Mathematician"}}{\fldrslt \cf2 mathematician}} {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/John_Horton_Conway"}}{\fldrslt \cf2 John Horton Conway}} in {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/1970"}}{\fldrslt \cf2 1970}}. It is the best-known example of a cellular automaton."\ \ Basically, your screen is divided into a grid of square cells. Each one of those has a state -- it's either "alive" (white) or "dead" (black). At each tick of the clock, every cell looks at its neighbours (the 8 cells that touch it) and applies the following logic:\ \ \pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\ql\qnatural\pardirnatural \ls1\ilvl0\cf0 {\listtext \'a5 }If the cell is alive, it will remain alive if it has either two or three living neighbours. If it has fewer or more than that, it dies.\ {\listtext \'a5 }If the cell is dead, it will become alive if it has exactly two living neighbours.\ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 That's it! But just look at those patterns! Every twenty seconds or so, the screen saver will load a pre-defined pattern and start ticking away. It almost seems alive, and thanks to the wonders of mathematicians with too much time on their hands, we can know that the Game of Life can actually support a universal computer, which means it sort of is.\ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural \f1\b\fs36 \cf1 \'a5\cf0 \'a5 \cf1 \'a5\cf0 \ \cf1 \'a5\cf0 \cf1 \'a5\cf0 \'a5\ \'a5 \'a5 \'a5 \f0\b0\fs25\fsmilli12700 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \fs28 Technical Details\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs24 \cf0 This screen saver uses a very simple implementation of the rules of Life, and is pretty slow as a result. This is my first attempt at writing an implementation of Life, and only my second Macintosh programming endeavour, so there's a lot of room for improvement. In terms of Life, there are plenty of better algorithms, and in terms of Mac programming, I'm sure I'm inadvertently doing things the hard and/or wrong way. That being said, it works, and that's something.\ \ The pattern is stored as an array of NSPoints wrapped in NSValues. All of the points that are specified in the array are the cells that are alive. At each tick of the clock, all of the living cells and all of their neighbours are evaluated to see if their state should change (cells that don't touch a living cell have no possibility of changing, and can be ignored). Cells that change, either from alive to dead or dead to alive, are added to another array that is used to update the view, and the array containing the pattern itself is updated to reflect the new state. That's it.\ \ The file patterns.plist in the screen saver bundle's Resources folder contains the set of patterns that the screen saver cycles through. It's a Dictionary of Arrays, each of which consists of a series of coordinates given as strings in the form of "X,Y". It's pretty easy to work with, so feel free to play around.\ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural \f1\b\fs36 \cf1 \'a5\cf0 \'a5 \cf1 \'a5\cf0 \ \cf1 \'a5\cf0 \cf1 \'a5\cf0 \'a5\ \'a5 \'a5 \'a5 \f0\b0\fs24 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \cf0 \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \fs28 \cf0 Credits \fs24 \ Most of the patterns included the the screen saver are courtesy of {\field{\*\fldinst{HYPERLINK "http://www.bitstorm.org/gameoflife/"}}{\fldrslt Edwin Martin's Game of Life page}}.\ \ Other noteworthy resources:\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural {\field{\*\fldinst{HYPERLINK "http://www.ibiblio.org/lifepatterns/"}}{\fldrslt \cf0 Alan Hensel's Game of Life page}}\ {\field{\*\fldinst{HYPERLINK "http://math.com/students/wonders/life/life.html"}}{\fldrslt Wonders of Math - The Game of Life}}\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life"}}{\fldrslt \cf0 Wikipedia entry}}\ }