pbmlife
Simulate Conway's Game of Life using PBM images
TLDR
Apply the Rules of Life to an input PBM image file for one generation and the output the result as a PBM image file
Display version
SYNOPSIS
pbmlife [-generations N] [-speed N] [-newborn RULE] [-sick RULE] [pbmfile]
PARAMETERS
-generations N
Simulates the game for N generations. The default is 100 generations.
-speed N
Outputs an image every N generations. A value of 1 outputs every generation, while higher values skip intermediate states. The default is 1.
-newborn RULE
Specifies the rule for a dead cell to become alive (birth rule). RULE is a comma-separated list of digits representing the exact number of live neighbors a dead cell must have to become alive. The default is '3' (a dead cell with exactly 3 live neighbors becomes alive).
-sick RULE
Specifies the rule for an alive cell to survive (survival rule). RULE is a comma-separated list of digits representing the exact number of live neighbors an alive cell must have to remain alive. If an alive cell doesn't meet this rule, it dies. The default is '2,3' (an alive cell with 2 or 3 live neighbors survives).
pbmfile
The path to the input PBM image file. If omitted, pbmlife reads the PBM data from standard input.
DESCRIPTION
pbmlife is a utility from the Netpbm toolkit that simulates Conway's Game of Life. It interprets an input Portable BitMap (PBM) image, where white pixels represent 'alive' cells and black pixels represent 'dead' cells, as the initial state for the cellular automaton. The program then applies the classic rules of Conway's Game of Life, or custom variations thereof, for a specified number of generations.
The primary output is a new PBM image reflecting the final state after the simulation. Users can control parameters such as the number of generations to simulate, the frequency of outputting intermediate states, and even modify the birth and survival rules of the game. It provides a visual and interactive way to explore cellular automata, demonstrating how complex patterns and behaviors can emerge from simple underlying rules.
CAVEATS
pbmlife exclusively processes PBM (Portable BitMap) format files. Input images in other Netpbm formats (PGM, PPM) or other image formats must be converted to PBM beforehand. Complex or large initial patterns, combined with a high number of generations, can lead to significant processing time and memory consumption.
INPUT INTERPRETATION
In the input PBM image, white pixels are treated as 'alive' cells and black pixels as 'dead' cells. The dimensions of the PBM image define the grid size for the simulation.
DEFAULT GAME OF LIFE RULES
By default, pbmlife implements the standard Conway's Game of Life rules (often denoted B3/S23):
- Any live cell with fewer than two live neighbours dies (underpopulation).
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies (overpopulation).
- Any dead cell with exactly three live neighbours becomes a live cell (reproduction).
These correspond to the default -newborn 3 and -sick 2,3 parameters.
HISTORY
Conway's Game of Life, the cellular automaton that pbmlife simulates, was created by British mathematician John Horton Conway in 1970. It quickly became a classic example of emergent behavior in simple rule-based systems. pbmlife itself is part of the Netpbm project, a comprehensive suite of graphics manipulation tools for Unix-like systems. Netpbm evolved from Jef Poskanzer's `pbmplus` package, first released in the late 1980s, which standardized the PBM, PGM, and PPM image formats. pbmlife integrates this classic mathematical concept with a widely adopted image format, providing a practical way to visualize cellular automata within the command-line environment.