GtkLife Help

## Contents

1. Introduction to Conway's Life
2. Introduction to GtkLife
3. The Pattern Archive
4. Anatomy of the Main Window
   - Overview
   - Viewport
   - Menubar
   - Toolbar
   - Sidebar
   - Status Bar
5. Usage
   1. Moving Around
   2. Zooming
   3. Drawing
   4. Cut and Paste
   5. Running
   6. Changing Speed
   7. File Handling
6. Menu Reference
   1. File
   2. View
   3. Edit
   4. Run
   5. Help
7. Configuring GtkLife
   1. File Preferences
   2. View Preferences
   3. Run Preferences
   4. Help Preferences
8. Keybindings

## 1. Introduction to Conway's Life

Conway's Life is a form of artificial life (specifically, a cellular automaton)--one of the simplest there is. There are only a few rules:

1. The game is played on a rectangular grid, where each cell is either alive or dead.
2. Each generation is computed from the state of the previous generation, using rules 3 and 4:
3. A live cell with 2 or 3 live neighbors (adjacent cells, including diagonals) lives on. Otherwise it dies.
4. A dead cell with exactly 3 live neighbors comes to life.

That's all there is to it. Yet fascinating behavior arises from these simple rules. Gliders, for instance.

It turns out, if you take the little five-cell shape to the left and apply the rules of Life to it, it glides diagonally across the grid. That is, it transforms in such a way that it reproduces itself at an offset every four generations. No one invented gliders. They just happen. In fact, draw some random cells in a Life program and hit "start," and it's a good chance you'll see gliders form spontaneously. This is just the beginning: Conway's Life has a whole menagerie of recurring patterns.

Much more detailed introductions to Conway's Life are available on the web. Here are a few links worth following:

- What is the Game of Life?
- The original 1970 Scientific American article
- Paul Callahan's Page of Conway's Life Miscellany

## 2. Introduction to GtkLife

You can play Conway's Life with nothing more than a pencil and a sheet of graph paper, but it's a lot faster to use a computer. That's where GtkLife comes in. It provides you with a scrolling 1 million x 1 million cell grid, which should be enough space for even the most complex patterns, and an optimized algorithm which can run up to hundreds of generations per second. At any time, you can save the contents of the grid to a file for later use. There are also a number of preset patterns bundled with the application.

For Life newbies, getting started is easy. Scribble generously on the Life canvas, then push the green button. You'll see various "still lifes" (unchanging shapes), blinkers, and gliders coalesce out of the ensuing chaos. If you're lucky you might see a lightweight spaceship or a pulsar. Now try to figure out why it happens!

Once you've experimented on your own for awhile, you may want to explore what others have created in the Life Pattern Archive.

## 3. The Pattern Archive

GtkLife comes with the Life Pattern Archive, a public-domain collection amassed by Alan Hensel. After installation, the patterns are available from GtkLife in a sidebar on the main window. Another collection, Jason Summers' JSLife, is also available and can be selected as an option. The Life Pattern Archive has a good range of patterns from simple to complex; JSLife contains more esoteric, unusual, and recently-discovered patterns.

Most of the patterns have descriptions provided by their authors, which you can read after loading by clicking the text icon on the toolbar. If you get lost in the terminology (rakes, sawtooths, corderships...), the online Life Lexicon will clear things up.

A typical Life pattern explodes chaotically, then gradually settles down into small groups of predictable cells. However, Life enthusiasts have engineered patterns that are anything but typical, and most of the included files fall into that category. There are fleets of ships, glider guns, complex oscillators, puffer trains, breeders that grow at quadratic speed, patterns that build other patterns, and perhaps the most anomalous pattern of all, "Max" (pictured at left). To get an idea of just how delicately balanced Max is, let it run for awhile, then erase one little dot in the middle.

Then there are the computational patterns, of which perhaps the most impressive is a functional (though slow) prime number sieve. As it turns out, Life is Turing-Complete: given a large enough grid and enough time, it can perform any computation that a modern computer could.

Here are a few of the author's current favorites:

LPA/Breeders/"Breeder 4"
  One of the more unusual breeders: it generates a zigzagging grid of gliders.
LPA/Math and CS/"Primes"
  Produces a westward stream of spaceships representing prime numbers. It's a real puzzle to try to figure out how this works.
LPA/Math and CS/"Unit Cell"
  A 500x500-cell cell, duplicating the rules of a life on a larger scale.
JSLife/Builders/"SS Factory"
  A spaceship factory. Complex machinery funnels four streams of gliders into the middle of the pattern, where they synthesize a fleet of 2c/5 spaceships.
JSLife/Odds & Ends/"Shuttle"
  A corridor of gliders shuttles a spaceship back and forth. It's just cute.

For more details on the contents of the Life Pattern Archive, see Alan Hensel's notes.

## 4. Anatomy of the Main Window

The GtkLife main window consists of a scrollable viewport in the middle, a menubar and toolbar at top, a scrollable sidebar at the left, and a status bar at the bottom. Many of these components can be disabled from the "View" menu, and a fullscreen mode is available.

Viewport
  The main display of GtkLife is a scrolling viewport on the 1 million x 1 million Life grid. At startup, it is centered on the middle of the world, which has the coordinates (0,0).

Menubar
  See the Menu Reference for a full listing of menu items. All GtkLife menus are "tearable": click on the dotted line at the top of the menu to tear it off into a separate window.

Toolbar
  The toolbar has buttons linked to the most important menu items, grouped by menu:

  File: | New, Open, Reopen, Save, Description
  View: | Zoom in, Zoom out, Zoom 1:1 (minimum), Zoom 16:1 (maximum)
  Edit: | Drawing Tool, Selection Tool, Cut, Copy, Paste
  Run: | Start/Stop, Step

  At the far right of the toolbar is a slider which you can use to adjust the pattern running speed.

Sidebar
  The Sidebar lists the contents of the currently chosen pattern collection. Simply click on a pattern title to load the file. Scroll through the list of patterns using the scrollbar or your mouse wheel. As a shortcut for File->Change Pattern Collection, you can click on the "Patterns" list header to choose a new collection.

  Some patterns are sorted into sub-directories--in fact, the included collections (Life Pattern Archive and JSLife) are entirely hierarchical. Directories are displayed with trailing slashes. Click on a directory to display its contents in a clickable list below the main sidebar.

Status Bar
  The status bar displays various useful bits of information. On the left are the coordinates of the cell where the mouse is hovering. If the mouse pointer is not inside the Life display, it shows the coordinates of the cell in the upper-left corner. On the right, labeled "Tick" and "Population", are the current generation number and the current live cell count. The middle is reserved for messages to the user.

## 5. Usage

### 5.1. Moving Around

There are a number of ways to move the Life viewport. In addition to the scrollbars, you can use the numeric keypad (with NumLock on) to scroll the viewport up, down, right, left, or diagonally. To scroll by page, hold down the <ctrl> key. Keypad "5" recenters at (0,0).

The mouse wheel scrolls the display vertically. Hold down "shift" to scroll horizontally. Finally, you can recenter around a particular point on the grid by right-clicking on it.

Some Life patterns (e.g. Jaws, Catacryst) are very sparse--you may not even see any cells in the viewport when you first load them. For these, the View->Find Active Cells command is useful. It will locate an area containing live cells and center on it, preferring active regions to those which have become stable (still life) or oscillatory.

### 5.2. Zooming

Zoom operations are available from the "View" menu and from the magnifying glasses in the toolbar. At startup, the viewport is zoomed all the way out, so that one blue pixel represents one live cell. You can zoom in up to 16:1, which makes operations like drawing much easier. At zoom levels 4:1 and up, a visual grid is drawn to clearly distinguish individual cells.

You can also zoom in and out with the mouse wheel while holding down "control".

### 5.3. Drawing

Left-click on the grid to toggle a cell between alive and dead. Drag the mouse to continue drawing or continue erasing cells. If you drag to the edge of the viewport, it will scroll with you.

### 5.4. Cut and Paste

GtkLife supports block cut-and-paste of pattern cells. To select a block of cells, left click on one corner of the block while holding down the <shift> key, then drag to the opposite corner. If you drag to the edge, the viewport will scroll with you, so you can select as large an area as you like. If you want the left mouse button to select by default rather than drawing, choose the selection tool from the toolbar (in which case you can hold down shift to draw).

The selection can then be cut/copied and pasted via the commands in the "Edit" menu (or by using the standard Ctrl-X, Ctrl-C, and Ctrl-V keystrokes). After choosing "Paste", a highlighted rectangle will appear as you move over the grid. Left-click when the rectangle is located where you want to paste. For convenience, Unix-style pasting is also allowed: instead of using the Paste command, simply middle-click on the upper-left corner of the desired region.

If there is a currently selected region when you paste, it will be implicitly copied and used in place of the copy buffer.

Note: GtkLife pasting is "transparent"--only live cells are copied. In other words, empty cells in the source region will not overwrite live cells in the target region.

### 5.5. Running

Start the pattern by clicking the green button on the toolbar. Click the button again to stop. Note that most operations are still available while the pattern is running. In particular, you can draw and cut-and-paste in the middle of a running pattern. Of course, a lone plotted cell will quickly die out!

There are two other ways to advance the pattern: Run->Step (the green arrow in the toolbar) to advance by one generation, and Run->Jump to jump ahead to a particular generation as quickly as possible.

### 5.6. Changing Speed

Speed is adjustable, and is set in generations per second. You can adjust speed gradually using the '<' and '>' keys (unshifted), or directly using the Run->Speed dialog or the slider on the toolbar. By default the slider goes up to 200 generations/second, but this is not a hard maximum: it will expand if you set a higher speed by some other means. The only real limit on speed is how fast your processor can go.

The program will start to drop frames if it finds itself falling behind---that is, the next generation will be computed, but the screen will not update during that tick. This greatly improves performance, especially if you don't have 2D acceleration on your video card, but it makes the animation less smooth. If you want to temporarily disable frame skipping for the current session, deselect the "skip frames" check box in the Run->Speed dialog. To have it turned off by default, see Preferences/Run.

### 5.7. File Handling

All of the standard commands are available from the File menu: New (Ctrl-N), Open (Ctrl-O), Save (Ctrl-S), and Save As (Ctrl-A). In addition, the Reopen command (R) provides an easy way to "rewind" a pattern back to its saved state. Only one pattern file can be loaded at a time.

You can specify a pattern file on the command line to load it at start-up. If you specify a directory on the command line, it will be set as the pattern collection for the sidebar.

GtkLife supports a number of different pattern file formats, including RLE, Life 1.05, Life 1.06, and XLife. It also has a native format, GLF. Format is auto-detected when loading, while the "Save As" dialog allows you to choose format from a pull-down list. All file formats support a textual pattern description, which can be viewed and/or edited via the File->Description command.

At present, GtkLife only supports the classic rules of life: survive with 2 or 3 neighbors, birth with 3 neighbors. Thus, any special rules directives in pattern files will be ignored.

"Structured" XLife files (containing include directives and/or sub-patterns) are not currently supported. This includes many of the patterns bundled with the latest XLife.

## 6. Menu Reference

### 6.1. File Menu

File->New
  Start a new file, clearing the Life grid.
File->Open
  Load a pattern file. The Open dialog defaults to the directory of the current pattern collection, so that you can browse the collection even if you've disabled the sidebar.
File->Reopen
  Reload the current pattern from disk. This provides an easy way to revert a pattern back to its original state, provided it has a file associated with it.
File->Save
  Save the contents of the grid and description to a pattern file.
File->Save As
  Save with a new filename.
File->Description
  View and/or edit the pattern description. If you load a new pattern file while the description dialog is active, it will automatically update.
File->Change Pattern Collection
  Choose a different collection of Life patterns. You can select one of several included collections, or simply pick a directory: any files in the directory with recognized extensions (.glf, .rle, .lif, .l) will be listed in the sidebar, as will any sub-directories. This also sets the default starting directory for the File->Open dialog, so that you can easily load files from the collection when the sidebar is hidden.

  The change applies to the current program session only; to have a different collection chosen by default at startup, see File Preferences.

Recent files
  The five most recently accessed pattern files are listed near the bottom of the File menu for quick loading.
File->Quit
  Exit GtkLife.

### 6.2. View Menu

View->Zoom In
  Zoom in by a factor of 2.
View->Zoom Out
  Zoom out by a factor of 2.
View->Zoom (submenu)
  Choose a particular zoom level.
View->Recenter
  Recenter the viewport on the middle of the world (0,0).
View->Goto
  Pop up a dialog to set the exact location of the viewport. You can either choose a point to be the upper-left corner, or choose a point to center around.
View->Find Active Cells
  Find a region containing live cells and center on it. GtkLife will try to locate an active area of the grid, i.e., one where cells are neither stable nor oscillatory. Failing that, it will locate a region of oscillating cells, and failing that, stable ones.
View->Show Toolbar
View->Show Sidebar
View->Show Scrollbars
View->Show Status Bar
  These checkboxes allow you to enable or disable various components of the main window. The settings only applied to the current session, and will be reset to their defaults when you next run the program. See Preferences/View to learn how to change the defaults.
View->Fullscreen
  Select this checkbox to put GtkLife in fullscreen mode. The main window will enlarge to fill the screen and all components except for the Life viewport, the menubar and the status bar will be turned off. Type "F" to exit fullscreen mode. Note: your window manager must support EWMH to make full use of this feature. If it does not, the GUI will be stripped down as described above, but the window will not actually fill the screen.

  If you want GtkLife to go into fullscreen automatically at startup, see Preferences/View.

### 6.3. Edit Menu

Cut, copy, clear, paste and move all operate on blocks of cells. You can select a block by shift-clicking on one corner, then dragging to the opposite corner.

Edit->Drawing Tool
  Draw with the left mouse button (default)
Edit->Selection Tool
  Select with the left mouse button
Edit->Cut
  Copy and clear the selected region. Note: the copy buffer is preserved when you start or load a new file.
Edit->Copy
  Copy the selected region.
Edit->Clear
  Clear (but don't copy) the selected region.
Edit->Paste
  Paste the contents of the copy buffer to the grid. If there is a currently selected region, it will be implicitly copied and used in place of the copy buffer. After you enter this command, a highlighted rectangle will appear as you move over the grid, so that you can choose where to paste. Left-click when the rectangle is in the right position.
Edit->Move
  This is essentially a shortcut for Cut-Paste: it cuts the selected region, then allows you to choose a spot to paste it. But the original region is left on display while pasting, so that you can easily displace a block of cells by a chosen offset.
Edit->Cancel Paste
  Cancel a pending Paste or Move operation.
Edit->Preferences
  Pop up the GtkLife Preferences dialog.

### 6.4. Run Menu

Run->Start/Stop
  Start or stop the pattern.
Run->Step
  Run the pattern for one generation.
Run->Jump
  Jump ahead to a particular generation as quickly as possible, without display updates.
Run->Faster
  Increase the run speed (by a customizable increment).
Run->Slower
  Decrease the run speed (by a customizable increment).
Run->Speed
  Pop up the Speed dialog. This allows you to set speed directly in generations/second, and also to specify whether GtkLife should skip frames to try to achieve the requested speed. You can enter any value up to 10,000. Of course, what speed you will actually attain depends on the complexity of the pattern and on your processor.

### 6.5. Help Menu

Help->Help
  Display the GtkLife help file in a web browser window. You can change the choice of browser in Preferences/Help.
Help->Pattern Archive Notes
  Display Alan Hensel's notes on the Pattern Archive in a browser window.
Help->GLF File Format
  Display notes on GtkLife's native file format in a browser window.
Help->About GtkLife
  Display version, author, license and cute mascot for GtkLife.

## 7. Configuring GtkLife

A Preferences dialog can be popped up via the Edit->Preferences menu item. Changes are automatically saved to disk when you click "Okay" or "Apply". Below is a description of each option under each of the four tabs.

### 7.1. Preferences/File

Default pattern collection
  This is similar to the File->Change Pattern Collection command, but sets a default collection which will be loaded at program startup.

### 7.2. Preferences/View

Initial window size
  The dimensions (width x height) of the main window at startup.
Default zoom level
  The zoom level at startup.
Show by default
  These four checkboxes allow you to configure the appearance of the main window at startup. Any of the toolbar, sidebar, scrollbars, and status bar can be disabled. To turn components off temporarily, use the checkboxes in the "View" menu instead.
Start in fullscreen mode
  If this is checked, GtkLife will be in fullscreen mode at startup.
Colors
  Four colors are used for the Life viewport: background, live cells, visual grid (only drawn at zoom levels >= 4:1), and selection box (when cutting and pasting). Each of them is configurable: you can either type in a new color value (RRGGBB) directly in the text box, or click the "Select" button next to it to pop up a color chooser. To restore a particular color to its installed default, click the "Default" button.

### 7.3. Preferences/Run

Default speed
  The speed set when GtkLife starts up.
Speed slider range
  The lower and upper bounds for the speed slider in the toolbar. These are not absolute limits: a speed outside of this range can still be set by other means.
Speed increment
  The amount by which speed is increased or decreased by the "Faster" and "Slower" commands. This value also determines how fast the speed slider moves when you click in the trough.
Skip frames by default
  If this box is checked, frame skipping will be turned on when GtkLife starts up. Otherwise it will default to off, though you can reenable it for the session via the Run->Speed dialog.

### 7.4. Preferences/Help

Here you can choose a web browser with which to view the html help. Pick from several pre-configured options, or write your own command line. '$f' will be replaced with the URL of the help file. Shell characters are allowed, and should be escaped if meant literally.

## 8. Keybindings

Most menu operations in GtkLife have keyboard equivalents. The most common operations have one-character equivalents. Keybindings are displayed in the menus, but below is a list of the most useful and/or non-obvious ones. Note that NumLock must be on to use the numeric keypad.

As with any Gtk+ application, you can also set your own custom keybindings by typing a key combination while a menu item is highlighted. These bindings will be saved across program runs. (To use this capability under Gtk+ 2, you must add the line "gtk-can-change-accels = 1" to your ~/.gtkrc-2.0).

Key | Action
--- | ---
S | Start/stop the pattern
T | Step ahead one tick
J | Jump to a generation
D | View/edit pattern description
R | Reopen the current file
F | Toggle fullscreen mode
M | Move a block of cells
C | Change pattern collection
P | Edit preferences
Numeric keypad | Scroll the viewport in 8 directions
Ctrl-Keypad | Scroll by pages
Keypad-5 | Recenter at the middle of the world
+ and - (unshifted) | Zoom in and out, respectively
1, 2, 4, 8, Z | Zoom 1:1, 2:1, 4:1, 8:1, and 16:1, respectively
< and > (unshifted) | Slow down and speed up, respectively
Ctrl-1 through Ctrl-5 | Load a recently accessed file (Ctrl-1 is most recent)