Wednesday, April 21, 2010

PS-I and the Game of Life

Our first step into the PS-I world is to download the program and check it out.  You can download the most recent public version by going to the PS-I Sourceforge site and downloading version 4.0.5 (exe installer).  This installer will by default install the program to your Program Files directory, but you might want to install it into your documents folder or desktop.  The reason for this is that PS-I uses its root folder to look for files, and newer versions of windows do not automatically give writing access to PS-I in the Program Files folder.


Once installed, load the file from the Sample Files folder called "Life.mdl."  You should see the Model Parameters along with three parameters you can edit: overcrowded, lonely, and creation.  Before we get into what PS-I is doing, here is a summary of the Game of Life, originally devised by John Conway, from wikipedia:

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbors, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
  1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
  2. Any live cell with more than three live neighbours dies, as if by overcrowding.
  3. Any live cell with two or three live neighbours lives on to the next generation.
  4. Any dead cell with exactly three live neighbours becomes a live cell.
The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the one before). The rules continue to be applied repeatedly to create further generations.
The Game of Life is a perfect place to start with PS-I because it is an agent-based model (specifically a cellular automaton) that uses a two-dimensional lattice structure of agents; one of the few rigid requirements of PS-I models).  Choose New Field Viewer from the View menu to see what the current grid looks like.

Yellow cells here are "alive" whereas black cells are "dead".  Any cell has the opportunity to become one of the two states depending on its environment.  Clicking run will run the model according to the current parameters, and then will probably stop changing at some point.  You can reset the model by clicking the Reseed button in the main window, and then run the model again.  You'll probably begin to see patterns in the shapes agents are making, some of which might be Blinkers, Gliders, Beacons, or even Light Weight Space Ships, all of which were devised by the Game of Life community.

There are plenty of conceptual questions we can start to ask at this point, but the purpose of this post is to introduce a new user to PS-I, rather than a discuss evolution, emergence, or complexity, all of which can be found in the inner-workings of this simple model.

At this point, there are a few things a new user can try.  The first might be to edit the status of specific agents.  Right click on any agent, and choose Edit this Agent.  The Effect Tool will pop up, and you can edit the attributes of the current agent.  The present attribute can be either true or false, and it denotes whether an agent is alive or dead.  Change the status of the current agent, click the check box that says Change next to the input line, and then click Apply Effect on the bottom left.  When you check the Field Viewer again, you should see that the agent you edited now has a different status.  Once you've changed an agent, you can then click Step on the field viewer to move the model one time step forward to see the effect of your change.

Another way you can edit the model is by changing the parameters.  In the Model Parameters section of the main window, change one of the specifications for when an agent becomes overcrowded or lonely and click Set at the bottom of the window.  Rerun the model to see how changing different parameters changes the behavior of the model.  You'll probably find that few parameter combinations produce results quite as interesting as the defaults for the Game of Life.

More advanced users might be interested in clicking the Model Specification tab on the top of the main window to see the code used in this model.  You can also open "Life.mdl" in notepad (or, my preference, Notepad ++) and view the code from there.  Also, for another version of the model where a different coding technique is used to produce the same results, you can download "Life2.mdl".  Good luck and happy modeling!

No comments:

Post a Comment