17 KiB
Game of Life Sandbox — user guide
Commands below are run from the project folder.
Build an installable Arch Linux package with make package, then install the
result from dist/ using /usr/bin/pkexec pacman -U /path/to/package.pkg.tar.zst.
See RELEASE.md for dependencies, AUR publishing, and system/user
installation instructions. The application menu entry is Game of Life Sandbox;
the installed command is game-of-life-sandbox.
For portable use, ./run.sh compiles and launches the local game_of_life binary.
Requires GCC, make, OpenGL, GLUT and X11 development libraries. Python 3 is only
needed for the optional portable desktop launcher, not packaged builds.
Live cells are bright purple, dead cells dark purple, and text has a
shadow for readability. Control values stand out from their labels: On is green,
Off is red, and numbers and other selected values use the opposite hue from the
current theme.
App icon and launcher
Run ./build.sh to compile without launching. Open Game of Life Sandbox.desktop
to launch the compiled application with its purple glider icon. The window and
Linux taskbar icon are embedded in the executable, so they do not depend on an
external image at runtime. The SVG in assets/ supplies the desktop launcher icon.
Rebuild after moving the project to regenerate the launcher's paths.
Saved settings
Installed builds save preferences to
~/.config/game-of-life-sandbox/settings.cfg (or $XDG_CONFIG_HOME).
Portable builds save settings.cfg beside the executable. This includes
changes made with sliders, buttons, keyboard shortcuts, and window
resizing. Saves run in the background after 250 ms without further changes, so
sliders never wait for disk synchronization. Closing the program flushes the
latest pending changes. Preferences load before an empty, paused board is created at generation zero. This includes density,
resolution, speed, hue, brush width, tool/stamp selection, rotation, mirror/grid
modes, line snapping, circle anchor, pause-on-draw, looping/end generation,
sidebar visibility/category, and window size.
The file uses simple name=value lines, with 0/1 for booleans and # comments.
No JSON parser or external serialization library is needed. A missing file is
created with defaults. If the file contains malformed lines, invalid values,
duplicate/unknown fields, or an unsupported version, the game resets
to defaults and rewrites the file in its normal format. Omitted fields in an
otherwise valid file receive defaults. Saves use a temporary file and atomic
replacement; a failed save leaves the previous settings file intact and displays
an error. Edit the file while the game is closed if changing preferences manually.
Boards can be saved explicitly with Save/Open (below). Playback direction, undo/history, clipboard contents, and loop start snapshots are session-only. Paste mode reopens as Select because the clipboard is not saved. Startup always opens a blank, paused board. Use Board → Reseed to create a random board using your saved seed density, or open an existing board.
Controls slide in and out when toggled with Esc, H, or the Show/Hide button. The board view adjusts smoothly, and repeated toggles reverse the slide.
Clickable controls
Playback controls stay available in every category. Use Play forward / Pause, Play reverse / Pause reverse, Back, Step, and Restore start.
The Help tab lists keyboard shortcuts, drawing tips, playback behavior, and Life rules.
The sidebar is organized into four icon tabs with an active underline:
- Draw: tool picker, edit undo, clipboard placement, and options for the selected tool. Brush width appears for brushes and shapes; snapping only for Line; anchoring only for Circle; Copy only for Select; rotation for Stamp and Paste. Stamp mode displays a clickable gallery with pixel previews and names below.
- Board: Save/Open, example boards, starting density, resolution, Reseed, and Clear.
- View: hue, Rainbow Hue with a speed slider, and Off / Grid / Guidelines display options. Rainbow Hue cycles colors even while paused, at 1–180 degrees per second. Turning it off restores your selected hue. The toggle and speed are saved. Show top bar hides or restores the playback statistics and frees that space for the board. This preference is saved. H still restores the sidebar when both the sidebar and top bar are hidden.
- Help: shortcuts, drawing tips, playback behavior, and Life rules.
Scroll over the sidebar when the selected tool's controls exceed the window height.
Shift+Space or Play reverse starts reverse playback at the selected step interval. Repeat to pause reverse playback. It retraces every saved generation back to the beginning of the current timeline, with no fixed generation cutoff. Editing, reseeding, clearing, resizing, edit undo, and Restore start reset the timeline. Ordinary pause/resume and changing playback direction preserve it.
Conway's Life is not uniquely reversible: multiple boards can evolve into the same result. Exact reverse playback therefore records the actual past states. History is bit-packed in a temporary file (about 5 KB per generation at 200 x 200, or 20 KB at 400 x 400), rather than retaining full boards in RAM. The file is removed when the timeline resets or the game exits; it is not a saved game. If temporary storage cannot be written or read, the game pauses with a visible message. A failed write does not advance the simulation.
Restore start restores the cells, resolution, population, and generation saved immediately before the most recent forward Play/Space action, then pauses. Each new forward playback captures a fresh starting point; pausing or playing backward does not overwrite it. This snapshot is separate from generation history, so it survives long runs, reseeding, clearing, and resizing. Startup captures the initial board as well. The restore itself can be undone with Ctrl+Z.
Press M or click Back to restore one previous generation and pause. Repeat to rewind through recorded generations; the header shows how many are available. Reseeding, clearing, changing resolution, or editing cells resets history. At the oldest available generation, Back simply leaves the game paused. Drag the sliders to adjust:
- Step interval: 10–1000 ms (lower is faster).
- Starting density: 0–100%, in 5% increments. Click Reseed to apply it.
- Grid resolution: 25–400 cells per side, in increments of 25. Changes preserve the visible pattern using nearest-neighbor resampling.
- Brush width: 1–25 cells. Also controls eraser, line, and circle thickness.
- Color hue: 0–360 degrees, with a rainbow slider. Recolors live/dead cells, previews, and the controls immediately, preserving brightness contrast. Purple (hue 275) is the default; changing color does not change the simulation or history.
Click Hide controls / Show controls in the header to toggle the sidebar. Scroll over the sidebar to reach all controls in shorter windows.
Save and open boards
Use Board → Save / Open, or Ctrl+S / Ctrl+O. Save opens a name field
in the sidebar: type a name and press Enter or click Save board. The .life
extension is added automatically. Existing names require an explicit replacement
confirmation. Installed builds save your boards in ~/.local/share/game-of-life-sandbox/boards/
(or $XDG_DATA_HOME). Portable builds save them in boards/.
Open slides to a scrollable gallery of your saved boards with miniature previews.
Click a preview to load it, or Open File to browse elsewhere using the native
KDE dialog (kdialog required only for that button). Examples opens a separate
preview gallery of bundled boards (installed under /usr/share/game-of-life-sandbox/examples/,
or boards/examples/ for portable builds). Back returns to the
previous controls and scroll position. Escape hides or shows the sidebar without leaving its page. Previews and file
operations load in background workers so the window stays responsive.
Board files store the exact cells, square grid resolution, and generation. Opening a board pauses playback, resets generation history, creates a fresh Restore Start snapshot, and can be undone with Ctrl+Z. Settings such as hue and speed stay as selected. Invalid files leave the current board untouched. Saves replace the chosen file atomically.
The .life format is plain text and is deliberately simple:
#Life 1.06
#BOARD 200 0
# Optional comments; remaining lines are live-cell column/row coordinates.
100 99
101 100
99 101
100 101
101 101
#BOARD contains the grid size (25–400, in steps of 25) and saved generation.
Coordinates start at zero in the top-left corner. This metadata line is required
by this app, in addition to the Life 1.06 header; dead cells are implicit.
The Board tab’s Examples gallery contains twenty example boards. See boards/examples/README.md for what each does. You can modify an example and use Save to keep your own version. The Sierpinski example is a fractal starting pattern, not a different cellular automaton rule: all examples evolve using Conway's original Life rules.
The old settings.json is retained as a backup; the game now reads settings.cfg.
Your existing preferences have been migrated to the new file.
Looping
In Playback, click Looping: on, click End and type a generation number (default 100), then press Enter or click Play. The - / + buttons adjust it one generation at a time. Values from 1 to 999999999 are supported.
Play loop records the current generation as the start, evolves to the end generation, reverses to that start, and repeats continuously. For example, starting at Gen 0 with End 360 gives 0 → 360 → 0 → 360. Starting at Gen 100 with the same end loops between 100 and 360. The end must be greater than the starting generation.
- Pause / Space pauses either direction. Play/Space resumes the same loop, preserving its start and the Restore Start snapshot.
- Restore start stops and restores the board from the beginning of the loop.
- Turning looping off leaves normal playback running in its current direction.
- Changing End pauses playback; the next Play establishes a new range.
- Editing, reseeding, resizing, restoring, or manually stepping ends the active loop. Play starts a new one from the resulting board.
Automatic turnarounds do not create new start snapshots or undo entries. History storage is reused each cycle, rather than growing indefinitely. A history storage error pauses the loop with a message.
Board zoom
Hold Ctrl and scroll over the board to zoom in or out around the pointer (100%–1600%). Drawing, stamps, selections, and grid lines follow the zoom. Use View → Reset zoom to fit the entire board again. Zoom does not change resolution, cells, generation, or playback. Zoom is held steady during a drawing stroke; release the mouse before zooming.
Drawing and stamps
Select a tool, then use the board. Pause on draw is on by default: editing pauses the simulation until you click Play forward. Turn it off to keep the simulation running while drawing or placing stamps. If already paused, it stays paused. The toggle applies to all drawing tools, including erasing.
- Brush: drag to paint continuous strokes with a square brush.
- Eraser: drag to remove cells. Right-drag also erases with the Brush tool.
- Line: drag from start to end, then release to commit the preview. By default, lines snap to horizontal, vertical, or 45-degree diagonals. Click Line snap for free angles. Right-drag erases a line. Releasing outside the board commits it at the nearest edge.
- Circle: click at the center, drag out to the desired radius, then release to draw a circular outline. The preview follows your drag; brush width sets thickness. Click Circle anchor: center / corner to change the anchor. Center mode draws a round circle as before. Corner mode uses your starting point and release point as opposite corners of a bounding box, letting you draw wide or tall ellipses in any drag direction. Hold Ctrl while dragging to constrain the bounding box to a square and draw a perfect circle; release Ctrl to stretch again. This also works when erasing. Right-drag erases an outline. Releasing outside the board commits it at the nearest edge.
- Stamp: select a formation, move over the board to preview, and click to place. Choose Glider, lightweight spaceship, Blinker, Toad, Beacon, Pulsar, R-pentomino, Acorn, or Gosper Glider Gun. Rotate turns patterns 90 degrees. Stamps retain their natural cell dimensions regardless of brush width.
Stamps add live cells without clearing their surrounding area. Use Clear board first to observe a formation on its own. Drawing and stamps clip at board edges; the simulation itself wraps around the edges.
Undo, selection, and copy/paste
- Ctrl+Z or Undo restores the board before the last edit and pauses. Up to 32 edits are retained. A continuous brush/eraser stroke is one edit; stamp and paste placements, committed shapes, clears, reseeds, and resolution changes can also be undone. A canceled shape or unchanged stroke adds no entry. If the simulation ran after an edit, undo restores the entire pre-edit board, including its generation and resolution. M / Back remains a separate generation rewind; edit undo resets that generation history.
- Choose Select, then drag a rectangle in either direction. Its border stays visible. Copy / Ctrl+C captures the current cells within that rectangle.
- Paste / Ctrl+V switches to placement mode: hover to preview, then click to paste. Both live and dead cells replace the destination rectangle. You can place the same copy repeatedly or rotate it with Rotate. The clipboard is internal to the game and survives clear/reseed/resize.
- Esc hides or shows the controls. It ends any unfinished drawing gesture or loop-end entry before resizing the board view; it never quits the app.
Selection follows the pause-on-draw setting. If the game keeps running, Copy captures the selected region as it exists when you click Copy.
Mirror and grid guides
Click Mirror to cycle through Off, Horizontal, Vertical, and Both. Horizontal duplicates edits left/right across the board center; Vertical duplicates them top/bottom; Both creates all four reflections. With Grid enabled, center guides show the active symmetry axes. Mirroring applies to brush strokes, erasing, lines, circles, ellipses, stamps, and paste placements, including previews. It does not retroactively change existing cells or the simulation rules. This replaces the old stamp-only flip switch.
The grid button cycles through Off, Grid, and Guidelines. Off hides all grid and center guides. Grid shows individual cell boundaries (and active mirror axes); Guidelines shows only the horizontal and vertical center axes. Lower grid resolutions make cell boundaries easier to distinguish. Neither the grid nor mirror setting changes cells or consumes undo history.
Optional keyboard shortcuts
| Key | Action |
|---|---|
| B / E | Brush / Eraser |
| L / O | Line / Circle (oval) |
| S / V | Stamp / Select |
| P | Paste copied cells (also Ctrl+V) |
| 1–9 | Choose a stamp in gallery order |
| , / . | Decrease / increase brush size |
| T / Shift+T | Rotate stamp or paste clockwise / counterclockwise |
| X | Cycle mirror: Off, Horizontal, Vertical, Both |
| G | Cycle grid: Off, Grid, Guidelines |
| 0 | Reset zoom |
Tool shortcuts also work with the sidebar hidden. Typing a board name or loop end takes priority over shortcuts. Switching tools cancels an unfinished shape.
All simulation settings are available with the mouse. Existing shortcuts remain: Space toggles forward playback, Shift+Space toggles reverse playback, N steps forward, M steps back, R restores the playback start, C clears, H toggles the sidebar, Up/Down adjust speed, -/+ adjust resolution, and Esc hides or shows the controls. The [ / ] shortcuts adjust starting density and reseed immediately.
Verification
Run all checks with make check (requires Xvfb, xauth, libXtst, and desktop-file-utils).
This includes real Ctrl/mouse input, installed XDG paths, app identity, and launcher validation.
Compile and run the interaction and rendering tests with a virtual X display:
gcc -std=c11 -Wall -Wextra -Wpedantic -fsanitize=address,undefined -g -pthread tests/test_game.c -o /tmp/test_life_tools -lGL -lglut -lX11
ASAN_OPTIONS=detect_leaks=0 xvfb-run -a /tmp/test_life_tools
The tests cover stamps and transforms, clipped brush footprints, line drawing, continuous strokes, sliders, mouse routing, sidebar scrolling, generation history, circle outlines, hue changes, edit undo, selection/copy/paste, mirror modes, grid lines, contextual categories, reverse playback, start restoration, 5,000-generation full rewinds, history branching, storage failures, repeated looping with exact turnarounds, and GL rendering.
Preference storage can also be tested without a display:
gcc -std=c11 -Wall -Wextra -Wpedantic -fsanitize=address,undefined -g -pthread tests/test_settings.c -o /tmp/test_life_settings -lGL -lglut -lX11
ASAN_OPTIONS=detect_leaks=0 /tmp/test_life_settings
Board file tests (no display required; run from the project directory):
gcc -std=c11 -Wall -Wextra -Wpedantic -fsanitize=address,undefined -g -pthread tests/test_boards.c -o /tmp/test_life_boards -lGL -lglut -lX11
ASAN_OPTIONS=detect_leaks=0 /tmp/test_life_boards