Initial release of Game of Life Sandbox
This commit is contained in:
commit
8d622ce33c
49 files changed
+18671
No files matched your search
@@ -0,0 +1,24 @@
|
||||
pkgbase = game-of-life-sandbox-git
|
||||
pkgdesc = Interactive Conway's Game of Life sandbox with drawing tools and board libraries
|
||||
pkgver = 0.1.0.r5.g3f94533
|
||||
pkgrel = 1
|
||||
url = https://github.com/Zebratic/Cool-C
|
||||
arch = x86_64
|
||||
arch = aarch64
|
||||
license = MIT
|
||||
checkdepends = desktop-file-utils
|
||||
checkdepends = xorg-server-xvfb
|
||||
checkdepends = xorg-xauth
|
||||
checkdepends = libxtst
|
||||
makedepends = git
|
||||
depends = glibc
|
||||
depends = freeglut
|
||||
depends = libglvnd
|
||||
depends = libx11
|
||||
optdepends = kdialog: native Open File dialog; saved boards and examples work without it
|
||||
provides = game-of-life-sandbox
|
||||
conflicts = game-of-life-sandbox
|
||||
source = cool-c::git+https://github.com/Zebratic/Cool-C.git
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = game-of-life-sandbox-git
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/game_of_life
|
||||
/game-of-life-sandbox
|
||||
/Game of Life Sandbox.desktop
|
||||
/build/
|
||||
/dist/
|
||||
/src/
|
||||
/pkg/
|
||||
/*.pkg.tar.*
|
||||
/settings.cfg
|
||||
/settings.json
|
||||
/settings.cfg.tmp.*
|
||||
/boards/*.life
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Zebratic and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,77 @@
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
DATADIR ?= $(PREFIX)/share
|
||||
DESTDIR ?=
|
||||
CC ?= cc
|
||||
CFLAGS ?= -O2 -g
|
||||
CPPFLAGS ?=
|
||||
LDFLAGS ?=
|
||||
VERSION := $(shell cat VERSION)
|
||||
WARNINGS := -std=c11 -Wall -Wextra -Wpedantic
|
||||
LIBS := -lGL -lglut -lX11
|
||||
SOURCES := game_of_life.c $(wildcard *.h *.inc)
|
||||
TESTS := test_game test_settings test_boards test_app_identity test_circle_input test_paths
|
||||
DIST_NAME := game-of-life-sandbox-$(VERSION)
|
||||
DIST_FILES := VERSION Makefile LICENSE README.md RELEASE.md PKGBUILD .SRCINFO \
|
||||
game_of_life.c $(wildcard *.h *.inc) build.sh run.sh .gitignore \
|
||||
$(wildcard assets/* scripts/* tests/*.c) boards/examples/*.life boards/examples/README.md
|
||||
|
||||
.PHONY: all portable check install uninstall clean dist package FORCE
|
||||
all: game-of-life-sandbox
|
||||
|
||||
game-of-life-sandbox: $(SOURCES) VERSION Makefile build/install-path
|
||||
$(CC) $(CPPFLAGS) -DAPP_PORTABLE=0 -DAPP_VERSION='"$(VERSION)"' \
|
||||
-DAPP_DATA_DIR='"$(DATADIR)/game-of-life-sandbox"' $(CFLAGS) $(WARNINGS) \
|
||||
-pthread game_of_life.c -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
portable: game_of_life
|
||||
|
||||
game_of_life: $(SOURCES) VERSION Makefile
|
||||
$(CC) $(CPPFLAGS) -DAPP_PORTABLE=1 -DAPP_VERSION='"$(VERSION)"' \
|
||||
$(CFLAGS) $(WARNINGS) -pthread game_of_life.c -o $@ $(LDFLAGS) $(LIBS)
|
||||
|
||||
build:
|
||||
mkdir -p build
|
||||
|
||||
# Rebuild if PREFIX/DATADIR changes, including when installing a local build.
|
||||
build/install-path: FORCE | build
|
||||
@printf '%s\n' '$(DATADIR)' > build/install-path.tmp
|
||||
@if ! cmp -s build/install-path.tmp $@; then mv build/install-path.tmp $@; else rm build/install-path.tmp; fi
|
||||
|
||||
build/test_%: tests/test_%.c $(SOURCES) Makefile | build
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(WARNINGS) -pthread $< -o $@ $(LDFLAGS) $(LIBS) $(if $(filter test_circle_input,$(@F)),-lXtst,)
|
||||
|
||||
check: $(addprefix build/,$(TESTS))
|
||||
./build/test_settings
|
||||
./build/test_boards
|
||||
./build/test_paths
|
||||
xvfb-run -a -s '-screen 0 1280x1024x24' ./build/test_game
|
||||
xvfb-run -a -s '-screen 0 1280x1024x24' ./build/test_app_identity
|
||||
xvfb-run -a -s '-screen 0 1280x1024x24' ./build/test_circle_input
|
||||
desktop-file-validate assets/game-of-life-sandbox.desktop
|
||||
|
||||
install: all
|
||||
install -Dm755 game-of-life-sandbox "$(DESTDIR)$(BINDIR)/game-of-life-sandbox"
|
||||
install -Dm644 assets/game-of-life-sandbox.desktop "$(DESTDIR)$(DATADIR)/applications/game-of-life-sandbox.desktop"
|
||||
install -Dm644 assets/game-of-life-sandbox.svg "$(DESTDIR)$(DATADIR)/icons/hicolor/scalable/apps/game-of-life-sandbox.svg"
|
||||
install -d "$(DESTDIR)$(DATADIR)/game-of-life-sandbox/examples"
|
||||
install -m644 boards/examples/*.life boards/examples/README.md "$(DESTDIR)$(DATADIR)/game-of-life-sandbox/examples/"
|
||||
install -Dm644 LICENSE "$(DESTDIR)$(DATADIR)/licenses/game-of-life-sandbox/LICENSE"
|
||||
install -Dm644 README.md "$(DESTDIR)$(DATADIR)/doc/game-of-life-sandbox/README.md"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(BINDIR)/game-of-life-sandbox"
|
||||
rm -f "$(DESTDIR)$(DATADIR)/applications/game-of-life-sandbox.desktop"
|
||||
rm -f "$(DESTDIR)$(DATADIR)/icons/hicolor/scalable/apps/game-of-life-sandbox.svg"
|
||||
rm -rf "$(DESTDIR)$(DATADIR)/game-of-life-sandbox" "$(DESTDIR)$(DATADIR)/licenses/game-of-life-sandbox" "$(DESTDIR)$(DATADIR)/doc/game-of-life-sandbox"
|
||||
|
||||
clean:
|
||||
rm -f game-of-life-sandbox game_of_life
|
||||
rm -rf build
|
||||
|
||||
dist:
|
||||
mkdir -p dist
|
||||
tar --transform='s,^,$(DIST_NAME)/,' -czf dist/$(DIST_NAME).tar.gz $(DIST_FILES)
|
||||
|
||||
package:
|
||||
./scripts/package-local.sh
|
||||
@@ -0,0 +1,34 @@
|
||||
# Maintainer: Zebratic (https://github.com/Zebratic)
|
||||
pkgname=game-of-life-sandbox-git
|
||||
pkgver=0.1.0.r5.g3f94533
|
||||
pkgrel=1
|
||||
pkgdesc="Interactive Conway's Game of Life sandbox with drawing tools and board libraries"
|
||||
arch=('x86_64' 'aarch64')
|
||||
url='https://github.com/Zebratic/Cool-C'
|
||||
license=('MIT')
|
||||
depends=('glibc' 'freeglut' 'libglvnd' 'libx11')
|
||||
makedepends=('git')
|
||||
checkdepends=('desktop-file-utils' 'xorg-server-xvfb' 'xorg-xauth' 'libxtst')
|
||||
optdepends=('kdialog: native Open File dialog; saved boards and examples work without it')
|
||||
provides=('game-of-life-sandbox')
|
||||
conflicts=('game-of-life-sandbox')
|
||||
source=('cool-c::git+https://github.com/Zebratic/Cool-C.git')
|
||||
sha256sums=('SKIP')
|
||||
_srcdir='cool-c/game-of-life'
|
||||
|
||||
pkgver() {
|
||||
cd "$srcdir/cool-c"
|
||||
printf '%s.r%s.g%s' "$(cat game-of-life/VERSION)" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
build() {
|
||||
make -C "$srcdir/$_srcdir" PREFIX=/usr
|
||||
}
|
||||
|
||||
check() {
|
||||
make -C "$srcdir/$_srcdir" PREFIX=/usr check
|
||||
}
|
||||
|
||||
package() {
|
||||
make -C "$srcdir/$_srcdir" PREFIX=/usr DESTDIR="$pkgdir" install
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
# Game of Life Sandbox
|
||||
|
||||
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](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:
|
||||
|
||||
```text
|
||||
#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](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:
|
||||
|
||||
```sh
|
||||
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:
|
||||
|
||||
```sh
|
||||
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):
|
||||
|
||||
```sh
|
||||
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
|
||||
```
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
# Packaging and releasing Game of Life Sandbox
|
||||
|
||||
The initial release version is `0.1.0` (`VERSION`). The root `PKGBUILD` and
|
||||
`.SRCINFO` describe the AUR development package `game-of-life-sandbox-git`, using
|
||||
`https://github.com/Zebratic/Cool-C.git`, subdirectory `game-of-life/`.
|
||||
|
||||
## Build a package from this checkout
|
||||
|
||||
On Arch Linux, install build and test dependencies if they are missing:
|
||||
|
||||
```sh
|
||||
/usr/bin/pkexec pacman -S --needed base-devel git freeglut libglvnd libx11 desktop-file-utils xorg-server-xvfb xorg-xauth libxtst
|
||||
```
|
||||
|
||||
Then, as your normal user:
|
||||
|
||||
```sh
|
||||
make package
|
||||
```
|
||||
|
||||
This creates a source archive and a pacman package in `dist/`. Only explicit
|
||||
source files and bundled examples enter the archive: local settings, saved
|
||||
boards, compiled binaries, and generated launchers are excluded. The build runs
|
||||
the unit and virtual-display tests. No privileges or system installation are
|
||||
performed by `make package`.
|
||||
|
||||
Install the generated package, using its exact filename:
|
||||
|
||||
```sh
|
||||
/usr/bin/pkexec pacman -U /absolute/path/to/game-of-life-sandbox-0.1.0-1-x86_64.pkg.tar.zst
|
||||
```
|
||||
|
||||
Launch **Game of Life Sandbox** from the application menu, or run
|
||||
`game-of-life-sandbox`. Optional `kdialog` enables **Open File**. Neither named
|
||||
saves nor either board gallery needs it. Uninstall with:
|
||||
|
||||
```sh
|
||||
/usr/bin/pkexec pacman -R game-of-life-sandbox
|
||||
```
|
||||
|
||||
Uninstalling leaves your settings and saved boards intact.
|
||||
|
||||
## Install layout
|
||||
|
||||
- `/usr/bin/game-of-life-sandbox`
|
||||
- `/usr/share/applications/game-of-life-sandbox.desktop`
|
||||
- `/usr/share/icons/hicolor/scalable/apps/game-of-life-sandbox.svg`
|
||||
- `/usr/share/game-of-life-sandbox/examples/`
|
||||
- `/usr/share/licenses/game-of-life-sandbox/LICENSE`
|
||||
- `/usr/share/doc/game-of-life-sandbox/README.md`
|
||||
|
||||
Installed builds store settings in
|
||||
`${XDG_CONFIG_HOME:-$HOME/.config}/game-of-life-sandbox/settings.cfg` and your boards
|
||||
in `${XDG_DATA_HOME:-$HOME/.local/share}/game-of-life-sandbox/boards/`. Only absolute
|
||||
XDG base paths are accepted; relative values use the standard HOME fallback.
|
||||
The app creates these directories with private permissions. Bundled examples are
|
||||
read from the installed, read-only data directory.
|
||||
|
||||
`./run.sh` and `./build.sh` retain the portable `game_of_life` executable with
|
||||
settings and boards beside it. To carry existing portable data into an installed
|
||||
copy, close both copies, then copy `settings.cfg` and your `boards/*.life` files
|
||||
to the respective per-user paths above. Do not copy bundled examples there.
|
||||
|
||||
## Makefile usage
|
||||
|
||||
```sh
|
||||
make PREFIX=/usr
|
||||
make check
|
||||
make PREFIX=/usr DESTDIR=/tmp/life-stage install
|
||||
```
|
||||
|
||||
`DESTDIR` stages files without changing their compiled-in runtime prefix. Changing
|
||||
`PREFIX` or `DATADIR` rebuilds the installed binary to use the matching data path.
|
||||
For an installation without administrator access:
|
||||
|
||||
```sh
|
||||
make PREFIX="$HOME/.local" install
|
||||
```
|
||||
|
||||
Make sure `$HOME/.local/bin` is on your PATH. `make ... uninstall` removes the
|
||||
installed program and bundled files; it never removes XDG user data. On Arch,
|
||||
prefer the pacman package so the package manager tracks ownership.
|
||||
|
||||
## AUR publication checklist
|
||||
|
||||
1. Review the proposed MIT license in `LICENSE` before publishing. If you choose
|
||||
another license, update both its full text and the `license` field in `PKGBUILD`.
|
||||
2. Commit and push the source, Makefile, assets, examples, tests, and packaging
|
||||
changes to `Zebratic/Cool-C`. AUR builds fetch that remote, not this working
|
||||
tree. A package is not ready for public builds until these files are pushed.
|
||||
3. In a fresh checkout, run `makepkg` in `game-of-life/` to test the VCS source
|
||||
download, build, tests, and package. Verify the package in a clean Arch chroot
|
||||
with `devtools` before submission. Only local x86_64 builds are validated here.
|
||||
4. Regenerate `.SRCINFO` with `makepkg --printsrcinfo > .SRCINFO`. The `pkgver()`
|
||||
function derives the version from `VERSION`, Git revision count, and commit.
|
||||
5. Check the AUR for a pre-existing package with the same name. Clone your AUR
|
||||
repository and commit only `PKGBUILD` and `.SRCINFO`; do not upload binaries,
|
||||
sources, personal settings, or saved boards to AUR.
|
||||
6. Review and push the AUR commit with your AUR SSH credentials. This workspace
|
||||
preparation does not publish to GitHub or AUR.
|
||||
|
||||
For later releases, update `VERSION`, document changes, build/test again, and tag
|
||||
upstream (for example `game-of-life-sandbox-v0.1.0`). The AUR `-git` package follows
|
||||
HEAD; `make package` creates the fixed-version package from the current checkout.
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef APP_IDENTITY_H
|
||||
#define APP_IDENTITY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define APP_NAME "Game of Life Sandbox"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <GL/glx.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* EWMH icons are embedded ARGB pixels, independent of files beside the binary.
|
||||
The geometry and colors match assets/game-of-life-sandbox.svg. */
|
||||
static unsigned long appIconPixel(int x, int y, int size) {
|
||||
int scale = size / 64;
|
||||
x /= scale;
|
||||
y /= scale;
|
||||
int dx = x < 12 ? 12 - x : x > 51 ? x - 51 : 0;
|
||||
int dy = y < 12 ? 12 - y : y > 51 ? y - 51 : 0;
|
||||
if (dx * dx + dy * dy > 144) return 0;
|
||||
unsigned long color = 0xff160b25UL;
|
||||
if (x >= 8 && x < 56 && y >= 8 && y < 56) {
|
||||
int col = (x - 8) / 10, row = (y - 8) / 10;
|
||||
if ((x - 8) % 10 < 8 && (y - 8) % 10 < 8) {
|
||||
bool live = (col == 2 && row == 1) || (col == 3 && row == 2)
|
||||
|| (row == 3 && col >= 1 && col <= 3);
|
||||
color = live ? 0xffc58affUL : 0xff352047UL;
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
static void setAppIdentity(void) {
|
||||
Display *display = glXGetCurrentDisplay();
|
||||
Window window = (Window)glXGetCurrentDrawable();
|
||||
if (!display || !window) return;
|
||||
XClassHint identity = {"game-of-life-sandbox", "GameOfLifeSandbox"};
|
||||
XSetClassHint(display, window, &identity);
|
||||
XSetIconName(display, window, APP_NAME);
|
||||
/* Xlib expects machine-word storage for format-32 properties on 64-bit Linux. */
|
||||
unsigned long pixels[2 + 64 * 64 + 2 + 128 * 128];
|
||||
int used = 0;
|
||||
for (int size = 64; size <= 128; size *= 2) {
|
||||
pixels[used++] = (unsigned long)size;
|
||||
pixels[used++] = (unsigned long)size;
|
||||
for (int y = 0; y < size; ++y)
|
||||
for (int x = 0; x < size; ++x) pixels[used++] = appIconPixel(x, y, size);
|
||||
}
|
||||
XChangeProperty(display, window, XInternAtom(display, "_NET_WM_ICON", False),
|
||||
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pixels, used);
|
||||
XFlush(display);
|
||||
}
|
||||
#else
|
||||
static void setAppIdentity(void) { }
|
||||
#endif
|
||||
#endif
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#ifndef APP_PATHS_H
|
||||
#define APP_PATHS_H
|
||||
|
||||
/* Direct/local builds stay portable; distribution builds use XDG storage. */
|
||||
#ifndef APP_PORTABLE
|
||||
#define APP_PORTABLE 1
|
||||
#endif
|
||||
#ifndef APP_DATA_DIR
|
||||
#define APP_DATA_DIR "/usr/share/game-of-life-sandbox"
|
||||
#endif
|
||||
#ifndef APP_VERSION
|
||||
#define APP_VERSION "0.1.0"
|
||||
#endif
|
||||
|
||||
#if !APP_PORTABLE
|
||||
static char userBoardsDirectory[PATH_MAX];
|
||||
|
||||
static bool makeUserDirectory(const char *path) {
|
||||
char copy[PATH_MAX];
|
||||
if (strlen(path) >= sizeof(copy)) return false;
|
||||
snprintf(copy, sizeof(copy), "%s", path);
|
||||
for (char *p = copy + 1; ; ++p) {
|
||||
if (*p != '/' && *p != '\0') continue;
|
||||
char saved = *p;
|
||||
*p = '\0';
|
||||
if (mkdir(copy, 0700) != 0 && errno != EEXIST) return false;
|
||||
struct stat info;
|
||||
if (stat(copy, &info) != 0 || !S_ISDIR(info.st_mode)) return false;
|
||||
*p = saved;
|
||||
if (!saved) break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool userAppDirectory(char output[PATH_MAX], const char *variable, const char *fallback) {
|
||||
const char *base = getenv(variable);
|
||||
int count;
|
||||
if (base && base[0] == '/') {
|
||||
count = snprintf(output, PATH_MAX, "%s/game-of-life-sandbox", base);
|
||||
} else {
|
||||
const char *home = getenv("HOME");
|
||||
if (!home || home[0] != '/') return false;
|
||||
count = snprintf(output, PATH_MAX, "%s/%s/game-of-life-sandbox", home, fallback);
|
||||
}
|
||||
return count >= 0 && count < PATH_MAX && makeUserDirectory(output);
|
||||
}
|
||||
|
||||
static bool initializeUserPaths(char configPath[PATH_MAX]) {
|
||||
char configDirectory[PATH_MAX], dataDirectory[PATH_MAX];
|
||||
if (!userAppDirectory(configDirectory, "XDG_CONFIG_HOME", ".config")
|
||||
|| !userAppDirectory(dataDirectory, "XDG_DATA_HOME", ".local/share")) return false;
|
||||
int configLength = snprintf(configPath, PATH_MAX, "%s/settings.cfg", configDirectory);
|
||||
int boardLength = snprintf(userBoardsDirectory, PATH_MAX, "%s/boards", dataDirectory);
|
||||
return configLength > 0 && configLength < PATH_MAX
|
||||
&& boardLength > 0 && boardLength < PATH_MAX
|
||||
&& makeUserDirectory(userBoardsDirectory);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Game of Life Sandbox
|
||||
Comment=Draw, experiment, and explore Conway's Game of Life
|
||||
Exec=game-of-life-sandbox
|
||||
Icon=game-of-life-sandbox
|
||||
Terminal=false
|
||||
Categories=Game;Simulation;
|
||||
Keywords=Conway;Life;Cells;Automaton;Sandbox;
|
||||
StartupNotify=false
|
||||
StartupWMClass=GameOfLifeSandbox
|
||||
@@ -0,0 +1,13 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 64 64">
|
||||
<title>Game of Life Sandbox</title>
|
||||
<rect width="64" height="64" rx="12" fill="#160b25"/>
|
||||
<defs>
|
||||
<pattern id="cells" x="8" y="8" width="10" height="10" patternUnits="userSpaceOnUse">
|
||||
<rect width="8" height="8" fill="#352047"/>
|
||||
</pattern>
|
||||
</defs>
|
||||
<path fill="url(#cells)" d="M8 8h48v48H8z"/>
|
||||
<g fill="#c58aff">
|
||||
<path d="M28 18h8v8h-8zM38 28h8v8h-8zM18 38h8v8h-8zM28 38h8v8h-8zM38 38h8v8h-8z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 523 B |
@@ -0,0 +1,189 @@
|
||||
/* Board libraries are scanned off the UI thread, with compact cached previews. */
|
||||
#define BOARD_THUMB_SIZE 96
|
||||
typedef struct {
|
||||
char path[PATH_MAX], name[256];
|
||||
unsigned char preview[BOARD_THUMB_SIZE * BOARD_THUMB_SIZE];
|
||||
int resolution, population;
|
||||
} BoardEntry;
|
||||
typedef struct {
|
||||
BoardEntry *items;
|
||||
size_t count;
|
||||
bool ready;
|
||||
char message[100];
|
||||
} BoardCatalog;
|
||||
static BoardCatalog catalogs[2], catalogResult;
|
||||
static pthread_t catalogThread;
|
||||
static pthread_mutex_t catalogMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static bool catalogBusy, catalogDone;
|
||||
static int catalogWhich, catalogPending = -1;
|
||||
static char catalogDirectory[PATH_MAX];
|
||||
|
||||
static bool appendBoardEntry(const char *path, const char *name) {
|
||||
EditSnapshot board;
|
||||
char error[160];
|
||||
if (!readBoardFile(path, &board, error)) {
|
||||
snprintf(catalogResult.message, sizeof(catalogResult.message), "Some unreadable boards skipped.");
|
||||
return true;
|
||||
}
|
||||
BoardEntry *items = realloc(catalogResult.items, (catalogResult.count + 1) * sizeof(*items));
|
||||
if (!items) {
|
||||
snprintf(catalogResult.message, sizeof(catalogResult.message), "Not enough memory for more boards.");
|
||||
return false;
|
||||
}
|
||||
catalogResult.items = items;
|
||||
BoardEntry *entry = &items[catalogResult.count++];
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
snprintf(entry->path, sizeof(entry->path), "%s", path);
|
||||
snprintf(entry->name, sizeof(entry->name), "%s", name);
|
||||
entry->resolution = board.resolution;
|
||||
entry->population = board.population;
|
||||
/* Fit the occupied bounds so small formations remain legible in the gallery. */
|
||||
int minX = board.resolution, minY = board.resolution, maxX = -1, maxY = -1;
|
||||
for (int y = 0; y < board.resolution; ++y)
|
||||
for (int x = 0; x < board.resolution; ++x)
|
||||
if (board.cells[y * board.resolution + x]) {
|
||||
if (x < minX) minX = x;
|
||||
if (x > maxX) maxX = x;
|
||||
if (y < minY) minY = y;
|
||||
if (y > maxY) maxY = y;
|
||||
}
|
||||
int width = maxX - minX + 1, height = maxY - minY + 1;
|
||||
int span = (width > height ? width : height) + 4;
|
||||
if (span < 8) span = 8;
|
||||
int originX = minX - (span - width) / 2, originY = minY - (span - height) / 2;
|
||||
for (int y = minY; y <= maxY; ++y)
|
||||
for (int x = minX; x <= maxX; ++x)
|
||||
if (board.cells[y * board.resolution + x]) {
|
||||
int x0 = (x - originX) * BOARD_THUMB_SIZE / span;
|
||||
int y0 = (y - originY) * BOARD_THUMB_SIZE / span;
|
||||
int x1 = (x + 1 - originX) * BOARD_THUMB_SIZE / span;
|
||||
int y1 = (y + 1 - originY) * BOARD_THUMB_SIZE / span;
|
||||
if (x1 <= x0) x1 = x0 + 1;
|
||||
if (y1 <= y0) y1 = y0 + 1;
|
||||
for (int py = y0; py < y1; ++py)
|
||||
for (int px = x0; px < x1; ++px)
|
||||
entry->preview[py * BOARD_THUMB_SIZE + px] = 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int compareBoardEntries(const void *a, const void *b) {
|
||||
return strcmp(((const BoardEntry *)a)->name, ((const BoardEntry *)b)->name);
|
||||
}
|
||||
|
||||
static void *scanBoardCatalog(void *unused) {
|
||||
(void)unused;
|
||||
char path[PATH_MAX];
|
||||
if (catalogWhich == 0) {
|
||||
for (int i = 0; i < EXAMPLE_COUNT; ++i) {
|
||||
if (snprintf(path, sizeof(path), "%s%s", catalogDirectory, exampleFiles[i] + 9) >= (int)sizeof(path)) continue;
|
||||
if (!appendBoardEntry(path, exampleNames[i])) break;
|
||||
}
|
||||
} else {
|
||||
DIR *directory = opendir(catalogDirectory);
|
||||
if (directory) {
|
||||
struct dirent *item;
|
||||
while ((item = readdir(directory))) {
|
||||
size_t length = strlen(item->d_name);
|
||||
if (item->d_name[0] == '.' || length < 6 || strcmp(item->d_name + length - 5, ".life")) continue;
|
||||
if (snprintf(path, sizeof(path), "%s%s", catalogDirectory, item->d_name) >= (int)sizeof(path)) continue;
|
||||
struct stat info;
|
||||
if (lstat(path, &info) != 0 || !S_ISREG(info.st_mode)) continue;
|
||||
char name[256];
|
||||
snprintf(name, sizeof(name), "%s", item->d_name);
|
||||
name[length - 5] = '\0';
|
||||
if (!appendBoardEntry(path, name)) break;
|
||||
}
|
||||
closedir(directory);
|
||||
if (catalogResult.count > 1)
|
||||
qsort(catalogResult.items, catalogResult.count, sizeof(BoardEntry), compareBoardEntries);
|
||||
} else if (errno != ENOENT) {
|
||||
snprintf(catalogResult.message, sizeof(catalogResult.message), "Cannot read the boards folder.");
|
||||
}
|
||||
}
|
||||
catalogResult.ready = true;
|
||||
pthread_mutex_lock(&catalogMutex);
|
||||
catalogDone = true;
|
||||
pthread_mutex_unlock(&catalogMutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void requestBoardCatalog(int which) {
|
||||
if (catalogBusy) { catalogPending = which; return; }
|
||||
catalogWhich = which;
|
||||
boardPath(catalogDirectory, which == 0 ? "examples/" : "");
|
||||
memset(&catalogResult, 0, sizeof(catalogResult));
|
||||
catalogDone = false;
|
||||
if (pthread_create(&catalogThread, NULL, scanBoardCatalog, NULL) == 0) catalogBusy = true;
|
||||
else {
|
||||
catalogs[which].ready = true;
|
||||
snprintf(catalogs[which].message, sizeof(catalogs[which].message), "Cannot load board previews.");
|
||||
}
|
||||
}
|
||||
|
||||
static void pollBoardCatalog(void) {
|
||||
if (!catalogBusy) return;
|
||||
pthread_mutex_lock(&catalogMutex);
|
||||
bool done = catalogDone;
|
||||
pthread_mutex_unlock(&catalogMutex);
|
||||
if (!done) return;
|
||||
pthread_join(catalogThread, NULL);
|
||||
catalogBusy = false;
|
||||
free(catalogs[catalogWhich].items);
|
||||
catalogs[catalogWhich] = catalogResult;
|
||||
memset(&catalogResult, 0, sizeof(catalogResult));
|
||||
if (catalogPending >= 0) {
|
||||
int which = catalogPending;
|
||||
catalogPending = -1;
|
||||
requestBoardCatalog(which);
|
||||
}
|
||||
}
|
||||
|
||||
static void closeBoardCatalogs(void) {
|
||||
if (catalogBusy) { pthread_join(catalogThread, NULL); free(catalogResult.items); }
|
||||
for (int i = 0; i < 2; ++i) free(catalogs[i].items);
|
||||
}
|
||||
|
||||
static void changeSidebarPage(int page) {
|
||||
finishLoopInput();
|
||||
drawing = editPending = false;
|
||||
activeSlider = -1;
|
||||
previousWidgetCount = widgetCount;
|
||||
memcpy(previousWidgets, widgets, sizeof(widgets));
|
||||
pageDirection = page == PAGE_CONTROLS ? -1 : 1;
|
||||
pageSlideStarted = notificationTime();
|
||||
if (sidebarPage == PAGE_CONTROLS) returnScroll = panelScroll;
|
||||
sidebarPage = page;
|
||||
panelScroll = page == PAGE_CONTROLS ? returnScroll : 0;
|
||||
if (!showControls) setControlsVisible(true);
|
||||
if (page == PAGE_SAVE) {
|
||||
paused = true;
|
||||
boardName[0] = '\0';
|
||||
confirmReplace = false;
|
||||
}
|
||||
if (page == PAGE_OPEN || page == PAGE_EXAMPLES) requestBoardCatalog(page == PAGE_OPEN);
|
||||
}
|
||||
|
||||
/* A plain basename only: keep saves inside boards/, never in examples/. */
|
||||
static bool namedBoardPath(char path[PATH_MAX]) {
|
||||
char name[sizeof(boardName) + 6];
|
||||
snprintf(name, sizeof(name), "%s", boardName);
|
||||
size_t length = strlen(name);
|
||||
while (length && name[length - 1] == ' ') name[--length] = '\0';
|
||||
if (!length || name[0] == '.' || name[0] == ' ' || strchr(name, '/') || strchr(name, '\\')) return false;
|
||||
if (length < 5 || strcmp(name + length - 5, ".life")) strcat(name, ".life");
|
||||
boardPath(path, name);
|
||||
return path[0] != '\0';
|
||||
}
|
||||
|
||||
static void submitBoardName(void) {
|
||||
char path[PATH_MAX];
|
||||
if (!namedBoardPath(path)) { notifyBoard("Enter a board name without slashes or leading dots/spaces."); return; }
|
||||
struct stat info;
|
||||
if (lstat(path, &info) == 0 && !confirmReplace) {
|
||||
confirmReplace = true;
|
||||
notifyBoard("Name exists. Click Replace existing board to overwrite it.");
|
||||
return;
|
||||
}
|
||||
startBoardPath(true, path, false, confirmReplace);
|
||||
}
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
/* Portable text boards: Life 1.06 coordinates plus size/generation metadata. */
|
||||
static const char *exampleNames[] = {
|
||||
"Sierpinski triangle", "Acorn kaleidoscope", "Pulsar garden", "Glider pinwheel",
|
||||
"Gosper glider gun", "Pentadecathlon garden", "Diehard", "R-pentomino", "Spaceship fleet", "Cross bloom", "Sierpinski carpet", "Blinker weave",
|
||||
"Glider gun compass", "Oscillator sampler", "Pulsar phase wave", "Diehard constellation", "Glider rain", "Acorn orbit", "Sierpinski diamond", "Symmetric nebula"
|
||||
};
|
||||
static const char *exampleFiles[] = {
|
||||
"examples/sierpinski.life", "examples/acorn-kaleidoscope.life", "examples/pulsar-garden.life", "examples/glider-pinwheel.life",
|
||||
"examples/gosper-glider-gun.life", "examples/pentadecathlon-garden.life", "examples/diehard.life", "examples/r-pentomino.life", "examples/spaceship-fleet.life", "examples/cross-bloom.life", "examples/sierpinski-carpet.life", "examples/blinker-weave.life",
|
||||
"examples/glider-gun-compass.life", "examples/oscillator-sampler.life", "examples/pulsar-phase-wave.life", "examples/diehard-constellation.life", "examples/glider-rain.life", "examples/acorn-orbit.life", "examples/sierpinski-diamond.life", "examples/symmetric-nebula.life"
|
||||
};
|
||||
#define EXAMPLE_COUNT ((int)(sizeof(exampleFiles) / sizeof(exampleFiles[0])))
|
||||
static char boardMessage[160];
|
||||
static double boardMessageStarted;
|
||||
|
||||
static double notificationTime(void) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0;
|
||||
}
|
||||
|
||||
static void notifyBoard(const char *message) {
|
||||
snprintf(boardMessage, sizeof(boardMessage), "%s", message);
|
||||
boardMessageStarted = notificationTime();
|
||||
}
|
||||
|
||||
/* 250 ms entrance, 3 seconds readable, 250 ms exit; no blocking waits. */
|
||||
static float boardNotificationVisibility(double now) {
|
||||
double age = now - boardMessageStarted;
|
||||
if (!boardMessage[0]) return 0;
|
||||
if (age >= 3500) { boardMessage[0] = '\0'; return 0; }
|
||||
float t = age < 250 ? (float)(age / 250) : age > 3250 ? (float)((3500 - age) / 250) : 1;
|
||||
if (t < 0) t = 0;
|
||||
return t * t * (3 - 2 * t);
|
||||
}
|
||||
static bool boardBusy;
|
||||
static pthread_t boardThread;
|
||||
static pthread_mutex_t boardMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static bool boardDone;
|
||||
static struct {
|
||||
EditSnapshot board;
|
||||
char path[PATH_MAX], message[160];
|
||||
bool save, dialog, success, replace;
|
||||
} boardJob;
|
||||
|
||||
static bool boardNumbers(const char *line, unsigned long long *a, unsigned long long *b) {
|
||||
unsigned long long *outputs[] = {a, b};
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
while (isspace((unsigned char)*line)) ++line;
|
||||
if (!isdigit((unsigned char)*line)) return false;
|
||||
char *end;
|
||||
errno = 0;
|
||||
*outputs[i] = strtoull(line, &end, 10);
|
||||
if (errno || (*end && !isspace((unsigned char)*end))) return false;
|
||||
line = end;
|
||||
}
|
||||
while (isspace((unsigned char)*line)) ++line;
|
||||
return *line == '\0';
|
||||
}
|
||||
|
||||
static bool readBoardFile(const char *path, EditSnapshot *board, char message[160]) {
|
||||
FILE *file = fopen(path, "rb");
|
||||
if (!file) { snprintf(message, 160, "Cannot open board file."); return false; }
|
||||
char line[128];
|
||||
bool valid = fgets(line, sizeof(line), file) &&
|
||||
(strcmp(line, "#Life 1.06\n") == 0 || strcmp(line, "#Life 1.06\r\n") == 0);
|
||||
bool metadata = false;
|
||||
size_t bytes = 0;
|
||||
memset(board, 0, sizeof(*board));
|
||||
while (valid && fgets(line, sizeof(line), file)) {
|
||||
bytes += strlen(line);
|
||||
if (strlen(line) >= sizeof(line) - 1 || bytes > 4 * 1024 * 1024) { valid = false; break; }
|
||||
unsigned long long a, b;
|
||||
if (strncmp(line, "#BOARD ", 7) == 0) {
|
||||
valid = !metadata && boardNumbers(line + 7, &a, &b)
|
||||
&& a >= MIN_RESOLUTION && a <= MAX_RESOLUTION && a % RESOLUTION_STEP == 0;
|
||||
if (valid) { board->resolution = (int)a; board->generation = b; metadata = true; }
|
||||
} else if (line[0] != '#') {
|
||||
const char *p = line;
|
||||
while (isspace((unsigned char)*p)) ++p;
|
||||
if (!*p) continue;
|
||||
valid = metadata && boardNumbers(p, &a, &b)
|
||||
&& a < (unsigned)board->resolution && b < (unsigned)board->resolution;
|
||||
if (valid) {
|
||||
size_t index = (size_t)b * board->resolution + (size_t)a;
|
||||
if (board->cells[index]) valid = false;
|
||||
else { board->cells[index] = 1; ++board->population; }
|
||||
}
|
||||
}
|
||||
}
|
||||
valid = valid && metadata && !ferror(file);
|
||||
fclose(file);
|
||||
if (!valid) snprintf(message, 160, "Invalid board file; current board unchanged.");
|
||||
return valid;
|
||||
}
|
||||
|
||||
static bool writeBoardFileMode(const char *path, const EditSnapshot *board, char message[160], bool replace) {
|
||||
char temporary[PATH_MAX + 16];
|
||||
snprintf(temporary, sizeof(temporary), "%s.tmp.XXXXXX", path);
|
||||
int fd = mkstemp(temporary);
|
||||
if (fd < 0) goto failed;
|
||||
FILE *file = fdopen(fd, "w");
|
||||
if (!file) { close(fd); unlink(temporary); goto failed; }
|
||||
bool ok = fprintf(file, "#Life 1.06\n#BOARD %d %llu\n", board->resolution, board->generation) >= 0;
|
||||
for (int row = 0; row < board->resolution; ++row)
|
||||
for (int col = 0; col < board->resolution; ++col)
|
||||
if (board->cells[row * board->resolution + col]
|
||||
&& fprintf(file, "%d %d\n", col, row) < 0) ok = false;
|
||||
if (fflush(file) != 0 || fsync(fd) != 0) ok = false;
|
||||
if (fclose(file) != 0) ok = false;
|
||||
if (!ok || (replace ? rename(temporary, path) : link(temporary, path)) != 0) {
|
||||
int savedError = errno;
|
||||
unlink(temporary);
|
||||
if (!replace && savedError == EEXIST) {
|
||||
snprintf(message, 160, "Name already exists. Choose another or confirm replacement.");
|
||||
return false;
|
||||
}
|
||||
goto failed;
|
||||
}
|
||||
if (!replace) unlink(temporary);
|
||||
return true;
|
||||
failed:
|
||||
snprintf(message, 160, "Cannot save board; check the folder and free space.");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool writeBoardFile(const char *path, const EditSnapshot *board, char message[160]) {
|
||||
return writeBoardFileMode(path, board, message, true);
|
||||
}
|
||||
|
||||
static void boardPath(char path[PATH_MAX], const char *name) {
|
||||
#if !APP_PORTABLE
|
||||
int length;
|
||||
if (strncmp(name, "examples/", 9) == 0)
|
||||
length = snprintf(path, PATH_MAX, "%s/%s", APP_DATA_DIR, name);
|
||||
else length = snprintf(path, PATH_MAX, "%s/%s", userBoardsDirectory, name);
|
||||
if (length < 0 || length >= PATH_MAX) path[0] = '\0';
|
||||
#else
|
||||
const char *slash = strrchr(settingsPath, '/');
|
||||
size_t prefix = slash ? (size_t)(slash - settingsPath + 1) : 0;
|
||||
if (prefix + strlen("boards/") + strlen(name) + 1 > PATH_MAX) { path[0] = '\0'; return; }
|
||||
memcpy(path, settingsPath, prefix);
|
||||
snprintf(path + prefix, PATH_MAX - prefix, "boards/%s", name);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Native KDE dialogs run outside the GLUT thread, with explicit argv (no shell). */
|
||||
static bool chooseBoardFile(bool save, char path[PATH_MAX], char message[160]) {
|
||||
int output[2];
|
||||
if (pipe(output) != 0) return false;
|
||||
posix_spawn_file_actions_t actions;
|
||||
posix_spawn_file_actions_init(&actions);
|
||||
posix_spawn_file_actions_adddup2(&actions, output[1], STDOUT_FILENO);
|
||||
posix_spawn_file_actions_addclose(&actions, output[0]);
|
||||
posix_spawn_file_actions_addclose(&actions, output[1]);
|
||||
char *argv[] = {"kdialog", save ? "--getsavefilename" : "--getopenfilename",
|
||||
path, "*.life|Life boards (*.life)", "--title", save ? "Save board" : "Open board", NULL};
|
||||
pid_t child;
|
||||
extern char **environ;
|
||||
int result = posix_spawnp(&child, "kdialog", &actions, NULL, argv, environ);
|
||||
posix_spawn_file_actions_destroy(&actions);
|
||||
close(output[1]);
|
||||
if (result != 0) {
|
||||
close(output[0]);
|
||||
snprintf(message, 160, "File dialogs require kdialog. Example buttons still work.");
|
||||
return false;
|
||||
}
|
||||
size_t used = 0;
|
||||
char buffer[512];
|
||||
ssize_t count;
|
||||
bool tooLong = false;
|
||||
while ((count = read(output[0], buffer, sizeof(buffer))) != 0) {
|
||||
if (count < 0) { if (errno == EINTR) continue; break; }
|
||||
if (used + (size_t)count >= PATH_MAX) tooLong = true;
|
||||
else { memcpy(path + used, buffer, (size_t)count); used += (size_t)count; }
|
||||
}
|
||||
close(output[0]);
|
||||
int status;
|
||||
while (waitpid(child, &status, 0) < 0) if (errno != EINTR) return false;
|
||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) return false;
|
||||
if (tooLong) { snprintf(message, 160, "Board filename is too long."); return false; }
|
||||
if (used && path[used - 1] == '\n') --used;
|
||||
path[used] = '\0';
|
||||
return used > 0;
|
||||
}
|
||||
|
||||
static void *boardWorker(void *unused) {
|
||||
(void)unused;
|
||||
bool ready = !boardJob.dialog || chooseBoardFile(boardJob.save, boardJob.path, boardJob.message);
|
||||
if (ready && boardJob.save) {
|
||||
char directory[PATH_MAX];
|
||||
boardPath(directory, "");
|
||||
if (mkdir(directory, 0700) != 0 && errno != EEXIST) {
|
||||
snprintf(boardJob.message, sizeof(boardJob.message), "Cannot create boards folder.");
|
||||
ready = false;
|
||||
}
|
||||
}
|
||||
if (ready) {
|
||||
boardJob.success = boardJob.save
|
||||
? (boardJob.replace ? writeBoardFile(boardJob.path, &boardJob.board, boardJob.message)
|
||||
: writeBoardFileMode(boardJob.path, &boardJob.board, boardJob.message, false))
|
||||
: readBoardFile(boardJob.path, &boardJob.board, boardJob.message);
|
||||
}
|
||||
pthread_mutex_lock(&boardMutex);
|
||||
boardDone = true;
|
||||
pthread_mutex_unlock(&boardMutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void applyBoard(const EditSnapshot *board) {
|
||||
beginEdit();
|
||||
commitEdit();
|
||||
clearHistory();
|
||||
resolution = board->resolution;
|
||||
generation = board->generation;
|
||||
population = board->population;
|
||||
memcpy(grid, board->cells, (size_t)resolution * resolution);
|
||||
paused = true;
|
||||
reversePlayback = drawing = editPending = hasSelection = false;
|
||||
activeSlider = -1;
|
||||
capturePlaybackStart();
|
||||
saveSettingsIfChanged();
|
||||
}
|
||||
|
||||
static void startBoardPath(bool save, const char *path, bool dialog, bool replace) {
|
||||
if (boardBusy) return;
|
||||
finishLoopInput();
|
||||
paused = true;
|
||||
drawing = editPending = false;
|
||||
memset(&boardJob, 0, sizeof(boardJob));
|
||||
boardJob.save = save;
|
||||
boardJob.dialog = dialog;
|
||||
boardJob.replace = replace;
|
||||
snprintf(boardJob.path, sizeof(boardJob.path), "%s", path);
|
||||
if (save) {
|
||||
memcpy(boardJob.board.cells, grid, (size_t)resolution * resolution);
|
||||
boardJob.board.resolution = resolution;
|
||||
boardJob.board.population = population;
|
||||
boardJob.board.generation = generation;
|
||||
}
|
||||
boardDone = false;
|
||||
notifyBoard(dialog ? "Choose a board file in the file dialog." : save ? "Saving board..." : "Opening board...");
|
||||
if (pthread_create(&boardThread, NULL, boardWorker, NULL) == 0) boardBusy = true;
|
||||
else notifyBoard("Cannot start board file operation.");
|
||||
}
|
||||
|
||||
static void startBoardJob(bool save, int example) {
|
||||
char path[PATH_MAX];
|
||||
boardPath(path, example >= 0 ? exampleFiles[example] : save ? "my-board.life" : "");
|
||||
startBoardPath(save, path, example < 0, true);
|
||||
}
|
||||
|
||||
static void pollBoardJob(void) {
|
||||
if (!boardBusy) return;
|
||||
pthread_mutex_lock(&boardMutex);
|
||||
bool done = boardDone;
|
||||
pthread_mutex_unlock(&boardMutex);
|
||||
if (!done) return;
|
||||
pthread_join(boardThread, NULL);
|
||||
boardBusy = false;
|
||||
if (boardJob.success) {
|
||||
if (!boardJob.save) applyBoard(&boardJob.board);
|
||||
if (sidebarPage != PAGE_CONTROLS) changeSidebarPage(PAGE_CONTROLS);
|
||||
notifyBoard(boardJob.save ? "Board saved." : "Board opened. Click Play to evolve it.");
|
||||
} else notifyBoard(boardJob.message[0] ? boardJob.message : "File operation canceled.");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Saved boards
|
||||
|
||||
This folder is the default location for your saved `.life` boards.
|
||||
|
||||
Bundled patterns live separately in [examples/](examples/README.md). Open them
|
||||
from **Board → Examples**, or use **Open / Ctrl+O** to browse your saved boards. **Open File** opens a file
|
||||
dialog for boards elsewhere. **Save / Ctrl+S** lets you name a board in the sidebar.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Example boards
|
||||
|
||||
Open these from the **Board → Examples** menu, or browse to this folder using **Open → Open File**.
|
||||
They open paused at generation zero. Click Play, draw changes, or save a variation.
|
||||
|
||||
| Board | Starting pattern | What to try |
|
||||
| --- | --- | --- |
|
||||
| `sierpinski.life` | 128-row Sierpinski triangle on a 300×300 grid | Inspect the recursive triangle, then watch Conway's rules reshape it. Loop to Gen 100. |
|
||||
| `acorn-kaleidoscope.life` | Four mirrored acorns on a 200×200 grid | Expanding four-way symmetry and collisions; try Gen 100–500. |
|
||||
| `pulsar-garden.life` | Sixteen pulsars on a 200×200 grid | A geometric, three-generation repeating garden. Slow playback makes the phases clear. |
|
||||
| `glider-pinwheel.life` | Four gliders aimed inward on a 200×200 grid | Watch their approach and collisions; try Gen 200–300. |
|
||||
| `gosper-glider-gun.life` | Gosper glider gun | A period-30 glider gun. Try Gen 300; gliders eventually wrap around. |
|
||||
| `pentadecathlon-garden.life` | Pentadecathlon garden | Nine period-15 oscillators. Slow playback or loop to Gen 15. |
|
||||
| `diehard.life` | Diehard | Seven cells create a transient that vanishes at Gen 130. Loop to Gen 130. |
|
||||
| `r-pentomino.life` | R-pentomino | Five cells grow into a complex expanding cloud. Try Gen 100-500. |
|
||||
| `spaceship-fleet.life` | Spaceship fleet | Twelve lightweight spaceships travel left and wrap around. Try Gen 400. |
|
||||
| `cross-bloom.life` | Cross bloom | A symmetric cross bursts into changing geometric forms. Try Gen 100-200. |
|
||||
| `sierpinski-carpet.life` | Sierpinski carpet | Four-level fractal seed; Conway rules reshape it. Inspect paused, then try Gen 100. |
|
||||
| `blinker-weave.life` | Blinker weave | Alternating horizontal and vertical blinkers form a period-2 woven field. |
|
||||
| `glider-gun-compass.life` | Glider gun compass | Four inward-facing Gosper guns. Watch streams cross; try Gen 300-1000. |
|
||||
| `oscillator-sampler.life` | Oscillator sampler | Pairs of blinkers, toads, beacons, pulsars and pentadecathlons. Loop to Gen 30. |
|
||||
| `pulsar-phase-wave.life` | Pulsar phase wave | Twenty-five pulsars in staggered phases form a repeating diagonal wave. Loop to Gen 3. |
|
||||
| `diehard-constellation.life` | Diehard constellation | Sixteen rotated Diehard seeds bloom, then all disappear at Gen 130. |
|
||||
| `glider-rain.life` | Glider rain | One hundred phase-shifted gliders drift diagonally and wrap around. Try Gen 200-800. |
|
||||
| `acorn-orbit.life` | Acorn orbit | Eight acorns surround an empty center; expanding debris gradually meets. Try Gen 100-500. |
|
||||
| `sierpinski-diamond.life` | Sierpinski diamond | Mirrored recursive triangles create a fractal diamond seed. Try Gen 50-150. |
|
||||
| `symmetric-nebula.life` | Symmetric nebula | A dense, mirrored seed develops four-way symmetric forms. Try Gen 100-300. |
|
||||
|
||||
These boards include classic Life patterns and original geometric arrangements.
|
||||
The Gosper glider gun is Bill Gosper’s classic pattern. The triangle uses
|
||||
Pascal's triangle modulo two: row `y` includes `x` when `(x & y) == x`.
|
||||
The carpet removes the middle ninth recursively. The diamond mirrors two recursive triangles. These start as fractals; Conway evolution does not guarantee fractal growth.
|
||||
All boards retain the game's wrapping edges and normal B3/S23 rules.
|
||||
@@ -0,0 +1,31 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Four mirrored acorns; expanding symmetric collisions. Try Gen 100-500.
|
||||
66 65
|
||||
133 65
|
||||
68 66
|
||||
131 66
|
||||
65 67
|
||||
66 67
|
||||
69 67
|
||||
70 67
|
||||
71 67
|
||||
128 67
|
||||
129 67
|
||||
130 67
|
||||
133 67
|
||||
134 67
|
||||
65 132
|
||||
66 132
|
||||
69 132
|
||||
70 132
|
||||
71 132
|
||||
128 132
|
||||
129 132
|
||||
130 132
|
||||
133 132
|
||||
134 132
|
||||
68 133
|
||||
131 133
|
||||
66 134
|
||||
133 134
|
||||
@@ -0,0 +1,59 @@
|
||||
#Life 1.06
|
||||
#BOARD 300 0
|
||||
# Eight acorns surround an empty center; expanding debris gradually meets. Try Gen 100-500.
|
||||
151 55
|
||||
153 56
|
||||
150 57
|
||||
151 57
|
||||
154 57
|
||||
155 57
|
||||
156 57
|
||||
87 79
|
||||
87 80
|
||||
87 81
|
||||
86 82
|
||||
85 84
|
||||
87 84
|
||||
87 85
|
||||
213 85
|
||||
213 86
|
||||
215 86
|
||||
214 88
|
||||
213 89
|
||||
213 90
|
||||
213 91
|
||||
49 148
|
||||
50 148
|
||||
51 148
|
||||
54 148
|
||||
55 148
|
||||
239 148
|
||||
240 148
|
||||
241 148
|
||||
244 148
|
||||
245 148
|
||||
52 149
|
||||
242 149
|
||||
54 150
|
||||
244 150
|
||||
217 209
|
||||
217 210
|
||||
217 211
|
||||
216 212
|
||||
215 214
|
||||
217 214
|
||||
83 215
|
||||
217 215
|
||||
83 216
|
||||
85 216
|
||||
84 218
|
||||
83 219
|
||||
83 220
|
||||
83 221
|
||||
151 245
|
||||
153 246
|
||||
150 247
|
||||
151 247
|
||||
154 247
|
||||
155 247
|
||||
156 247
|
||||
@@ -0,0 +1,510 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Alternating horizontal and vertical blinkers form a period-2 woven field.
|
||||
40 40
|
||||
41 40
|
||||
42 40
|
||||
50 40
|
||||
60 40
|
||||
61 40
|
||||
62 40
|
||||
70 40
|
||||
80 40
|
||||
81 40
|
||||
82 40
|
||||
90 40
|
||||
100 40
|
||||
101 40
|
||||
102 40
|
||||
110 40
|
||||
120 40
|
||||
121 40
|
||||
122 40
|
||||
130 40
|
||||
140 40
|
||||
141 40
|
||||
142 40
|
||||
150 40
|
||||
160 40
|
||||
161 40
|
||||
162 40
|
||||
50 41
|
||||
70 41
|
||||
90 41
|
||||
110 41
|
||||
130 41
|
||||
150 41
|
||||
50 42
|
||||
70 42
|
||||
90 42
|
||||
110 42
|
||||
130 42
|
||||
150 42
|
||||
40 50
|
||||
50 50
|
||||
51 50
|
||||
52 50
|
||||
60 50
|
||||
70 50
|
||||
71 50
|
||||
72 50
|
||||
80 50
|
||||
90 50
|
||||
91 50
|
||||
92 50
|
||||
100 50
|
||||
110 50
|
||||
111 50
|
||||
112 50
|
||||
120 50
|
||||
130 50
|
||||
131 50
|
||||
132 50
|
||||
140 50
|
||||
150 50
|
||||
151 50
|
||||
152 50
|
||||
160 50
|
||||
40 51
|
||||
60 51
|
||||
80 51
|
||||
100 51
|
||||
120 51
|
||||
140 51
|
||||
160 51
|
||||
40 52
|
||||
60 52
|
||||
80 52
|
||||
100 52
|
||||
120 52
|
||||
140 52
|
||||
160 52
|
||||
40 60
|
||||
41 60
|
||||
42 60
|
||||
50 60
|
||||
60 60
|
||||
61 60
|
||||
62 60
|
||||
70 60
|
||||
80 60
|
||||
81 60
|
||||
82 60
|
||||
90 60
|
||||
100 60
|
||||
101 60
|
||||
102 60
|
||||
110 60
|
||||
120 60
|
||||
121 60
|
||||
122 60
|
||||
130 60
|
||||
140 60
|
||||
141 60
|
||||
142 60
|
||||
150 60
|
||||
160 60
|
||||
161 60
|
||||
162 60
|
||||
50 61
|
||||
70 61
|
||||
90 61
|
||||
110 61
|
||||
130 61
|
||||
150 61
|
||||
50 62
|
||||
70 62
|
||||
90 62
|
||||
110 62
|
||||
130 62
|
||||
150 62
|
||||
40 70
|
||||
50 70
|
||||
51 70
|
||||
52 70
|
||||
60 70
|
||||
70 70
|
||||
71 70
|
||||
72 70
|
||||
80 70
|
||||
90 70
|
||||
91 70
|
||||
92 70
|
||||
100 70
|
||||
110 70
|
||||
111 70
|
||||
112 70
|
||||
120 70
|
||||
130 70
|
||||
131 70
|
||||
132 70
|
||||
140 70
|
||||
150 70
|
||||
151 70
|
||||
152 70
|
||||
160 70
|
||||
40 71
|
||||
60 71
|
||||
80 71
|
||||
100 71
|
||||
120 71
|
||||
140 71
|
||||
160 71
|
||||
40 72
|
||||
60 72
|
||||
80 72
|
||||
100 72
|
||||
120 72
|
||||
140 72
|
||||
160 72
|
||||
40 80
|
||||
41 80
|
||||
42 80
|
||||
50 80
|
||||
60 80
|
||||
61 80
|
||||
62 80
|
||||
70 80
|
||||
80 80
|
||||
81 80
|
||||
82 80
|
||||
90 80
|
||||
100 80
|
||||
101 80
|
||||
102 80
|
||||
110 80
|
||||
120 80
|
||||
121 80
|
||||
122 80
|
||||
130 80
|
||||
140 80
|
||||
141 80
|
||||
142 80
|
||||
150 80
|
||||
160 80
|
||||
161 80
|
||||
162 80
|
||||
50 81
|
||||
70 81
|
||||
90 81
|
||||
110 81
|
||||
130 81
|
||||
150 81
|
||||
50 82
|
||||
70 82
|
||||
90 82
|
||||
110 82
|
||||
130 82
|
||||
150 82
|
||||
40 90
|
||||
50 90
|
||||
51 90
|
||||
52 90
|
||||
60 90
|
||||
70 90
|
||||
71 90
|
||||
72 90
|
||||
80 90
|
||||
90 90
|
||||
91 90
|
||||
92 90
|
||||
100 90
|
||||
110 90
|
||||
111 90
|
||||
112 90
|
||||
120 90
|
||||
130 90
|
||||
131 90
|
||||
132 90
|
||||
140 90
|
||||
150 90
|
||||
151 90
|
||||
152 90
|
||||
160 90
|
||||
40 91
|
||||
60 91
|
||||
80 91
|
||||
100 91
|
||||
120 91
|
||||
140 91
|
||||
160 91
|
||||
40 92
|
||||
60 92
|
||||
80 92
|
||||
100 92
|
||||
120 92
|
||||
140 92
|
||||
160 92
|
||||
40 100
|
||||
41 100
|
||||
42 100
|
||||
50 100
|
||||
60 100
|
||||
61 100
|
||||
62 100
|
||||
70 100
|
||||
80 100
|
||||
81 100
|
||||
82 100
|
||||
90 100
|
||||
100 100
|
||||
101 100
|
||||
102 100
|
||||
110 100
|
||||
120 100
|
||||
121 100
|
||||
122 100
|
||||
130 100
|
||||
140 100
|
||||
141 100
|
||||
142 100
|
||||
150 100
|
||||
160 100
|
||||
161 100
|
||||
162 100
|
||||
50 101
|
||||
70 101
|
||||
90 101
|
||||
110 101
|
||||
130 101
|
||||
150 101
|
||||
50 102
|
||||
70 102
|
||||
90 102
|
||||
110 102
|
||||
130 102
|
||||
150 102
|
||||
40 110
|
||||
50 110
|
||||
51 110
|
||||
52 110
|
||||
60 110
|
||||
70 110
|
||||
71 110
|
||||
72 110
|
||||
80 110
|
||||
90 110
|
||||
91 110
|
||||
92 110
|
||||
100 110
|
||||
110 110
|
||||
111 110
|
||||
112 110
|
||||
120 110
|
||||
130 110
|
||||
131 110
|
||||
132 110
|
||||
140 110
|
||||
150 110
|
||||
151 110
|
||||
152 110
|
||||
160 110
|
||||
40 111
|
||||
60 111
|
||||
80 111
|
||||
100 111
|
||||
120 111
|
||||
140 111
|
||||
160 111
|
||||
40 112
|
||||
60 112
|
||||
80 112
|
||||
100 112
|
||||
120 112
|
||||
140 112
|
||||
160 112
|
||||
40 120
|
||||
41 120
|
||||
42 120
|
||||
50 120
|
||||
60 120
|
||||
61 120
|
||||
62 120
|
||||
70 120
|
||||
80 120
|
||||
81 120
|
||||
82 120
|
||||
90 120
|
||||
100 120
|
||||
101 120
|
||||
102 120
|
||||
110 120
|
||||
120 120
|
||||
121 120
|
||||
122 120
|
||||
130 120
|
||||
140 120
|
||||
141 120
|
||||
142 120
|
||||
150 120
|
||||
160 120
|
||||
161 120
|
||||
162 120
|
||||
50 121
|
||||
70 121
|
||||
90 121
|
||||
110 121
|
||||
130 121
|
||||
150 121
|
||||
50 122
|
||||
70 122
|
||||
90 122
|
||||
110 122
|
||||
130 122
|
||||
150 122
|
||||
40 130
|
||||
50 130
|
||||
51 130
|
||||
52 130
|
||||
60 130
|
||||
70 130
|
||||
71 130
|
||||
72 130
|
||||
80 130
|
||||
90 130
|
||||
91 130
|
||||
92 130
|
||||
100 130
|
||||
110 130
|
||||
111 130
|
||||
112 130
|
||||
120 130
|
||||
130 130
|
||||
131 130
|
||||
132 130
|
||||
140 130
|
||||
150 130
|
||||
151 130
|
||||
152 130
|
||||
160 130
|
||||
40 131
|
||||
60 131
|
||||
80 131
|
||||
100 131
|
||||
120 131
|
||||
140 131
|
||||
160 131
|
||||
40 132
|
||||
60 132
|
||||
80 132
|
||||
100 132
|
||||
120 132
|
||||
140 132
|
||||
160 132
|
||||
40 140
|
||||
41 140
|
||||
42 140
|
||||
50 140
|
||||
60 140
|
||||
61 140
|
||||
62 140
|
||||
70 140
|
||||
80 140
|
||||
81 140
|
||||
82 140
|
||||
90 140
|
||||
100 140
|
||||
101 140
|
||||
102 140
|
||||
110 140
|
||||
120 140
|
||||
121 140
|
||||
122 140
|
||||
130 140
|
||||
140 140
|
||||
141 140
|
||||
142 140
|
||||
150 140
|
||||
160 140
|
||||
161 140
|
||||
162 140
|
||||
50 141
|
||||
70 141
|
||||
90 141
|
||||
110 141
|
||||
130 141
|
||||
150 141
|
||||
50 142
|
||||
70 142
|
||||
90 142
|
||||
110 142
|
||||
130 142
|
||||
150 142
|
||||
40 150
|
||||
50 150
|
||||
51 150
|
||||
52 150
|
||||
60 150
|
||||
70 150
|
||||
71 150
|
||||
72 150
|
||||
80 150
|
||||
90 150
|
||||
91 150
|
||||
92 150
|
||||
100 150
|
||||
110 150
|
||||
111 150
|
||||
112 150
|
||||
120 150
|
||||
130 150
|
||||
131 150
|
||||
132 150
|
||||
140 150
|
||||
150 150
|
||||
151 150
|
||||
152 150
|
||||
160 150
|
||||
40 151
|
||||
60 151
|
||||
80 151
|
||||
100 151
|
||||
120 151
|
||||
140 151
|
||||
160 151
|
||||
40 152
|
||||
60 152
|
||||
80 152
|
||||
100 152
|
||||
120 152
|
||||
140 152
|
||||
160 152
|
||||
40 160
|
||||
41 160
|
||||
42 160
|
||||
50 160
|
||||
60 160
|
||||
61 160
|
||||
62 160
|
||||
70 160
|
||||
80 160
|
||||
81 160
|
||||
82 160
|
||||
90 160
|
||||
100 160
|
||||
101 160
|
||||
102 160
|
||||
110 160
|
||||
120 160
|
||||
121 160
|
||||
122 160
|
||||
130 160
|
||||
140 160
|
||||
141 160
|
||||
142 160
|
||||
150 160
|
||||
160 160
|
||||
161 160
|
||||
162 160
|
||||
50 161
|
||||
70 161
|
||||
90 161
|
||||
110 161
|
||||
130 161
|
||||
150 161
|
||||
50 162
|
||||
70 162
|
||||
90 162
|
||||
110 162
|
||||
130 162
|
||||
150 162
|
||||
@@ -0,0 +1,144 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# A symmetric cross bursts into changing geometric forms. Try Gen 100-200.
|
||||
100 65
|
||||
100 66
|
||||
100 67
|
||||
100 68
|
||||
100 69
|
||||
100 70
|
||||
100 71
|
||||
100 72
|
||||
100 73
|
||||
100 74
|
||||
100 75
|
||||
100 76
|
||||
100 77
|
||||
100 78
|
||||
100 79
|
||||
100 80
|
||||
100 81
|
||||
100 82
|
||||
100 83
|
||||
100 84
|
||||
100 85
|
||||
100 86
|
||||
100 87
|
||||
100 88
|
||||
100 89
|
||||
100 90
|
||||
100 91
|
||||
100 92
|
||||
100 93
|
||||
100 94
|
||||
100 95
|
||||
100 96
|
||||
100 97
|
||||
100 98
|
||||
100 99
|
||||
65 100
|
||||
66 100
|
||||
67 100
|
||||
68 100
|
||||
69 100
|
||||
70 100
|
||||
71 100
|
||||
72 100
|
||||
73 100
|
||||
74 100
|
||||
75 100
|
||||
76 100
|
||||
77 100
|
||||
78 100
|
||||
79 100
|
||||
80 100
|
||||
81 100
|
||||
82 100
|
||||
83 100
|
||||
84 100
|
||||
85 100
|
||||
86 100
|
||||
87 100
|
||||
88 100
|
||||
89 100
|
||||
90 100
|
||||
91 100
|
||||
92 100
|
||||
93 100
|
||||
94 100
|
||||
95 100
|
||||
96 100
|
||||
97 100
|
||||
98 100
|
||||
99 100
|
||||
100 100
|
||||
101 100
|
||||
102 100
|
||||
103 100
|
||||
104 100
|
||||
105 100
|
||||
106 100
|
||||
107 100
|
||||
108 100
|
||||
109 100
|
||||
110 100
|
||||
111 100
|
||||
112 100
|
||||
113 100
|
||||
114 100
|
||||
115 100
|
||||
116 100
|
||||
117 100
|
||||
118 100
|
||||
119 100
|
||||
120 100
|
||||
121 100
|
||||
122 100
|
||||
123 100
|
||||
124 100
|
||||
125 100
|
||||
126 100
|
||||
127 100
|
||||
128 100
|
||||
129 100
|
||||
130 100
|
||||
131 100
|
||||
132 100
|
||||
133 100
|
||||
134 100
|
||||
135 100
|
||||
100 101
|
||||
100 102
|
||||
100 103
|
||||
100 104
|
||||
100 105
|
||||
100 106
|
||||
100 107
|
||||
100 108
|
||||
100 109
|
||||
100 110
|
||||
100 111
|
||||
100 112
|
||||
100 113
|
||||
100 114
|
||||
100 115
|
||||
100 116
|
||||
100 117
|
||||
100 118
|
||||
100 119
|
||||
100 120
|
||||
100 121
|
||||
100 122
|
||||
100 123
|
||||
100 124
|
||||
100 125
|
||||
100 126
|
||||
100 127
|
||||
100 128
|
||||
100 129
|
||||
100 130
|
||||
100 131
|
||||
100 132
|
||||
100 133
|
||||
100 134
|
||||
100 135
|
||||
@@ -0,0 +1,115 @@
|
||||
#Life 1.06
|
||||
#BOARD 400 0
|
||||
# Sixteen rotated Diehard seeds bloom, then all disappear at Gen 130.
|
||||
322 58
|
||||
320 59
|
||||
322 59
|
||||
322 60
|
||||
228 63
|
||||
229 63
|
||||
230 63
|
||||
234 63
|
||||
234 64
|
||||
235 64
|
||||
321 64
|
||||
322 64
|
||||
71 65
|
||||
149 65
|
||||
229 65
|
||||
321 65
|
||||
65 66
|
||||
66 66
|
||||
148 66
|
||||
149 66
|
||||
66 67
|
||||
70 67
|
||||
71 67
|
||||
72 67
|
||||
148 70
|
||||
148 71
|
||||
150 71
|
||||
148 72
|
||||
237 143
|
||||
235 144
|
||||
237 144
|
||||
237 145
|
||||
143 148
|
||||
144 148
|
||||
145 148
|
||||
149 148
|
||||
149 149
|
||||
150 149
|
||||
236 149
|
||||
237 149
|
||||
64 150
|
||||
144 150
|
||||
236 150
|
||||
326 150
|
||||
63 151
|
||||
64 151
|
||||
320 151
|
||||
321 151
|
||||
321 152
|
||||
325 152
|
||||
326 152
|
||||
327 152
|
||||
63 155
|
||||
63 156
|
||||
65 156
|
||||
63 157
|
||||
152 228
|
||||
150 229
|
||||
152 229
|
||||
152 230
|
||||
58 233
|
||||
59 233
|
||||
60 233
|
||||
64 233
|
||||
64 234
|
||||
65 234
|
||||
151 234
|
||||
152 234
|
||||
59 235
|
||||
151 235
|
||||
241 235
|
||||
319 235
|
||||
235 236
|
||||
236 236
|
||||
318 236
|
||||
319 236
|
||||
236 237
|
||||
240 237
|
||||
241 237
|
||||
242 237
|
||||
318 240
|
||||
318 241
|
||||
320 241
|
||||
318 242
|
||||
67 313
|
||||
65 314
|
||||
67 314
|
||||
67 315
|
||||
313 318
|
||||
314 318
|
||||
315 318
|
||||
319 318
|
||||
66 319
|
||||
67 319
|
||||
319 319
|
||||
320 319
|
||||
66 320
|
||||
156 320
|
||||
234 320
|
||||
314 320
|
||||
150 321
|
||||
151 321
|
||||
233 321
|
||||
234 321
|
||||
151 322
|
||||
155 322
|
||||
156 322
|
||||
157 322
|
||||
233 325
|
||||
233 326
|
||||
235 326
|
||||
233 327
|
||||
@@ -0,0 +1,10 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Seven cells create a transient that vanishes at Gen 130. Loop to Gen 130.
|
||||
101 98
|
||||
95 99
|
||||
96 99
|
||||
96 100
|
||||
100 100
|
||||
101 100
|
||||
102 100
|
||||
@@ -0,0 +1,147 @@
|
||||
#Life 1.06
|
||||
#BOARD 400 0
|
||||
# Four inward-facing Gosper guns. Watch streams cross; try Gen 300-1000.
|
||||
69 45
|
||||
349 45
|
||||
350 45
|
||||
67 46
|
||||
69 46
|
||||
349 46
|
||||
350 46
|
||||
57 47
|
||||
58 47
|
||||
65 47
|
||||
66 47
|
||||
79 47
|
||||
80 47
|
||||
56 48
|
||||
60 48
|
||||
65 48
|
||||
66 48
|
||||
79 48
|
||||
80 48
|
||||
45 49
|
||||
46 49
|
||||
55 49
|
||||
61 49
|
||||
65 49
|
||||
66 49
|
||||
45 50
|
||||
46 50
|
||||
55 50
|
||||
59 50
|
||||
61 50
|
||||
62 50
|
||||
67 50
|
||||
69 50
|
||||
55 51
|
||||
61 51
|
||||
69 51
|
||||
56 52
|
||||
60 52
|
||||
57 53
|
||||
58 53
|
||||
348 55
|
||||
349 55
|
||||
350 55
|
||||
347 56
|
||||
351 56
|
||||
346 57
|
||||
352 57
|
||||
346 58
|
||||
352 58
|
||||
349 59
|
||||
347 60
|
||||
351 60
|
||||
348 61
|
||||
349 61
|
||||
350 61
|
||||
349 62
|
||||
350 65
|
||||
351 65
|
||||
352 65
|
||||
350 66
|
||||
351 66
|
||||
352 66
|
||||
349 67
|
||||
353 67
|
||||
348 69
|
||||
349 69
|
||||
353 69
|
||||
354 69
|
||||
351 79
|
||||
352 79
|
||||
351 80
|
||||
352 80
|
||||
47 319
|
||||
48 319
|
||||
47 320
|
||||
48 320
|
||||
45 330
|
||||
46 330
|
||||
50 330
|
||||
51 330
|
||||
46 332
|
||||
50 332
|
||||
47 333
|
||||
48 333
|
||||
49 333
|
||||
47 334
|
||||
48 334
|
||||
49 334
|
||||
50 337
|
||||
49 338
|
||||
50 338
|
||||
51 338
|
||||
48 339
|
||||
52 339
|
||||
50 340
|
||||
47 341
|
||||
53 341
|
||||
47 342
|
||||
53 342
|
||||
48 343
|
||||
52 343
|
||||
49 344
|
||||
50 344
|
||||
51 344
|
||||
341 346
|
||||
342 346
|
||||
339 347
|
||||
343 347
|
||||
330 348
|
||||
338 348
|
||||
344 348
|
||||
330 349
|
||||
332 349
|
||||
337 349
|
||||
338 349
|
||||
340 349
|
||||
344 349
|
||||
353 349
|
||||
354 349
|
||||
333 350
|
||||
334 350
|
||||
338 350
|
||||
344 350
|
||||
353 350
|
||||
354 350
|
||||
319 351
|
||||
320 351
|
||||
333 351
|
||||
334 351
|
||||
339 351
|
||||
343 351
|
||||
319 352
|
||||
320 352
|
||||
333 352
|
||||
334 352
|
||||
341 352
|
||||
342 352
|
||||
49 353
|
||||
50 353
|
||||
330 353
|
||||
332 353
|
||||
49 354
|
||||
50 354
|
||||
330 354
|
||||
@@ -0,0 +1,23 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Four inward gliders form a rotating arrangement and eventually collide.
|
||||
61 60
|
||||
137 60
|
||||
62 61
|
||||
137 61
|
||||
139 61
|
||||
60 62
|
||||
61 62
|
||||
62 62
|
||||
137 62
|
||||
138 62
|
||||
61 137
|
||||
62 137
|
||||
137 137
|
||||
138 137
|
||||
139 137
|
||||
60 138
|
||||
62 138
|
||||
137 138
|
||||
62 139
|
||||
138 139
|
||||
@@ -0,0 +1,503 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# One hundred phase-shifted gliders drift diagonally and wrap around. Try Gen 200-800.
|
||||
16 15
|
||||
88 15
|
||||
160 15
|
||||
17 16
|
||||
33 16
|
||||
35 16
|
||||
53 16
|
||||
70 16
|
||||
89 16
|
||||
105 16
|
||||
107 16
|
||||
125 16
|
||||
142 16
|
||||
161 16
|
||||
177 16
|
||||
179 16
|
||||
15 17
|
||||
16 17
|
||||
17 17
|
||||
34 17
|
||||
35 17
|
||||
51 17
|
||||
53 17
|
||||
71 17
|
||||
72 17
|
||||
87 17
|
||||
88 17
|
||||
89 17
|
||||
106 17
|
||||
107 17
|
||||
123 17
|
||||
125 17
|
||||
143 17
|
||||
144 17
|
||||
159 17
|
||||
160 17
|
||||
161 17
|
||||
178 17
|
||||
179 17
|
||||
34 18
|
||||
52 18
|
||||
53 18
|
||||
70 18
|
||||
71 18
|
||||
106 18
|
||||
124 18
|
||||
125 18
|
||||
142 18
|
||||
143 18
|
||||
178 18
|
||||
70 33
|
||||
142 33
|
||||
15 34
|
||||
17 34
|
||||
35 34
|
||||
52 34
|
||||
71 34
|
||||
87 34
|
||||
89 34
|
||||
107 34
|
||||
124 34
|
||||
143 34
|
||||
159 34
|
||||
161 34
|
||||
179 34
|
||||
16 35
|
||||
17 35
|
||||
33 35
|
||||
35 35
|
||||
53 35
|
||||
54 35
|
||||
69 35
|
||||
70 35
|
||||
71 35
|
||||
88 35
|
||||
89 35
|
||||
105 35
|
||||
107 35
|
||||
125 35
|
||||
126 35
|
||||
141 35
|
||||
142 35
|
||||
143 35
|
||||
160 35
|
||||
161 35
|
||||
177 35
|
||||
179 35
|
||||
16 36
|
||||
34 36
|
||||
35 36
|
||||
52 36
|
||||
53 36
|
||||
88 36
|
||||
106 36
|
||||
107 36
|
||||
124 36
|
||||
125 36
|
||||
160 36
|
||||
178 36
|
||||
179 36
|
||||
52 51
|
||||
124 51
|
||||
17 52
|
||||
34 52
|
||||
53 52
|
||||
69 52
|
||||
71 52
|
||||
89 52
|
||||
106 52
|
||||
125 52
|
||||
141 52
|
||||
143 52
|
||||
161 52
|
||||
178 52
|
||||
15 53
|
||||
17 53
|
||||
35 53
|
||||
36 53
|
||||
51 53
|
||||
52 53
|
||||
53 53
|
||||
70 53
|
||||
71 53
|
||||
87 53
|
||||
89 53
|
||||
107 53
|
||||
108 53
|
||||
123 53
|
||||
124 53
|
||||
125 53
|
||||
142 53
|
||||
143 53
|
||||
159 53
|
||||
161 53
|
||||
179 53
|
||||
180 53
|
||||
16 54
|
||||
17 54
|
||||
34 54
|
||||
35 54
|
||||
70 54
|
||||
88 54
|
||||
89 54
|
||||
106 54
|
||||
107 54
|
||||
142 54
|
||||
160 54
|
||||
161 54
|
||||
178 54
|
||||
179 54
|
||||
34 69
|
||||
106 69
|
||||
178 69
|
||||
16 70
|
||||
35 70
|
||||
51 70
|
||||
53 70
|
||||
71 70
|
||||
88 70
|
||||
107 70
|
||||
123 70
|
||||
125 70
|
||||
143 70
|
||||
160 70
|
||||
179 70
|
||||
17 71
|
||||
18 71
|
||||
33 71
|
||||
34 71
|
||||
35 71
|
||||
52 71
|
||||
53 71
|
||||
69 71
|
||||
71 71
|
||||
89 71
|
||||
90 71
|
||||
105 71
|
||||
106 71
|
||||
107 71
|
||||
124 71
|
||||
125 71
|
||||
141 71
|
||||
143 71
|
||||
161 71
|
||||
162 71
|
||||
177 71
|
||||
178 71
|
||||
179 71
|
||||
16 72
|
||||
17 72
|
||||
52 72
|
||||
70 72
|
||||
71 72
|
||||
88 72
|
||||
89 72
|
||||
124 72
|
||||
142 72
|
||||
143 72
|
||||
160 72
|
||||
161 72
|
||||
16 87
|
||||
88 87
|
||||
160 87
|
||||
17 88
|
||||
33 88
|
||||
35 88
|
||||
53 88
|
||||
70 88
|
||||
89 88
|
||||
105 88
|
||||
107 88
|
||||
125 88
|
||||
142 88
|
||||
161 88
|
||||
177 88
|
||||
179 88
|
||||
15 89
|
||||
16 89
|
||||
17 89
|
||||
34 89
|
||||
35 89
|
||||
51 89
|
||||
53 89
|
||||
71 89
|
||||
72 89
|
||||
87 89
|
||||
88 89
|
||||
89 89
|
||||
106 89
|
||||
107 89
|
||||
123 89
|
||||
125 89
|
||||
143 89
|
||||
144 89
|
||||
159 89
|
||||
160 89
|
||||
161 89
|
||||
178 89
|
||||
179 89
|
||||
34 90
|
||||
52 90
|
||||
53 90
|
||||
70 90
|
||||
71 90
|
||||
106 90
|
||||
124 90
|
||||
125 90
|
||||
142 90
|
||||
143 90
|
||||
178 90
|
||||
70 105
|
||||
142 105
|
||||
15 106
|
||||
17 106
|
||||
35 106
|
||||
52 106
|
||||
71 106
|
||||
87 106
|
||||
89 106
|
||||
107 106
|
||||
124 106
|
||||
143 106
|
||||
159 106
|
||||
161 106
|
||||
179 106
|
||||
16 107
|
||||
17 107
|
||||
33 107
|
||||
35 107
|
||||
53 107
|
||||
54 107
|
||||
69 107
|
||||
70 107
|
||||
71 107
|
||||
88 107
|
||||
89 107
|
||||
105 107
|
||||
107 107
|
||||
125 107
|
||||
126 107
|
||||
141 107
|
||||
142 107
|
||||
143 107
|
||||
160 107
|
||||
161 107
|
||||
177 107
|
||||
179 107
|
||||
16 108
|
||||
34 108
|
||||
35 108
|
||||
52 108
|
||||
53 108
|
||||
88 108
|
||||
106 108
|
||||
107 108
|
||||
124 108
|
||||
125 108
|
||||
160 108
|
||||
178 108
|
||||
179 108
|
||||
52 123
|
||||
124 123
|
||||
17 124
|
||||
34 124
|
||||
53 124
|
||||
69 124
|
||||
71 124
|
||||
89 124
|
||||
106 124
|
||||
125 124
|
||||
141 124
|
||||
143 124
|
||||
161 124
|
||||
178 124
|
||||
15 125
|
||||
17 125
|
||||
35 125
|
||||
36 125
|
||||
51 125
|
||||
52 125
|
||||
53 125
|
||||
70 125
|
||||
71 125
|
||||
87 125
|
||||
89 125
|
||||
107 125
|
||||
108 125
|
||||
123 125
|
||||
124 125
|
||||
125 125
|
||||
142 125
|
||||
143 125
|
||||
159 125
|
||||
161 125
|
||||
179 125
|
||||
180 125
|
||||
16 126
|
||||
17 126
|
||||
34 126
|
||||
35 126
|
||||
70 126
|
||||
88 126
|
||||
89 126
|
||||
106 126
|
||||
107 126
|
||||
142 126
|
||||
160 126
|
||||
161 126
|
||||
178 126
|
||||
179 126
|
||||
34 141
|
||||
106 141
|
||||
178 141
|
||||
16 142
|
||||
35 142
|
||||
51 142
|
||||
53 142
|
||||
71 142
|
||||
88 142
|
||||
107 142
|
||||
123 142
|
||||
125 142
|
||||
143 142
|
||||
160 142
|
||||
179 142
|
||||
17 143
|
||||
18 143
|
||||
33 143
|
||||
34 143
|
||||
35 143
|
||||
52 143
|
||||
53 143
|
||||
69 143
|
||||
71 143
|
||||
89 143
|
||||
90 143
|
||||
105 143
|
||||
106 143
|
||||
107 143
|
||||
124 143
|
||||
125 143
|
||||
141 143
|
||||
143 143
|
||||
161 143
|
||||
162 143
|
||||
177 143
|
||||
178 143
|
||||
179 143
|
||||
16 144
|
||||
17 144
|
||||
52 144
|
||||
70 144
|
||||
71 144
|
||||
88 144
|
||||
89 144
|
||||
124 144
|
||||
142 144
|
||||
143 144
|
||||
160 144
|
||||
161 144
|
||||
16 159
|
||||
88 159
|
||||
160 159
|
||||
17 160
|
||||
33 160
|
||||
35 160
|
||||
53 160
|
||||
70 160
|
||||
89 160
|
||||
105 160
|
||||
107 160
|
||||
125 160
|
||||
142 160
|
||||
161 160
|
||||
177 160
|
||||
179 160
|
||||
15 161
|
||||
16 161
|
||||
17 161
|
||||
34 161
|
||||
35 161
|
||||
51 161
|
||||
53 161
|
||||
71 161
|
||||
72 161
|
||||
87 161
|
||||
88 161
|
||||
89 161
|
||||
106 161
|
||||
107 161
|
||||
123 161
|
||||
125 161
|
||||
143 161
|
||||
144 161
|
||||
159 161
|
||||
160 161
|
||||
161 161
|
||||
178 161
|
||||
179 161
|
||||
34 162
|
||||
52 162
|
||||
53 162
|
||||
70 162
|
||||
71 162
|
||||
106 162
|
||||
124 162
|
||||
125 162
|
||||
142 162
|
||||
143 162
|
||||
178 162
|
||||
70 177
|
||||
142 177
|
||||
15 178
|
||||
17 178
|
||||
35 178
|
||||
52 178
|
||||
71 178
|
||||
87 178
|
||||
89 178
|
||||
107 178
|
||||
124 178
|
||||
143 178
|
||||
159 178
|
||||
161 178
|
||||
179 178
|
||||
16 179
|
||||
17 179
|
||||
33 179
|
||||
35 179
|
||||
53 179
|
||||
54 179
|
||||
69 179
|
||||
70 179
|
||||
71 179
|
||||
88 179
|
||||
89 179
|
||||
105 179
|
||||
107 179
|
||||
125 179
|
||||
126 179
|
||||
141 179
|
||||
142 179
|
||||
143 179
|
||||
160 179
|
||||
161 179
|
||||
177 179
|
||||
179 179
|
||||
16 180
|
||||
34 180
|
||||
35 180
|
||||
52 180
|
||||
53 180
|
||||
88 180
|
||||
106 180
|
||||
107 180
|
||||
124 180
|
||||
125 180
|
||||
160 180
|
||||
178 180
|
||||
179 180
|
||||
@@ -0,0 +1,39 @@
|
||||
#Life 1.06
|
||||
#BOARD 300 0
|
||||
# A period-30 glider gun. Try Gen 300; gliders eventually wrap around.
|
||||
69 45
|
||||
67 46
|
||||
69 46
|
||||
57 47
|
||||
58 47
|
||||
65 47
|
||||
66 47
|
||||
79 47
|
||||
80 47
|
||||
56 48
|
||||
60 48
|
||||
65 48
|
||||
66 48
|
||||
79 48
|
||||
80 48
|
||||
45 49
|
||||
46 49
|
||||
55 49
|
||||
61 49
|
||||
65 49
|
||||
66 49
|
||||
45 50
|
||||
46 50
|
||||
55 50
|
||||
59 50
|
||||
61 50
|
||||
62 50
|
||||
67 50
|
||||
69 50
|
||||
55 51
|
||||
61 51
|
||||
69 51
|
||||
56 52
|
||||
60 52
|
||||
57 53
|
||||
58 53
|
||||
@@ -0,0 +1,157 @@
|
||||
#Life 1.06
|
||||
#BOARD 300 0
|
||||
# Pairs of blinkers, toads, beacons, pulsars and pentadecathlons. Loop to Gen 30.
|
||||
90 35
|
||||
91 35
|
||||
92 35
|
||||
190 35
|
||||
191 35
|
||||
192 35
|
||||
91 80
|
||||
92 80
|
||||
93 80
|
||||
191 80
|
||||
192 80
|
||||
193 80
|
||||
90 81
|
||||
91 81
|
||||
92 81
|
||||
190 81
|
||||
191 81
|
||||
192 81
|
||||
90 125
|
||||
91 125
|
||||
190 125
|
||||
191 125
|
||||
90 126
|
||||
91 126
|
||||
190 126
|
||||
191 126
|
||||
92 127
|
||||
93 127
|
||||
192 127
|
||||
193 127
|
||||
92 128
|
||||
93 128
|
||||
192 128
|
||||
193 128
|
||||
92 175
|
||||
93 175
|
||||
94 175
|
||||
98 175
|
||||
99 175
|
||||
100 175
|
||||
192 175
|
||||
193 175
|
||||
194 175
|
||||
198 175
|
||||
199 175
|
||||
200 175
|
||||
90 177
|
||||
95 177
|
||||
97 177
|
||||
102 177
|
||||
190 177
|
||||
195 177
|
||||
197 177
|
||||
202 177
|
||||
90 178
|
||||
95 178
|
||||
97 178
|
||||
102 178
|
||||
190 178
|
||||
195 178
|
||||
197 178
|
||||
202 178
|
||||
90 179
|
||||
95 179
|
||||
97 179
|
||||
102 179
|
||||
190 179
|
||||
195 179
|
||||
197 179
|
||||
202 179
|
||||
92 180
|
||||
93 180
|
||||
94 180
|
||||
98 180
|
||||
99 180
|
||||
100 180
|
||||
192 180
|
||||
193 180
|
||||
194 180
|
||||
198 180
|
||||
199 180
|
||||
200 180
|
||||
92 182
|
||||
93 182
|
||||
94 182
|
||||
98 182
|
||||
99 182
|
||||
100 182
|
||||
192 182
|
||||
193 182
|
||||
194 182
|
||||
198 182
|
||||
199 182
|
||||
200 182
|
||||
90 183
|
||||
95 183
|
||||
97 183
|
||||
102 183
|
||||
190 183
|
||||
195 183
|
||||
197 183
|
||||
202 183
|
||||
90 184
|
||||
95 184
|
||||
97 184
|
||||
102 184
|
||||
190 184
|
||||
195 184
|
||||
197 184
|
||||
202 184
|
||||
90 185
|
||||
95 185
|
||||
97 185
|
||||
102 185
|
||||
190 185
|
||||
195 185
|
||||
197 185
|
||||
202 185
|
||||
92 187
|
||||
93 187
|
||||
94 187
|
||||
98 187
|
||||
99 187
|
||||
100 187
|
||||
192 187
|
||||
193 187
|
||||
194 187
|
||||
198 187
|
||||
199 187
|
||||
200 187
|
||||
92 240
|
||||
97 240
|
||||
192 240
|
||||
197 240
|
||||
90 241
|
||||
91 241
|
||||
93 241
|
||||
94 241
|
||||
95 241
|
||||
96 241
|
||||
98 241
|
||||
99 241
|
||||
190 241
|
||||
191 241
|
||||
193 241
|
||||
194 241
|
||||
195 241
|
||||
196 241
|
||||
198 241
|
||||
199 241
|
||||
92 242
|
||||
97 242
|
||||
192 242
|
||||
197 242
|
||||
@@ -0,0 +1,111 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Nine period-15 oscillators. Slow playback or loop to Gen 15.
|
||||
42 40
|
||||
47 40
|
||||
92 40
|
||||
97 40
|
||||
142 40
|
||||
147 40
|
||||
40 41
|
||||
41 41
|
||||
43 41
|
||||
44 41
|
||||
45 41
|
||||
46 41
|
||||
48 41
|
||||
49 41
|
||||
90 41
|
||||
91 41
|
||||
93 41
|
||||
94 41
|
||||
95 41
|
||||
96 41
|
||||
98 41
|
||||
99 41
|
||||
140 41
|
||||
141 41
|
||||
143 41
|
||||
144 41
|
||||
145 41
|
||||
146 41
|
||||
148 41
|
||||
149 41
|
||||
42 42
|
||||
47 42
|
||||
92 42
|
||||
97 42
|
||||
142 42
|
||||
147 42
|
||||
42 90
|
||||
47 90
|
||||
92 90
|
||||
97 90
|
||||
142 90
|
||||
147 90
|
||||
40 91
|
||||
41 91
|
||||
43 91
|
||||
44 91
|
||||
45 91
|
||||
46 91
|
||||
48 91
|
||||
49 91
|
||||
90 91
|
||||
91 91
|
||||
93 91
|
||||
94 91
|
||||
95 91
|
||||
96 91
|
||||
98 91
|
||||
99 91
|
||||
140 91
|
||||
141 91
|
||||
143 91
|
||||
144 91
|
||||
145 91
|
||||
146 91
|
||||
148 91
|
||||
149 91
|
||||
42 92
|
||||
47 92
|
||||
92 92
|
||||
97 92
|
||||
142 92
|
||||
147 92
|
||||
42 140
|
||||
47 140
|
||||
92 140
|
||||
97 140
|
||||
142 140
|
||||
147 140
|
||||
40 141
|
||||
41 141
|
||||
43 141
|
||||
44 141
|
||||
45 141
|
||||
46 141
|
||||
48 141
|
||||
49 141
|
||||
90 141
|
||||
91 141
|
||||
93 141
|
||||
94 141
|
||||
95 141
|
||||
96 141
|
||||
98 141
|
||||
99 141
|
||||
140 141
|
||||
141 141
|
||||
143 141
|
||||
144 141
|
||||
145 141
|
||||
146 141
|
||||
148 141
|
||||
149 141
|
||||
42 142
|
||||
47 142
|
||||
92 142
|
||||
97 142
|
||||
142 142
|
||||
147 142
|
||||
@@ -0,0 +1,771 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Sixteen pulsars; a repeating three-generation geometric garden.
|
||||
37 35
|
||||
38 35
|
||||
39 35
|
||||
43 35
|
||||
44 35
|
||||
45 35
|
||||
77 35
|
||||
78 35
|
||||
79 35
|
||||
83 35
|
||||
84 35
|
||||
85 35
|
||||
117 35
|
||||
118 35
|
||||
119 35
|
||||
123 35
|
||||
124 35
|
||||
125 35
|
||||
157 35
|
||||
158 35
|
||||
159 35
|
||||
163 35
|
||||
164 35
|
||||
165 35
|
||||
35 37
|
||||
40 37
|
||||
42 37
|
||||
47 37
|
||||
75 37
|
||||
80 37
|
||||
82 37
|
||||
87 37
|
||||
115 37
|
||||
120 37
|
||||
122 37
|
||||
127 37
|
||||
155 37
|
||||
160 37
|
||||
162 37
|
||||
167 37
|
||||
35 38
|
||||
40 38
|
||||
42 38
|
||||
47 38
|
||||
75 38
|
||||
80 38
|
||||
82 38
|
||||
87 38
|
||||
115 38
|
||||
120 38
|
||||
122 38
|
||||
127 38
|
||||
155 38
|
||||
160 38
|
||||
162 38
|
||||
167 38
|
||||
35 39
|
||||
40 39
|
||||
42 39
|
||||
47 39
|
||||
75 39
|
||||
80 39
|
||||
82 39
|
||||
87 39
|
||||
115 39
|
||||
120 39
|
||||
122 39
|
||||
127 39
|
||||
155 39
|
||||
160 39
|
||||
162 39
|
||||
167 39
|
||||
37 40
|
||||
38 40
|
||||
39 40
|
||||
43 40
|
||||
44 40
|
||||
45 40
|
||||
77 40
|
||||
78 40
|
||||
79 40
|
||||
83 40
|
||||
84 40
|
||||
85 40
|
||||
117 40
|
||||
118 40
|
||||
119 40
|
||||
123 40
|
||||
124 40
|
||||
125 40
|
||||
157 40
|
||||
158 40
|
||||
159 40
|
||||
163 40
|
||||
164 40
|
||||
165 40
|
||||
37 42
|
||||
38 42
|
||||
39 42
|
||||
43 42
|
||||
44 42
|
||||
45 42
|
||||
77 42
|
||||
78 42
|
||||
79 42
|
||||
83 42
|
||||
84 42
|
||||
85 42
|
||||
117 42
|
||||
118 42
|
||||
119 42
|
||||
123 42
|
||||
124 42
|
||||
125 42
|
||||
157 42
|
||||
158 42
|
||||
159 42
|
||||
163 42
|
||||
164 42
|
||||
165 42
|
||||
35 43
|
||||
40 43
|
||||
42 43
|
||||
47 43
|
||||
75 43
|
||||
80 43
|
||||
82 43
|
||||
87 43
|
||||
115 43
|
||||
120 43
|
||||
122 43
|
||||
127 43
|
||||
155 43
|
||||
160 43
|
||||
162 43
|
||||
167 43
|
||||
35 44
|
||||
40 44
|
||||
42 44
|
||||
47 44
|
||||
75 44
|
||||
80 44
|
||||
82 44
|
||||
87 44
|
||||
115 44
|
||||
120 44
|
||||
122 44
|
||||
127 44
|
||||
155 44
|
||||
160 44
|
||||
162 44
|
||||
167 44
|
||||
35 45
|
||||
40 45
|
||||
42 45
|
||||
47 45
|
||||
75 45
|
||||
80 45
|
||||
82 45
|
||||
87 45
|
||||
115 45
|
||||
120 45
|
||||
122 45
|
||||
127 45
|
||||
155 45
|
||||
160 45
|
||||
162 45
|
||||
167 45
|
||||
37 47
|
||||
38 47
|
||||
39 47
|
||||
43 47
|
||||
44 47
|
||||
45 47
|
||||
77 47
|
||||
78 47
|
||||
79 47
|
||||
83 47
|
||||
84 47
|
||||
85 47
|
||||
117 47
|
||||
118 47
|
||||
119 47
|
||||
123 47
|
||||
124 47
|
||||
125 47
|
||||
157 47
|
||||
158 47
|
||||
159 47
|
||||
163 47
|
||||
164 47
|
||||
165 47
|
||||
37 75
|
||||
38 75
|
||||
39 75
|
||||
43 75
|
||||
44 75
|
||||
45 75
|
||||
77 75
|
||||
78 75
|
||||
79 75
|
||||
83 75
|
||||
84 75
|
||||
85 75
|
||||
117 75
|
||||
118 75
|
||||
119 75
|
||||
123 75
|
||||
124 75
|
||||
125 75
|
||||
157 75
|
||||
158 75
|
||||
159 75
|
||||
163 75
|
||||
164 75
|
||||
165 75
|
||||
35 77
|
||||
40 77
|
||||
42 77
|
||||
47 77
|
||||
75 77
|
||||
80 77
|
||||
82 77
|
||||
87 77
|
||||
115 77
|
||||
120 77
|
||||
122 77
|
||||
127 77
|
||||
155 77
|
||||
160 77
|
||||
162 77
|
||||
167 77
|
||||
35 78
|
||||
40 78
|
||||
42 78
|
||||
47 78
|
||||
75 78
|
||||
80 78
|
||||
82 78
|
||||
87 78
|
||||
115 78
|
||||
120 78
|
||||
122 78
|
||||
127 78
|
||||
155 78
|
||||
160 78
|
||||
162 78
|
||||
167 78
|
||||
35 79
|
||||
40 79
|
||||
42 79
|
||||
47 79
|
||||
75 79
|
||||
80 79
|
||||
82 79
|
||||
87 79
|
||||
115 79
|
||||
120 79
|
||||
122 79
|
||||
127 79
|
||||
155 79
|
||||
160 79
|
||||
162 79
|
||||
167 79
|
||||
37 80
|
||||
38 80
|
||||
39 80
|
||||
43 80
|
||||
44 80
|
||||
45 80
|
||||
77 80
|
||||
78 80
|
||||
79 80
|
||||
83 80
|
||||
84 80
|
||||
85 80
|
||||
117 80
|
||||
118 80
|
||||
119 80
|
||||
123 80
|
||||
124 80
|
||||
125 80
|
||||
157 80
|
||||
158 80
|
||||
159 80
|
||||
163 80
|
||||
164 80
|
||||
165 80
|
||||
37 82
|
||||
38 82
|
||||
39 82
|
||||
43 82
|
||||
44 82
|
||||
45 82
|
||||
77 82
|
||||
78 82
|
||||
79 82
|
||||
83 82
|
||||
84 82
|
||||
85 82
|
||||
117 82
|
||||
118 82
|
||||
119 82
|
||||
123 82
|
||||
124 82
|
||||
125 82
|
||||
157 82
|
||||
158 82
|
||||
159 82
|
||||
163 82
|
||||
164 82
|
||||
165 82
|
||||
35 83
|
||||
40 83
|
||||
42 83
|
||||
47 83
|
||||
75 83
|
||||
80 83
|
||||
82 83
|
||||
87 83
|
||||
115 83
|
||||
120 83
|
||||
122 83
|
||||
127 83
|
||||
155 83
|
||||
160 83
|
||||
162 83
|
||||
167 83
|
||||
35 84
|
||||
40 84
|
||||
42 84
|
||||
47 84
|
||||
75 84
|
||||
80 84
|
||||
82 84
|
||||
87 84
|
||||
115 84
|
||||
120 84
|
||||
122 84
|
||||
127 84
|
||||
155 84
|
||||
160 84
|
||||
162 84
|
||||
167 84
|
||||
35 85
|
||||
40 85
|
||||
42 85
|
||||
47 85
|
||||
75 85
|
||||
80 85
|
||||
82 85
|
||||
87 85
|
||||
115 85
|
||||
120 85
|
||||
122 85
|
||||
127 85
|
||||
155 85
|
||||
160 85
|
||||
162 85
|
||||
167 85
|
||||
37 87
|
||||
38 87
|
||||
39 87
|
||||
43 87
|
||||
44 87
|
||||
45 87
|
||||
77 87
|
||||
78 87
|
||||
79 87
|
||||
83 87
|
||||
84 87
|
||||
85 87
|
||||
117 87
|
||||
118 87
|
||||
119 87
|
||||
123 87
|
||||
124 87
|
||||
125 87
|
||||
157 87
|
||||
158 87
|
||||
159 87
|
||||
163 87
|
||||
164 87
|
||||
165 87
|
||||
37 115
|
||||
38 115
|
||||
39 115
|
||||
43 115
|
||||
44 115
|
||||
45 115
|
||||
77 115
|
||||
78 115
|
||||
79 115
|
||||
83 115
|
||||
84 115
|
||||
85 115
|
||||
117 115
|
||||
118 115
|
||||
119 115
|
||||
123 115
|
||||
124 115
|
||||
125 115
|
||||
157 115
|
||||
158 115
|
||||
159 115
|
||||
163 115
|
||||
164 115
|
||||
165 115
|
||||
35 117
|
||||
40 117
|
||||
42 117
|
||||
47 117
|
||||
75 117
|
||||
80 117
|
||||
82 117
|
||||
87 117
|
||||
115 117
|
||||
120 117
|
||||
122 117
|
||||
127 117
|
||||
155 117
|
||||
160 117
|
||||
162 117
|
||||
167 117
|
||||
35 118
|
||||
40 118
|
||||
42 118
|
||||
47 118
|
||||
75 118
|
||||
80 118
|
||||
82 118
|
||||
87 118
|
||||
115 118
|
||||
120 118
|
||||
122 118
|
||||
127 118
|
||||
155 118
|
||||
160 118
|
||||
162 118
|
||||
167 118
|
||||
35 119
|
||||
40 119
|
||||
42 119
|
||||
47 119
|
||||
75 119
|
||||
80 119
|
||||
82 119
|
||||
87 119
|
||||
115 119
|
||||
120 119
|
||||
122 119
|
||||
127 119
|
||||
155 119
|
||||
160 119
|
||||
162 119
|
||||
167 119
|
||||
37 120
|
||||
38 120
|
||||
39 120
|
||||
43 120
|
||||
44 120
|
||||
45 120
|
||||
77 120
|
||||
78 120
|
||||
79 120
|
||||
83 120
|
||||
84 120
|
||||
85 120
|
||||
117 120
|
||||
118 120
|
||||
119 120
|
||||
123 120
|
||||
124 120
|
||||
125 120
|
||||
157 120
|
||||
158 120
|
||||
159 120
|
||||
163 120
|
||||
164 120
|
||||
165 120
|
||||
37 122
|
||||
38 122
|
||||
39 122
|
||||
43 122
|
||||
44 122
|
||||
45 122
|
||||
77 122
|
||||
78 122
|
||||
79 122
|
||||
83 122
|
||||
84 122
|
||||
85 122
|
||||
117 122
|
||||
118 122
|
||||
119 122
|
||||
123 122
|
||||
124 122
|
||||
125 122
|
||||
157 122
|
||||
158 122
|
||||
159 122
|
||||
163 122
|
||||
164 122
|
||||
165 122
|
||||
35 123
|
||||
40 123
|
||||
42 123
|
||||
47 123
|
||||
75 123
|
||||
80 123
|
||||
82 123
|
||||
87 123
|
||||
115 123
|
||||
120 123
|
||||
122 123
|
||||
127 123
|
||||
155 123
|
||||
160 123
|
||||
162 123
|
||||
167 123
|
||||
35 124
|
||||
40 124
|
||||
42 124
|
||||
47 124
|
||||
75 124
|
||||
80 124
|
||||
82 124
|
||||
87 124
|
||||
115 124
|
||||
120 124
|
||||
122 124
|
||||
127 124
|
||||
155 124
|
||||
160 124
|
||||
162 124
|
||||
167 124
|
||||
35 125
|
||||
40 125
|
||||
42 125
|
||||
47 125
|
||||
75 125
|
||||
80 125
|
||||
82 125
|
||||
87 125
|
||||
115 125
|
||||
120 125
|
||||
122 125
|
||||
127 125
|
||||
155 125
|
||||
160 125
|
||||
162 125
|
||||
167 125
|
||||
37 127
|
||||
38 127
|
||||
39 127
|
||||
43 127
|
||||
44 127
|
||||
45 127
|
||||
77 127
|
||||
78 127
|
||||
79 127
|
||||
83 127
|
||||
84 127
|
||||
85 127
|
||||
117 127
|
||||
118 127
|
||||
119 127
|
||||
123 127
|
||||
124 127
|
||||
125 127
|
||||
157 127
|
||||
158 127
|
||||
159 127
|
||||
163 127
|
||||
164 127
|
||||
165 127
|
||||
37 155
|
||||
38 155
|
||||
39 155
|
||||
43 155
|
||||
44 155
|
||||
45 155
|
||||
77 155
|
||||
78 155
|
||||
79 155
|
||||
83 155
|
||||
84 155
|
||||
85 155
|
||||
117 155
|
||||
118 155
|
||||
119 155
|
||||
123 155
|
||||
124 155
|
||||
125 155
|
||||
157 155
|
||||
158 155
|
||||
159 155
|
||||
163 155
|
||||
164 155
|
||||
165 155
|
||||
35 157
|
||||
40 157
|
||||
42 157
|
||||
47 157
|
||||
75 157
|
||||
80 157
|
||||
82 157
|
||||
87 157
|
||||
115 157
|
||||
120 157
|
||||
122 157
|
||||
127 157
|
||||
155 157
|
||||
160 157
|
||||
162 157
|
||||
167 157
|
||||
35 158
|
||||
40 158
|
||||
42 158
|
||||
47 158
|
||||
75 158
|
||||
80 158
|
||||
82 158
|
||||
87 158
|
||||
115 158
|
||||
120 158
|
||||
122 158
|
||||
127 158
|
||||
155 158
|
||||
160 158
|
||||
162 158
|
||||
167 158
|
||||
35 159
|
||||
40 159
|
||||
42 159
|
||||
47 159
|
||||
75 159
|
||||
80 159
|
||||
82 159
|
||||
87 159
|
||||
115 159
|
||||
120 159
|
||||
122 159
|
||||
127 159
|
||||
155 159
|
||||
160 159
|
||||
162 159
|
||||
167 159
|
||||
37 160
|
||||
38 160
|
||||
39 160
|
||||
43 160
|
||||
44 160
|
||||
45 160
|
||||
77 160
|
||||
78 160
|
||||
79 160
|
||||
83 160
|
||||
84 160
|
||||
85 160
|
||||
117 160
|
||||
118 160
|
||||
119 160
|
||||
123 160
|
||||
124 160
|
||||
125 160
|
||||
157 160
|
||||
158 160
|
||||
159 160
|
||||
163 160
|
||||
164 160
|
||||
165 160
|
||||
37 162
|
||||
38 162
|
||||
39 162
|
||||
43 162
|
||||
44 162
|
||||
45 162
|
||||
77 162
|
||||
78 162
|
||||
79 162
|
||||
83 162
|
||||
84 162
|
||||
85 162
|
||||
117 162
|
||||
118 162
|
||||
119 162
|
||||
123 162
|
||||
124 162
|
||||
125 162
|
||||
157 162
|
||||
158 162
|
||||
159 162
|
||||
163 162
|
||||
164 162
|
||||
165 162
|
||||
35 163
|
||||
40 163
|
||||
42 163
|
||||
47 163
|
||||
75 163
|
||||
80 163
|
||||
82 163
|
||||
87 163
|
||||
115 163
|
||||
120 163
|
||||
122 163
|
||||
127 163
|
||||
155 163
|
||||
160 163
|
||||
162 163
|
||||
167 163
|
||||
35 164
|
||||
40 164
|
||||
42 164
|
||||
47 164
|
||||
75 164
|
||||
80 164
|
||||
82 164
|
||||
87 164
|
||||
115 164
|
||||
120 164
|
||||
122 164
|
||||
127 164
|
||||
155 164
|
||||
160 164
|
||||
162 164
|
||||
167 164
|
||||
35 165
|
||||
40 165
|
||||
42 165
|
||||
47 165
|
||||
75 165
|
||||
80 165
|
||||
82 165
|
||||
87 165
|
||||
115 165
|
||||
120 165
|
||||
122 165
|
||||
127 165
|
||||
155 165
|
||||
160 165
|
||||
162 165
|
||||
167 165
|
||||
37 167
|
||||
38 167
|
||||
39 167
|
||||
43 167
|
||||
44 167
|
||||
45 167
|
||||
77 167
|
||||
78 167
|
||||
79 167
|
||||
83 167
|
||||
84 167
|
||||
85 167
|
||||
117 167
|
||||
118 167
|
||||
119 167
|
||||
123 167
|
||||
124 167
|
||||
125 167
|
||||
157 167
|
||||
158 167
|
||||
159 167
|
||||
163 167
|
||||
164 167
|
||||
165 167
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Five cells grow into a complex expanding cloud. Try Gen 100-500.
|
||||
100 99
|
||||
101 99
|
||||
99 100
|
||||
100 100
|
||||
100 101
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,111 @@
|
||||
#Life 1.06
|
||||
#BOARD 200 0
|
||||
# Twelve lightweight spaceships travel left and wrap around. Try Gen 400.
|
||||
41 40
|
||||
44 40
|
||||
101 40
|
||||
104 40
|
||||
161 40
|
||||
164 40
|
||||
40 41
|
||||
100 41
|
||||
160 41
|
||||
40 42
|
||||
44 42
|
||||
100 42
|
||||
104 42
|
||||
160 42
|
||||
164 42
|
||||
40 43
|
||||
41 43
|
||||
42 43
|
||||
43 43
|
||||
100 43
|
||||
101 43
|
||||
102 43
|
||||
103 43
|
||||
160 43
|
||||
161 43
|
||||
162 43
|
||||
163 43
|
||||
41 80
|
||||
44 80
|
||||
101 80
|
||||
104 80
|
||||
161 80
|
||||
164 80
|
||||
40 81
|
||||
100 81
|
||||
160 81
|
||||
40 82
|
||||
44 82
|
||||
100 82
|
||||
104 82
|
||||
160 82
|
||||
164 82
|
||||
40 83
|
||||
41 83
|
||||
42 83
|
||||
43 83
|
||||
100 83
|
||||
101 83
|
||||
102 83
|
||||
103 83
|
||||
160 83
|
||||
161 83
|
||||
162 83
|
||||
163 83
|
||||
41 120
|
||||
44 120
|
||||
101 120
|
||||
104 120
|
||||
161 120
|
||||
164 120
|
||||
40 121
|
||||
100 121
|
||||
160 121
|
||||
40 122
|
||||
44 122
|
||||
100 122
|
||||
104 122
|
||||
160 122
|
||||
164 122
|
||||
40 123
|
||||
41 123
|
||||
42 123
|
||||
43 123
|
||||
100 123
|
||||
101 123
|
||||
102 123
|
||||
103 123
|
||||
160 123
|
||||
161 123
|
||||
162 123
|
||||
163 123
|
||||
41 160
|
||||
44 160
|
||||
101 160
|
||||
104 160
|
||||
161 160
|
||||
164 160
|
||||
40 161
|
||||
100 161
|
||||
160 161
|
||||
40 162
|
||||
44 162
|
||||
100 162
|
||||
104 162
|
||||
160 162
|
||||
164 162
|
||||
40 163
|
||||
41 163
|
||||
42 163
|
||||
43 163
|
||||
100 163
|
||||
101 163
|
||||
102 163
|
||||
103 163
|
||||
160 163
|
||||
161 163
|
||||
162 163
|
||||
163 163
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
cd -- "$(dirname -- "$0")"
|
||||
make portable
|
||||
python3 scripts/create_launcher.py
|
||||
printf '%s\n' 'Built portable Game of Life Sandbox and its desktop launcher.'
|
||||
+1845
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
cd -- "$(dirname -- "$0")"
|
||||
./build.sh
|
||||
exec ./game_of_life
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate a relocatable-at-build-time Linux launcher for this checkout."""
|
||||
from pathlib import Path
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
|
||||
def desktop_value(value):
|
||||
return str(value).replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r').replace('\t', '\\t')
|
||||
|
||||
def exec_argument(value):
|
||||
# Exec has its own quoting layer after desktop-entry string decoding.
|
||||
escaped = ''.join('\\' + c if c in '\\"`$' else c for c in str(value))
|
||||
return desktop_value('"' + escaped.replace('%', '%%') + '"')
|
||||
|
||||
launcher = root / 'Game of Life Sandbox.desktop'
|
||||
launcher.write_text(
|
||||
'[Desktop Entry]\n'
|
||||
'Type=Application\n'
|
||||
'Name=Game of Life Sandbox\n'
|
||||
'Comment=Draw, experiment, and explore Conway\'s Game of Life\n'
|
||||
f'Exec={exec_argument(root / "game_of_life")}\n'
|
||||
f'Path={desktop_value(root)}\n'
|
||||
f'Icon={desktop_value(root / "assets/game-of-life-sandbox.svg")}\n'
|
||||
'Terminal=false\n'
|
||||
'Categories=Game;Simulation;\n'
|
||||
'StartupNotify=false\n'
|
||||
'StartupWMClass=GameOfLifeSandbox\n'
|
||||
)
|
||||
launcher.chmod(0o755)
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# Build a pacman-installable release from the working tree, without publishing.
|
||||
set -euo pipefail
|
||||
project_root=$(cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd -- "$project_root"
|
||||
make dist
|
||||
version=$(cat VERSION)
|
||||
archive="game-of-life-sandbox-$version.tar.gz"
|
||||
package_work=$(mktemp -d "${TMPDIR:-/tmp}/life-package.XXXXXX")
|
||||
trap 'rm -rf -- "$package_work"' EXIT
|
||||
cp -- "dist/$archive" "$package_work/"
|
||||
cp -- PKGBUILD "$package_work/PKGBUILD"
|
||||
checksum=$(sha256sum "dist/$archive")
|
||||
checksum=${checksum%% *}
|
||||
# Reuse the AUR dependencies and build steps, but package the local source archive.
|
||||
cat >> "$package_work/PKGBUILD" <<EOF_LOCAL
|
||||
pkgname=game-of-life-sandbox
|
||||
pkgver=$version
|
||||
makedepends=()
|
||||
provides=()
|
||||
conflicts=('game-of-life-sandbox-git')
|
||||
source=('$archive')
|
||||
sha256sums=('$checksum')
|
||||
_srcdir='game-of-life-sandbox-$version'
|
||||
unset -f pkgver
|
||||
EOF_LOCAL
|
||||
(cd -- "$package_work" && PKGDEST="$project_root/dist" makepkg --cleanbuild --force)
|
||||
printf '\nPackage written to %s/dist/\nInstall it with: /usr/bin/pkexec pacman -U /absolute/path/to/the.pkg.tar.zst\n' "$project_root"
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
/* Preference storage only: simulation cells and runtime history are session data. */
|
||||
typedef enum { SETTING_INT, SETTING_BOOL, SETTING_ULL } SettingType;
|
||||
typedef struct {
|
||||
const char *name;
|
||||
SettingType type;
|
||||
void *value;
|
||||
long long defaultValue, minimum, maximum, step;
|
||||
} Setting;
|
||||
|
||||
static int settingsVersion = 1;
|
||||
static const Setting settings[] = {
|
||||
{"version", SETTING_INT, &settingsVersion, 1, 1, 1, 1},
|
||||
{"resolution", SETTING_INT, &resolution, 200, 25, 400, 25},
|
||||
{"start_density", SETTING_INT, &startDensity, 50, 0, 100, 5},
|
||||
{"update_interval_ms", SETTING_INT, &updateInterval, 100, 10, 1000, 10},
|
||||
{"hue", SETTING_INT, &hue, 275, 0, 360, 1},
|
||||
{"rainbow_hue", SETTING_BOOL, &rainbowHue, 0, 0, 1, 1},
|
||||
{"rainbow_speed", SETTING_INT, &rainbowSpeed, 30, 1, 180, 1},
|
||||
{"brush_size", SETTING_INT, &brushSize, 1, 1, 25, 1},
|
||||
{"grid_mode", SETTING_INT, &gridMode, GRID_OFF, GRID_OFF, GRID_GUIDELINES, 1},
|
||||
{"mirror_mode", SETTING_INT, &mirrorMode, 0, 0, 3, 1},
|
||||
{"line_snap", SETTING_BOOL, &snapLine, 1, 0, 1, 1},
|
||||
{"circle_from_corner", SETTING_BOOL, &circleFromCorner, 0, 0, 1, 1},
|
||||
{"pause_on_draw", SETTING_BOOL, &pauseOnDraw, 1, 0, 1, 1},
|
||||
{"loop_enabled", SETTING_BOOL, &loopEnabled, 0, 0, 1, 1},
|
||||
{"loop_end", SETTING_ULL, &loopEnd, 100, 1, MAX_LOOP_END, 1},
|
||||
{"show_top_bar", SETTING_BOOL, &showTopBar, 1, 0, 1, 1},
|
||||
{"show_controls", SETTING_BOOL, &showControls, 1, 0, 1, 1},
|
||||
{"tool", SETTING_INT, &tool, TOOL_BRUSH, TOOL_BRUSH, TOOL_SELECT, 1},
|
||||
{"selected_stamp", SETTING_INT, &selectedStamp, 0, 0, STAMP_COUNT - 1, 1},
|
||||
{"rotation", SETTING_INT, &rotation, 0, 0, 3, 1},
|
||||
{"category", SETTING_INT, &category, CATEGORY_DRAW, CATEGORY_DRAW, CATEGORY_HELP, 1},
|
||||
{"window_width", SETTING_INT, &windowWidth, 1240, 1, 16384, 1},
|
||||
{"window_height", SETTING_INT, &windowHeight, 900, 1, 16384, 1}
|
||||
};
|
||||
#define SETTING_COUNT (sizeof(settings) / sizeof(settings[0]))
|
||||
static char settingsPath[PATH_MAX] = "settings.cfg";
|
||||
static char settingsError[160];
|
||||
static bool settingsEnabled, hasSavedSettings;
|
||||
static long long savedSettings[SETTING_COUNT];
|
||||
|
||||
static long long settingValue(size_t index) {
|
||||
const Setting *s = &settings[index];
|
||||
if (s->value == &tool && tool == TOOL_PASTE) return TOOL_SELECT;
|
||||
if (s->type == SETTING_BOOL) return *(bool *)s->value;
|
||||
if (s->type == SETTING_ULL) return (long long)*(unsigned long long *)s->value;
|
||||
return *(int *)s->value;
|
||||
}
|
||||
|
||||
static void applySettings(const long long values[SETTING_COUNT]) {
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) {
|
||||
if (settings[i].type == SETTING_BOOL) *(bool *)settings[i].value = values[i] != 0;
|
||||
else if (settings[i].type == SETTING_ULL)
|
||||
*(unsigned long long *)settings[i].value = (unsigned long long)values[i];
|
||||
else *(int *)settings[i].value = (int)values[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Small, editable name=value format; booleans are 0 or 1. */
|
||||
static bool parseSettings(const char *text, long long values[SETTING_COUNT]) {
|
||||
bool seen[SETTING_COUNT] = {false};
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) values[i] = settings[i].defaultValue;
|
||||
bool any = false;
|
||||
while (*text) {
|
||||
const char *end = strchr(text, '\n');
|
||||
size_t length = end ? (size_t)(end - text) : strlen(text);
|
||||
if (length >= 128) return false;
|
||||
char line[128], key[64], extra;
|
||||
memcpy(line, text, length);
|
||||
line[length] = '\0';
|
||||
char *p = line;
|
||||
while (isspace((unsigned char)*p)) ++p;
|
||||
if (*p && *p != '#') {
|
||||
char number[64];
|
||||
if (sscanf(p, "%63[a-z_] = %63s %c", key, number, &extra) != 2) return false;
|
||||
size_t i;
|
||||
for (i = 0; i < SETTING_COUNT; ++i) if (strcmp(key, settings[i].name) == 0) break;
|
||||
if (i == SETTING_COUNT || seen[i]) return false;
|
||||
char *tail;
|
||||
errno = 0;
|
||||
long long value = strtoll(number, &tail, 10);
|
||||
if (errno || *tail || tail == number || value < settings[i].minimum
|
||||
|| value > settings[i].maximum || (value - settings[i].minimum) % settings[i].step)
|
||||
return false;
|
||||
values[i] = value;
|
||||
seen[i] = any = true;
|
||||
}
|
||||
text += length;
|
||||
if (*text == '\n') ++text;
|
||||
}
|
||||
return any;
|
||||
}
|
||||
|
||||
#ifndef SETTINGS_BEFORE_WRITE
|
||||
#define SETTINGS_BEFORE_WRITE() ((void)0)
|
||||
#endif
|
||||
|
||||
/* This function uses only its immutable arguments and is safe on the writer thread. */
|
||||
static bool writeSettingsSnapshot(const char *path, const long long values[SETTING_COUNT],
|
||||
char error[160]) {
|
||||
SETTINGS_BEFORE_WRITE();
|
||||
char temporary[PATH_MAX + 16];
|
||||
snprintf(temporary, sizeof(temporary), "%s.tmp.XXXXXX", path);
|
||||
int fd = mkstemp(temporary);
|
||||
if (fd < 0) goto failed;
|
||||
FILE *file = fdopen(fd, "w");
|
||||
if (!file) {
|
||||
close(fd);
|
||||
unlink(temporary);
|
||||
goto failed;
|
||||
}
|
||||
bool ok = fprintf(file, "# Game of Life settings; booleans: 0=off, 1=on\n") >= 0;
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i)
|
||||
if (fprintf(file, "%s=%lld\n", settings[i].name, values[i]) < 0) ok = false;
|
||||
if (fflush(file) != 0) ok = false;
|
||||
if (ok && fsync(fd) != 0) ok = false;
|
||||
if (fclose(file) != 0) ok = false;
|
||||
if (!ok || rename(temporary, path) != 0) {
|
||||
unlink(temporary);
|
||||
goto failed;
|
||||
}
|
||||
error[0] = '\0';
|
||||
return true;
|
||||
failed:
|
||||
snprintf(error, 160, "Cannot save settings.cfg. Check that the game folder is writable.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Synchronous startup repair; interactive saves use the worker below. */
|
||||
static bool writeSettings(void) {
|
||||
long long values[SETTING_COUNT];
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) values[i] = settingValue(i);
|
||||
if (!writeSettingsSnapshot(settingsPath, values, settingsError)) return false;
|
||||
memcpy(savedSettings, values, sizeof(savedSettings));
|
||||
hasSavedSettings = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static pthread_t settingsThread;
|
||||
static pthread_mutex_t settingsMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t settingsCondition = PTHREAD_COND_INITIALIZER;
|
||||
static bool settingsWorkerRunning, settingsWorkerStopping, settingsWritePending;
|
||||
static bool settingsResultReady, settingsResultSuccess;
|
||||
static long long pendingSettings[SETTING_COUNT], resultSettings[SETTING_COUNT];
|
||||
static long long queuedSettings[SETTING_COUNT]; /* UI-thread-only comparison cache. */
|
||||
static bool hasQueuedSettings;
|
||||
static char pendingSettingsPath[PATH_MAX], settingsResultError[160];
|
||||
static struct timespec settingsDeadline;
|
||||
|
||||
static void *settingsWriter(void *unused) {
|
||||
(void)unused;
|
||||
pthread_mutex_lock(&settingsMutex);
|
||||
for (;;) {
|
||||
while (!settingsWritePending && !settingsWorkerStopping)
|
||||
pthread_cond_wait(&settingsCondition, &settingsMutex);
|
||||
if (!settingsWritePending && settingsWorkerStopping) break;
|
||||
if (!settingsWorkerStopping) {
|
||||
int result = pthread_cond_timedwait(&settingsCondition, &settingsMutex, &settingsDeadline);
|
||||
if (result != ETIMEDOUT) continue; /* A new change extends the debounce. */
|
||||
}
|
||||
long long values[SETTING_COUNT];
|
||||
char path[PATH_MAX], error[160] = {0};
|
||||
memcpy(values, pendingSettings, sizeof(values));
|
||||
memcpy(path, pendingSettingsPath, sizeof(path));
|
||||
settingsWritePending = false;
|
||||
pthread_mutex_unlock(&settingsMutex);
|
||||
|
||||
bool success = writeSettingsSnapshot(path, values, error);
|
||||
|
||||
pthread_mutex_lock(&settingsMutex);
|
||||
settingsResultReady = true;
|
||||
settingsResultSuccess = success;
|
||||
memcpy(resultSettings, values, sizeof(values));
|
||||
memcpy(settingsResultError, error, sizeof(error));
|
||||
}
|
||||
pthread_mutex_unlock(&settingsMutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void pollSettingsWriter(void) {
|
||||
if (!settingsWorkerRunning) return;
|
||||
pthread_mutex_lock(&settingsMutex);
|
||||
if (settingsResultReady) {
|
||||
if (settingsResultSuccess) {
|
||||
memcpy(savedSettings, resultSettings, sizeof(savedSettings));
|
||||
hasSavedSettings = true;
|
||||
}
|
||||
memcpy(settingsError, settingsResultError, sizeof(settingsError));
|
||||
settingsResultReady = false;
|
||||
}
|
||||
pthread_mutex_unlock(&settingsMutex);
|
||||
}
|
||||
|
||||
static void saveSettingsIfChanged(void) {
|
||||
if (!settingsEnabled) return;
|
||||
long long values[SETTING_COUNT];
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) values[i] = settingValue(i);
|
||||
const long long *previous = settingsWorkerRunning ? queuedSettings : savedSettings;
|
||||
bool hasPrevious = settingsWorkerRunning ? hasQueuedSettings : hasSavedSettings;
|
||||
if (hasPrevious && memcmp(values, previous, sizeof(values)) == 0) return;
|
||||
if (!settingsWorkerRunning) { writeSettings(); return; }
|
||||
|
||||
/* No file operations or disk synchronization occur in input callbacks. */
|
||||
pthread_mutex_lock(&settingsMutex);
|
||||
memcpy(pendingSettings, values, sizeof(values));
|
||||
memcpy(pendingSettingsPath, settingsPath, sizeof(settingsPath));
|
||||
clock_gettime(CLOCK_REALTIME, &settingsDeadline);
|
||||
settingsDeadline.tv_nsec += 250000000L;
|
||||
if (settingsDeadline.tv_nsec >= 1000000000L) {
|
||||
++settingsDeadline.tv_sec;
|
||||
settingsDeadline.tv_nsec -= 1000000000L;
|
||||
}
|
||||
settingsWritePending = true;
|
||||
pthread_cond_signal(&settingsCondition);
|
||||
pthread_mutex_unlock(&settingsMutex);
|
||||
memcpy(queuedSettings, values, sizeof(values));
|
||||
hasQueuedSettings = true;
|
||||
}
|
||||
|
||||
static void startSettingsWriter(void) {
|
||||
if (settingsWorkerRunning || !settingsEnabled) return;
|
||||
settingsWorkerStopping = settingsWritePending = settingsResultReady = false;
|
||||
hasQueuedSettings = hasSavedSettings;
|
||||
memcpy(queuedSettings, savedSettings, sizeof(queuedSettings));
|
||||
if (pthread_create(&settingsThread, NULL, settingsWriter, NULL) != 0) {
|
||||
snprintf(settingsError, sizeof(settingsError), "Cannot start settings autosave worker.");
|
||||
settingsEnabled = false;
|
||||
return;
|
||||
}
|
||||
settingsWorkerRunning = true;
|
||||
}
|
||||
|
||||
static void stopSettingsWriter(void) {
|
||||
if (!settingsWorkerRunning) return;
|
||||
saveSettingsIfChanged();
|
||||
pthread_mutex_lock(&settingsMutex);
|
||||
settingsWorkerStopping = true;
|
||||
pthread_cond_signal(&settingsCondition);
|
||||
pthread_mutex_unlock(&settingsMutex);
|
||||
/* Only shutdown waits for disk I/O, including the latest queued preference. */
|
||||
pthread_join(settingsThread, NULL);
|
||||
pollSettingsWriter();
|
||||
settingsWorkerRunning = false;
|
||||
}
|
||||
|
||||
static bool loadSettings(void) {
|
||||
char buffer[8192];
|
||||
long long values[SETTING_COUNT];
|
||||
bool valid = false;
|
||||
FILE *file = fopen(settingsPath, "rb");
|
||||
if (file) {
|
||||
size_t count = fread(buffer, 1, sizeof(buffer) - 1, file);
|
||||
bool readable = !ferror(file) && feof(file);
|
||||
buffer[count] = '\0';
|
||||
if (readable && !memchr(buffer, '\0', count)) valid = parseSettings(buffer, values);
|
||||
fclose(file);
|
||||
}
|
||||
if (!valid)
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) values[i] = settings[i].defaultValue;
|
||||
applySettings(values);
|
||||
settingsEnabled = true;
|
||||
hasSavedSettings = false;
|
||||
/* Canonical output also fills any omitted preferences with their defaults. */
|
||||
writeSettings();
|
||||
return valid;
|
||||
}
|
||||
|
||||
static void initializeSettings(void) {
|
||||
#if !APP_PORTABLE
|
||||
if (!initializeUserPaths(settingsPath)) {
|
||||
fprintf(stderr, "%s: cannot create user configuration/data directories.\n", APP_NAME);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#else
|
||||
/* Keep preferences beside the executable, even when launched from elsewhere. */
|
||||
char executable[PATH_MAX];
|
||||
ssize_t length = readlink("/proc/self/exe", executable, sizeof(executable) - 1);
|
||||
if (length > 0 && (size_t)length < sizeof(executable) - 1) {
|
||||
executable[length] = '\0';
|
||||
char *slash = strrchr(executable, '/');
|
||||
if (slash) {
|
||||
slash[1] = '\0';
|
||||
size_t prefixLength = strlen(executable);
|
||||
if (prefixLength + sizeof("settings.cfg") <= sizeof(settingsPath)) {
|
||||
memcpy(settingsPath, executable, prefixLength);
|
||||
memcpy(settingsPath + prefixLength, "settings.cfg", sizeof("settings.cfg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
loadSettings();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <GL/glut.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "../app_identity.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
|
||||
glutInitWindowSize(320, 240);
|
||||
glutCreateWindow(APP_NAME);
|
||||
setAppIdentity();
|
||||
Display *display = glXGetCurrentDisplay();
|
||||
Window window = (Window)glXGetCurrentDrawable();
|
||||
char *title = NULL;
|
||||
assert(XFetchName(display, window, &title) && !strcmp(title, APP_NAME));
|
||||
XFree(title);
|
||||
XClassHint identity;
|
||||
assert(XGetClassHint(display, window, &identity));
|
||||
assert(!strcmp(identity.res_class, "GameOfLifeSandbox"));
|
||||
assert(!strcmp(identity.res_name, "game-of-life-sandbox"));
|
||||
XFree(identity.res_class); XFree(identity.res_name);
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long count, remaining;
|
||||
unsigned char *data;
|
||||
assert(XGetWindowProperty(display, window, XInternAtom(display, "_NET_WM_ICON", False),
|
||||
0, 2 + 64 * 64 + 2 + 128 * 128, False, XA_CARDINAL,
|
||||
&type, &format, &count, &remaining, &data) == Success);
|
||||
assert(type == XA_CARDINAL && format == 32 && remaining == 0);
|
||||
assert(count == 2 + 64 * 64 + 2 + 128 * 128);
|
||||
unsigned long *pixels = (unsigned long *)data;
|
||||
int offset = 0;
|
||||
for (int size = 64; size <= 128; size *= 2) {
|
||||
assert(pixels[offset++] == (unsigned long)size);
|
||||
assert(pixels[offset++] == (unsigned long)size);
|
||||
assert(pixels[offset] == 0); /* Transparent rounded corner. */
|
||||
int live = 0;
|
||||
for (int i = 0; i < size * size; ++i)
|
||||
live += (pixels[offset + i] & 0xffffffffUL) == 0xffc58affUL;
|
||||
assert(live == 5 * 8 * 8 * (size / 64) * (size / 64));
|
||||
offset += size * size;
|
||||
}
|
||||
XFree(data);
|
||||
XSync(display, False);
|
||||
puts("PASS: app title, desktop window class, and embedded 64/128px glider icons");
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#define main game_main
|
||||
#include "../game_of_life.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static EditSnapshot sourceBoard, loadedBoard;
|
||||
|
||||
static void corruptFile(const char *path, const char *text) {
|
||||
FILE *file = fopen(path, "w");
|
||||
assert(file && fputs(text, file) >= 0);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
notifyBoard("Board opened.");
|
||||
double started = boardMessageStarted;
|
||||
assert(boardNotificationVisibility(started) == 0);
|
||||
assert(boardNotificationVisibility(started + 125) == 0.5f);
|
||||
assert(boardNotificationVisibility(started + 250) == 1);
|
||||
assert(boardNotificationVisibility(started + 3250) == 1);
|
||||
assert(boardNotificationVisibility(started + 3375) == 0.5f);
|
||||
assert(boardNotificationVisibility(started + 3500) == 0 && !boardMessage[0]);
|
||||
notifyBoard("Board saved.");
|
||||
assert(boardMessage[0] && boardNotificationVisibility(boardMessageStarted + 250) == 1);
|
||||
|
||||
char directory[] = "/tmp/life-board-test-XXXXXX";
|
||||
assert(mkdtemp(directory));
|
||||
char path[PATH_MAX], error[160] = {0};
|
||||
snprintf(path, sizeof(path), "%s/a board.life", directory);
|
||||
for (int size = 25; size <= 400; size += 375) {
|
||||
memset(&sourceBoard, 0, sizeof(sourceBoard));
|
||||
sourceBoard.resolution = size;
|
||||
sourceBoard.generation = 12345;
|
||||
for (int i = 0; i < size * size; ++i) {
|
||||
sourceBoard.cells[i] = (i % 3 == 0 || i == size * size - 1);
|
||||
sourceBoard.population += sourceBoard.cells[i];
|
||||
}
|
||||
assert(writeBoardFile(path, &sourceBoard, error));
|
||||
assert(readBoardFile(path, &loadedBoard, error));
|
||||
assert(loadedBoard.resolution == size && loadedBoard.generation == 12345);
|
||||
assert(loadedBoard.population == sourceBoard.population);
|
||||
assert(memcmp(loadedBoard.cells, sourceBoard.cells, (size_t)size * size) == 0);
|
||||
}
|
||||
memset(&sourceBoard, 0, sizeof(sourceBoard));
|
||||
sourceBoard.resolution = 50;
|
||||
assert(writeBoardFile(path, &sourceBoard, error));
|
||||
assert(readBoardFile(path, &loadedBoard, error) && loadedBoard.population == 0);
|
||||
const char *invalid[] = {
|
||||
"", "garbage\n", "#Life 1.06\n", "#Life 1.06\n1 2\n",
|
||||
"#Life 1.06\n#BOARD 26 0\n", "#Life 1.06\n#BOARD 500 0\n",
|
||||
"#Life 1.06\n#BOARD 25 0\n25 0\n", "#Life 1.06\n#BOARD 25 0\n-1 0\n",
|
||||
"#Life 1.06\n#BOARD 25 0\n1 2 extra\n", "#Life 1.06\n#BOARD 25 0\n1 2\n1 2\n",
|
||||
"#Life 1.06\n#BOARD 25 0\n#BOARD 25 1\n", "#Life 1.06\n#BOARD 25 -1\n",
|
||||
"#Life 1.06\n#BOARD 25 99999999999999999999999999999999999\n"
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(invalid) / sizeof(invalid[0]); ++i) {
|
||||
corruptFile(path, invalid[i]);
|
||||
assert(!readBoardFile(path, &loadedBoard, error));
|
||||
}
|
||||
corruptFile(path, "#Life 1.06\r\n#BOARD 25 3\r\n# comment\r\n0 0\r\n24 24\r\n");
|
||||
assert(readBoardFile(path, &loadedBoard, error) && loadedBoard.population == 2);
|
||||
resolution = 50;
|
||||
memset(grid, 0, 2500);
|
||||
grid[0] = 1; population = 1; generation = 99;
|
||||
int priorUndo = undoCount;
|
||||
applyBoard(&loadedBoard);
|
||||
assert(paused && resolution == 25 && population == 2 && generation == 3);
|
||||
assert(undoCount == priorUndo + 1 && playbackStart.population == 2);
|
||||
assert(undoHistory[(undoNext + UNDO_LIMIT - 1) % UNDO_LIMIT].generation == 99);
|
||||
char blocked[PATH_MAX];
|
||||
snprintf(blocked, sizeof(blocked), "%s/blocked", directory);
|
||||
assert(mkdir(blocked, 0700) == 0);
|
||||
assert(!writeBoardFile(blocked, &loadedBoard, error));
|
||||
assert(rmdir(blocked) == 0);
|
||||
for (int i = 0; i < EXAMPLE_COUNT; ++i) {
|
||||
boardPath(path, exampleFiles[i]);
|
||||
assert(readBoardFile(path, &loadedBoard, error));
|
||||
assert(loadedBoard.population > 0 && loadedBoard.generation == 0);
|
||||
applyBoard(&loadedBoard);
|
||||
for (int step = 0; step < 20; ++step) updateGrid();
|
||||
assert(generation == 20);
|
||||
for (int step = 0; step < 20; ++step) assert(rewindGeneration());
|
||||
assert(memcmp(grid, loadedBoard.cells, (size_t)resolution * resolution) == 0);
|
||||
}
|
||||
clearHistory();
|
||||
startBoardJob(false, 0);
|
||||
assert(boardBusy);
|
||||
struct timespec delay = {0, 1000000L};
|
||||
for (int i = 0; i < 5000 && boardBusy; ++i) { pollBoardJob(); nanosleep(&delay, NULL); }
|
||||
assert(!boardBusy && resolution == 300 && population == 2187 && generation == 0);
|
||||
snprintf(path, sizeof(path), "%s/a board.life", directory);
|
||||
assert(unlink(path) == 0 && rmdir(directory) == 0);
|
||||
/* Named saves stay in the user folder and cannot silently replace a file. */
|
||||
char library[] = "/tmp/life-library-test-XXXXXX";
|
||||
assert(mkdtemp(library));
|
||||
snprintf(settingsPath, sizeof(settingsPath), "%s/settings.cfg", library);
|
||||
snprintf(boardName, sizeof(boardName), "My garden");
|
||||
assert(namedBoardPath(path));
|
||||
assert(strstr(path, "/boards/My garden.life"));
|
||||
snprintf(boardName, sizeof(boardName), "../examples/oops");
|
||||
assert(!namedBoardPath(path));
|
||||
snprintf(boardName, sizeof(boardName), "My garden.life");
|
||||
assert(namedBoardPath(path));
|
||||
submitBoardName();
|
||||
for (int i = 0; i < 5000 && boardBusy; ++i) { pollBoardJob(); nanosleep(&delay, NULL); }
|
||||
assert(!boardBusy && boardJob.success && !boardJob.dialog);
|
||||
assert(readBoardFile(path, &loadedBoard, error));
|
||||
assert(loadedBoard.population == population);
|
||||
assert(!writeBoardFileMode(path, &loadedBoard, error, false));
|
||||
submitBoardName();
|
||||
assert(confirmReplace && !boardBusy);
|
||||
submitBoardName();
|
||||
for (int i = 0; i < 5000 && boardBusy; ++i) { pollBoardJob(); nanosleep(&delay, NULL); }
|
||||
assert(!boardBusy && boardJob.success);
|
||||
char exampleDirectory[PATH_MAX], nestedPath[PATH_MAX], invalidPath[PATH_MAX];
|
||||
boardPath(exampleDirectory, "examples");
|
||||
assert(mkdir(exampleDirectory, 0700) == 0);
|
||||
boardPath(nestedPath, "examples/bundled.life");
|
||||
assert(writeBoardFile(nestedPath, &loadedBoard, error));
|
||||
boardPath(invalidPath, "invalid.life");
|
||||
corruptFile(invalidPath, "not a board");
|
||||
requestBoardCatalog(1);
|
||||
for (int i = 0; i < 5000 && catalogBusy; ++i) { pollBoardCatalog(); nanosleep(&delay, NULL); }
|
||||
assert(!catalogBusy && catalogs[1].count == 1);
|
||||
assert(strcmp(catalogs[1].items[0].name, "My garden") == 0);
|
||||
assert(catalogs[1].items[0].population == population);
|
||||
assert(unlink(path) == 0);
|
||||
assert(unlink(nestedPath) == 0 && rmdir(exampleDirectory) == 0);
|
||||
assert(unlink(invalidPath) == 0);
|
||||
boardPath(path, "");
|
||||
assert(rmdir(path) == 0 && rmdir(library) == 0);
|
||||
closeBoardCatalogs();
|
||||
closeHistory();
|
||||
puts("PASS: board round trips, empty/max grids, validation, atomic failure, undo snapshot, example evolution, asynchronous loading");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
/* Real X11 input regression: no mocked modifier state. */
|
||||
#include <GL/freeglut.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <X11/keysym.h>
|
||||
#define main game_main
|
||||
#include "../game_of_life.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
|
||||
static Display *inputDisplay;
|
||||
static int originX, originY;
|
||||
static void pump(void) {
|
||||
XSync(inputDisplay, False);
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
glutMainLoopEvent();
|
||||
struct timespec delay = {0, 1000000L};
|
||||
nanosleep(&delay, NULL);
|
||||
}
|
||||
}
|
||||
static void pointerAt(int col, int row) {
|
||||
int x = (int)(boardX + (col + 0.5f) * boardSize / resolution);
|
||||
int y = (int)(boardY + (row + 0.5f) * boardSize / resolution);
|
||||
XTestFakeMotionEvent(inputDisplay, -1, originX + x, originY + y, CurrentTime);
|
||||
pump();
|
||||
}
|
||||
static void control(KeySym key, bool down) {
|
||||
XTestFakeKeyEvent(inputDisplay, XKeysymToKeycode(inputDisplay, key), down, CurrentTime);
|
||||
pump();
|
||||
display(); /* Refresh even when the pointer is stationary. */
|
||||
}
|
||||
int main(int argc, char **argv) {
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
|
||||
glutInitWindowSize(600, 440);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutCreateWindow("Circle input regression");
|
||||
glutDisplayFunc(display);
|
||||
glutReshapeFunc(reshape);
|
||||
glutMouseFunc(mouse);
|
||||
glutMotionFunc(motion);
|
||||
glutPassiveMotionFunc(motion);
|
||||
inputDisplay = glXGetCurrentDisplay();
|
||||
pump();
|
||||
Window child;
|
||||
XTranslateCoordinates(inputDisplay, (Window)glXGetCurrentDrawable(),
|
||||
DefaultRootWindow(inputDisplay), 0, 0, &originX, &originY, &child);
|
||||
resolution = 50;
|
||||
tool = TOOL_CIRCLE;
|
||||
circleFromCorner = true;
|
||||
brushSize = 1;
|
||||
for (int right = 0; right < 2; ++right) {
|
||||
KeySym key = right ? XK_Control_R : XK_Control_L;
|
||||
memset(grid, 0, (size_t)resolution * resolution);
|
||||
population = 0;
|
||||
pointerAt(15, 15);
|
||||
XTestFakeButtonEvent(inputDisplay, 1, True, CurrentTime);
|
||||
pump();
|
||||
assert(drawing);
|
||||
pointerAt(30, 22);
|
||||
assert(endCol == 30 && endRow == 22);
|
||||
control(key, true);
|
||||
assert(endCol == 30 && endRow == 30);
|
||||
pointerAt(32, 23);
|
||||
assert(endCol == 32 && endRow == 32);
|
||||
control(key, false);
|
||||
assert(endCol == 32 && endRow == 23);
|
||||
control(key, true);
|
||||
XTestFakeButtonEvent(inputDisplay, 1, False, CurrentTime);
|
||||
pump();
|
||||
assert(!drawing && population > 0);
|
||||
/* A constrained circle must have equal extents and transpose symmetry. */
|
||||
int minX = 50, minY = 50, maxX = -1, maxY = -1;
|
||||
for (int y = 0; y < 50; ++y) for (int x = 0; x < 50; ++x) {
|
||||
assert(grid[y * 50 + x] == grid[x * 50 + y]);
|
||||
if (!grid[y * 50 + x]) continue;
|
||||
if (x < minX) minX = x;
|
||||
if (x > maxX) maxX = x;
|
||||
if (y < minY) minY = y;
|
||||
if (y > maxY) maxY = y;
|
||||
}
|
||||
assert(maxX - minX == maxY - minY);
|
||||
control(key, false);
|
||||
}
|
||||
assert(glGetError() == GL_NO_ERROR);
|
||||
closeHistory();
|
||||
puts("PASS: real left/right Ctrl input, live preview, unconstrained ellipse, and round committed circles");
|
||||
}
|
||||
+1277
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,43 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#define APP_PORTABLE 0
|
||||
#define APP_DATA_DIR "/usr/share/game-of-life-sandbox"
|
||||
#define main game_main
|
||||
#include "../game_of_life.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
|
||||
int main(void) {
|
||||
char directory[] = "/tmp/life-xdg-test-XXXXXX";
|
||||
assert(mkdtemp(directory));
|
||||
char config[PATH_MAX], data[PATH_MAX], path[PATH_MAX], expected[PATH_MAX];
|
||||
snprintf(config, sizeof(config), "%s/config", directory);
|
||||
snprintf(data, sizeof(data), "%s/data", directory);
|
||||
assert(setenv("XDG_CONFIG_HOME", config, 1) == 0);
|
||||
assert(setenv("XDG_DATA_HOME", data, 1) == 0);
|
||||
initializeSettings();
|
||||
snprintf(expected, sizeof(expected), "%s/config/game-of-life-sandbox/settings.cfg", directory);
|
||||
assert(strcmp(settingsPath, expected) == 0);
|
||||
assert(access(settingsPath, R_OK | W_OK) == 0);
|
||||
boardPath(path, "My board.life");
|
||||
snprintf(expected, sizeof(expected), "%s/data/game-of-life-sandbox/boards/My board.life", directory);
|
||||
assert(strcmp(path, expected) == 0);
|
||||
EditSnapshot board = {.resolution = 25, .population = 1};
|
||||
board.cells[0] = 1;
|
||||
char message[160];
|
||||
assert(writeBoardFile(path, &board, message));
|
||||
assert(unlink(path) == 0);
|
||||
boardPath(path, "examples/gosper-glider-gun.life");
|
||||
assert(strcmp(path, "/usr/share/game-of-life-sandbox/examples/gosper-glider-gun.life") == 0);
|
||||
boardPath(path, "examples/");
|
||||
assert(strcmp(path, "/usr/share/game-of-life-sandbox/examples/") == 0);
|
||||
struct stat info;
|
||||
assert(stat(userBoardsDirectory, &info) == 0 && (info.st_mode & 0777) == 0700);
|
||||
assert(unlink(settingsPath) == 0);
|
||||
assert(rmdir(userBoardsDirectory) == 0);
|
||||
snprintf(path, sizeof(path), "%s/data/game-of-life-sandbox", directory);
|
||||
assert(rmdir(path) == 0 && rmdir(data) == 0);
|
||||
snprintf(path, sizeof(path), "%s/config/game-of-life-sandbox", directory);
|
||||
assert(rmdir(path) == 0 && rmdir(config) == 0 && rmdir(directory) == 0);
|
||||
puts("PASS: installed XDG settings, private user boards, and separate system examples");
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#include <stdatomic.h>
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
static atomic_bool blockSettingsWrites, settingsWriteEntered;
|
||||
static atomic_int settingsWriteAttempts;
|
||||
static void beforeSettingsWrite(void) {
|
||||
atomic_fetch_add(&settingsWriteAttempts, 1);
|
||||
if (atomic_load(&blockSettingsWrites)) {
|
||||
atomic_store(&settingsWriteEntered, true);
|
||||
const struct timespec pause = {0, 1000000L};
|
||||
while (atomic_load(&blockSettingsWrites)) nanosleep(&pause, NULL);
|
||||
}
|
||||
}
|
||||
#define SETTINGS_BEFORE_WRITE() beforeSettingsWrite()
|
||||
#define main game_main
|
||||
#include "../game_of_life.c"
|
||||
#undef main
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static void putFile(const char *content) {
|
||||
FILE *file = fopen(settingsPath, "wb");
|
||||
assert(file);
|
||||
assert(fputs(content, file) >= 0);
|
||||
assert(fclose(file) == 0);
|
||||
}
|
||||
|
||||
static void checkCanonical(void) {
|
||||
char buffer[8192];
|
||||
FILE *file = fopen(settingsPath, "rb");
|
||||
assert(file);
|
||||
size_t n = fread(buffer, 1, sizeof(buffer) - 1, file);
|
||||
assert(!ferror(file));
|
||||
buffer[n] = '\0';
|
||||
fclose(file);
|
||||
long long values[SETTING_COUNT];
|
||||
assert(parseSettings(buffer, values));
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) assert(values[i] == settingValue(i));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc == 3 && strcmp(argv[1], "--create-defaults") == 0) {
|
||||
assert(strlen(argv[2]) < sizeof(settingsPath));
|
||||
snprintf(settingsPath, sizeof(settingsPath), "%s", argv[2]);
|
||||
assert(access(settingsPath, F_OK) != 0);
|
||||
assert(writeSettings());
|
||||
return 0;
|
||||
}
|
||||
char directory[] = "/tmp/life-settings-test-XXXXXX";
|
||||
assert(mkdtemp(directory));
|
||||
snprintf(settingsPath, sizeof(settingsPath), "%s/settings.cfg", directory);
|
||||
assert(!loadSettings());
|
||||
assert(hue == 275 && resolution == 200 && loopEnd == 100 && pauseOnDraw);
|
||||
checkCanonical();
|
||||
showTopBar = false;
|
||||
rainbowHue = true; rainbowSpeed = 75;
|
||||
hue = 42; resolution = 125; startDensity = 35; updateInterval = 250;
|
||||
brushSize = 7; gridMode = GRID_GUIDELINES; mirrorMode = 3;
|
||||
snapLine = false; circleFromCorner = true; pauseOnDraw = false;
|
||||
loopEnabled = true; loopEnd = 12345; showControls = false;
|
||||
tool = TOOL_CIRCLE; selectedStamp = 5; rotation = 3; category = CATEGORY_HELP;
|
||||
windowWidth = 1400; windowHeight = 1000;
|
||||
saveSettingsIfChanged();
|
||||
checkCanonical();
|
||||
long long expected[SETTING_COUNT];
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) expected[i] = settingValue(i);
|
||||
long long defaults[SETTING_COUNT];
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) defaults[i] = settings[i].defaultValue;
|
||||
applySettings(defaults);
|
||||
assert(loadSettings());
|
||||
for (size_t i = 0; i < SETTING_COUNT; ++i) assert(settingValue(i) == expected[i]);
|
||||
struct stat before, after;
|
||||
assert(stat(settingsPath, &before) == 0);
|
||||
saveSettingsIfChanged();
|
||||
assert(stat(settingsPath, &after) == 0 && before.st_ino == after.st_ino);
|
||||
/* Clipboard contents are not persisted, so paste restores to Select. */
|
||||
tool = TOOL_PASTE;
|
||||
saveSettingsIfChanged();
|
||||
assert(loadSettings() && tool == TOOL_SELECT);
|
||||
const char *invalid[] = {
|
||||
"", "{", "null", "[]", "hue=42 extra", "hue=42\nhue=70\n",
|
||||
"hue=\"42\"", "hue=361", "hue=-1", "hue=1.5", "hue=NaN",
|
||||
"hue=999999999999999999999999999999999999",
|
||||
"resolution=26", "start_density=17", "update_interval_ms=0",
|
||||
"pause_on_draw=true", "loop_enabled=2", "loop_end=0", "grid_mode=3",
|
||||
"version=2", "unknown=1", "tool=6", "window_width=0", "rotation=4", "selected_stamp=999",
|
||||
"rainbow_hue=2", "rainbow_speed=0", "rainbow_speed=181"
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(invalid) / sizeof(invalid[0]); ++i) {
|
||||
putFile(invalid[i]);
|
||||
assert(!loadSettings());
|
||||
for (size_t j = 0; j < SETTING_COUNT; ++j) assert(settingValue(j) == defaults[j]);
|
||||
checkCanonical();
|
||||
}
|
||||
putFile("# Preferences\npause_on_draw=0\nhue = 123\n");
|
||||
assert(loadSettings() && hue == 123 && !pauseOnDraw && resolution == 200);
|
||||
assert(!rainbowHue && rainbowSpeed == 30);
|
||||
checkCanonical();
|
||||
FILE *file = fopen(settingsPath, "wb");
|
||||
assert(file);
|
||||
for (int i = 0; i < 10000; ++i) fputc(' ', file);
|
||||
fclose(file);
|
||||
assert(!loadSettings());
|
||||
checkCanonical();
|
||||
file = fopen(settingsPath, "wb");
|
||||
assert(file);
|
||||
const char embedded[] = "{}\0hidden";
|
||||
fwrite(embedded, 1, sizeof(embedded), file);
|
||||
fclose(file);
|
||||
assert(!loadSettings());
|
||||
checkCanonical();
|
||||
/* A failed atomic rename must leave the old destination untouched. */
|
||||
char realPath[PATH_MAX];
|
||||
snprintf(realPath, sizeof(realPath), "%s", settingsPath);
|
||||
snprintf(settingsPath, sizeof(settingsPath), "%s/blocked", directory);
|
||||
assert(mkdir(settingsPath, 0700) == 0);
|
||||
hue = 10;
|
||||
assert(!writeSettings() && settingsError[0]);
|
||||
assert(rmdir(settingsPath) == 0); /* No partial output inside destination. */
|
||||
snprintf(settingsPath, sizeof(settingsPath), "%s", realPath);
|
||||
assert(loadSettings() && hue == 275 && !settingsError[0]);
|
||||
checkCanonical();
|
||||
/* A deliberately stalled disk writer must not stall slider-style updates. */
|
||||
atomic_store(&settingsWriteAttempts, 0);
|
||||
atomic_store(&blockSettingsWrites, true);
|
||||
atomic_store(&settingsWriteEntered, false);
|
||||
startSettingsWriter();
|
||||
assert(settingsWorkerRunning);
|
||||
hue = 100;
|
||||
saveSettingsIfChanged();
|
||||
const struct timespec pause = {0, 1000000L};
|
||||
for (int i = 0; i < 5000 && !atomic_load(&settingsWriteEntered); ++i) nanosleep(&pause, NULL);
|
||||
assert(atomic_load(&settingsWriteEntered));
|
||||
struct timespec started, ended;
|
||||
clock_gettime(CLOCK_MONOTONIC, &started);
|
||||
for (int i = 0; i < 2000; ++i) {
|
||||
hue = i % 361;
|
||||
saveSettingsIfChanged();
|
||||
pollSettingsWriter();
|
||||
}
|
||||
hue = 217;
|
||||
saveSettingsIfChanged();
|
||||
clock_gettime(CLOCK_MONOTONIC, &ended);
|
||||
double elapsed = ended.tv_sec - started.tv_sec + (ended.tv_nsec - started.tv_nsec) / 1e9;
|
||||
assert(elapsed < 0.5);
|
||||
assert(atomic_load(&settingsWriteAttempts) == 1);
|
||||
atomic_store(&blockSettingsWrites, false);
|
||||
stopSettingsWriter();
|
||||
assert(!settingsWorkerRunning && atomic_load(&settingsWriteAttempts) == 2);
|
||||
checkCanonical();
|
||||
assert(loadSettings() && hue == 217);
|
||||
/* Shutdown flushes a change even when the debounce has not expired. */
|
||||
atomic_store(&settingsWriteAttempts, 0);
|
||||
startSettingsWriter();
|
||||
hue = 218;
|
||||
saveSettingsIfChanged();
|
||||
stopSettingsWriter();
|
||||
assert(atomic_load(&settingsWriteAttempts) == 1);
|
||||
checkCanonical();
|
||||
printf("PASS: 2000 updates in %.3f ms while writer blocked; latest value and shutdown flush persisted\n", elapsed * 1000);
|
||||
assert(unlink(settingsPath) == 0);
|
||||
assert(rmdir(directory) == 0); /* No orphaned temporary files. */
|
||||
puts("PASS: settings round trip, defaults, validation, repair, no-op saves, atomic failure cleanup");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* Original 12 x 12 pixel icons. Each row uses its low 12 bits. */
|
||||
#ifndef TOOL_ICONS_H
|
||||
#define TOOL_ICONS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
ICON_NONE = -1,
|
||||
ICON_BRUSH,
|
||||
ICON_ERASER,
|
||||
ICON_LINE,
|
||||
ICON_CIRCLE,
|
||||
ICON_STAMP,
|
||||
ICON_SELECT,
|
||||
ICON_COPY,
|
||||
ICON_PASTE,
|
||||
ICON_UNDO,
|
||||
ICON_ROTATE,
|
||||
ICON_MIRROR_OFF,
|
||||
ICON_MIRROR_H,
|
||||
ICON_MIRROR_V,
|
||||
ICON_MIRROR_BOTH,
|
||||
ICON_GRID,
|
||||
ICON_GUIDES,
|
||||
ICON_GRID_OFF,
|
||||
ICON_SNAP,
|
||||
ICON_CENTER,
|
||||
ICON_CORNER,
|
||||
ICON_PAUSE,
|
||||
ICON_PLAY,
|
||||
ICON_CLEAR,
|
||||
ICON_RESEED,
|
||||
ICON_SAVE,
|
||||
ICON_OPEN,
|
||||
ICON_REVERSE,
|
||||
ICON_STEP,
|
||||
ICON_BACK,
|
||||
ICON_RESTORE,
|
||||
ICON_VIEW,
|
||||
ICON_HELP,
|
||||
ICON_COUNT
|
||||
} ToolIcon;
|
||||
|
||||
static const uint16_t toolIconPixels[ICON_COUNT][12] = {
|
||||
[ICON_BRUSH] = {0x600, 0x700, 0x380, 0x1c0, 0x0e0, 0x070, 0x038, 0x03c, 0x03e, 0x03e, 0x00f, 0x007},
|
||||
[ICON_ERASER] = {0x000, 0x1c0, 0x3e0, 0x630, 0xc18, 0x60c, 0x306, 0x183, 0x0c6, 0x06c, 0x038, 0x7f8},
|
||||
[ICON_LINE] = {0xe00, 0xe00, 0xf00, 0x180, 0x0c0, 0x060, 0x030, 0x018, 0x00c, 0x00f, 0x007, 0x007},
|
||||
[ICON_CIRCLE] = {0x0f0, 0x30c, 0x402, 0x402, 0x801, 0x801, 0x801, 0x801, 0x402, 0x402, 0x30c, 0x0f0},
|
||||
[ICON_STAMP] = {0x0f0, 0x198, 0x198, 0x198, 0x0f0, 0x0f0, 0x3fc, 0x7fe, 0x7fe, 0x000, 0x7fe, 0x7fe},
|
||||
[ICON_SELECT] = {0x777, 0x401, 0x001, 0x400, 0x401, 0x001, 0x400, 0x401, 0x001, 0x400, 0x777, 0x000},
|
||||
[ICON_COPY] = {0x0ff, 0x081, 0x7f9, 0x409, 0x409, 0x409, 0x409, 0x40f, 0x408, 0x408, 0x7f8, 0x000},
|
||||
[ICON_PASTE] = {0x0f0, 0x79e, 0x4f2, 0x402, 0x4f2, 0x402, 0x4f2, 0x402, 0x4f2, 0x402, 0x7fe, 0x000},
|
||||
[ICON_UNDO] = {0x008, 0x00c, 0x1fe, 0x3ff, 0x70e, 0x60c, 0x608, 0x600, 0x700, 0x3e0, 0x1e0, 0x000},
|
||||
[ICON_ROTATE] = {0x1f0, 0x31c, 0x606, 0x402, 0x003, 0x003, 0x203, 0x602, 0xfc6, 0x61c, 0x1f0, 0x000},
|
||||
[ICON_MIRROR_OFF] = {0x020, 0x422, 0x406, 0x62e, 0x71e, 0x7be, 0x7de, 0x78e, 0x726, 0x602, 0x422, 0x020},
|
||||
[ICON_MIRROR_H] = {0x060, 0x060, 0x168, 0x36c, 0x76e, 0xf6f, 0xf6f, 0x76e, 0x36c, 0x168, 0x060, 0x060},
|
||||
[ICON_MIRROR_V] = {0x060, 0x0f0, 0x1f8, 0x3fc, 0x000, 0xfff, 0xfff, 0x000, 0x3fc, 0x1f8, 0x0f0, 0x060},
|
||||
[ICON_MIRROR_BOTH] = {0x060, 0x264, 0x76e, 0x264, 0x060, 0xfff, 0xfff, 0x060, 0x264, 0x76e, 0x264, 0x060},
|
||||
[ICON_GRID] = {0xfff, 0x891, 0x891, 0x891, 0xfff, 0x891, 0x891, 0xfff, 0x891, 0x891, 0x891, 0xfff},
|
||||
[ICON_GUIDES] = {0x060, 0x060, 0x060, 0x060, 0x060, 0xfff, 0xfff, 0x060, 0x060, 0x060, 0x060, 0x060},
|
||||
[ICON_GRID_OFF] = {0xfff, 0x801, 0x801, 0x801, 0x801, 0x801, 0x801, 0x801, 0x801, 0x801, 0x801, 0xfff},
|
||||
[ICON_SNAP] = {0x007, 0x007, 0x007, 0x002, 0x002, 0x002, 0x002, 0x702, 0x7fe, 0x700, 0x000, 0x000},
|
||||
[ICON_CENTER] = {0x060, 0x1f8, 0x264, 0x402, 0x402, 0xe67, 0xe67, 0x402, 0x402, 0x264, 0x1f8, 0x060},
|
||||
[ICON_CORNER] = {0x00f, 0x00f, 0x1ff, 0x20f, 0x404, 0x804, 0x804, 0x804, 0x804, 0x408, 0x210, 0x1e0},
|
||||
[ICON_PAUSE] = {0x000, 0x39c, 0x39c, 0x39c, 0x39c, 0x39c, 0x39c, 0x39c, 0x39c, 0x39c, 0x39c, 0x000},
|
||||
[ICON_PLAY] = {0x004, 0x00c, 0x01c, 0x03c, 0x07c, 0x0fc, 0x0fc, 0x07c, 0x03c, 0x01c, 0x00c, 0x004},
|
||||
[ICON_CLEAR] = {0x0f0, 0x0f0, 0x7fe, 0x000, 0x204, 0x294, 0x294, 0x294, 0x294, 0x294, 0x204, 0x3fc},
|
||||
[ICON_RESEED] = {0x000, 0x7fe, 0x402, 0x41a, 0x41a, 0x462, 0x462, 0x582, 0x582, 0x402, 0x7fe, 0x000},
|
||||
[ICON_SAVE] = {0x7ff, 0xdf9, 0xd09, 0xdf9, 0xc01, 0xdf9, 0xd09, 0xd09, 0xd09, 0xdf9, 0xfff, 0x000},
|
||||
[ICON_OPEN] = {0x000, 0x01f, 0x3f1, 0x201, 0xffd, 0x805, 0x805, 0x805, 0x805, 0x807, 0xffc, 0x000},
|
||||
[ICON_REVERSE] = {0x200, 0x300, 0x380, 0x3c0, 0x3e0, 0x3f0, 0x3f0, 0x3e0, 0x3c0, 0x380, 0x300, 0x200},
|
||||
[ICON_STEP] = {0x604, 0x60c, 0x61c, 0x63c, 0x67c, 0x6fc, 0x6fc, 0x67c, 0x63c, 0x61c, 0x60c, 0x604},
|
||||
[ICON_BACK] = {0x206, 0x306, 0x386, 0x3c6, 0x3e6, 0x3f6, 0x3f6, 0x3e6, 0x3c6, 0x386, 0x306, 0x206},
|
||||
[ICON_RESTORE] = {0x000, 0x40c, 0x60c, 0x70c, 0x78c, 0x7cc, 0x7cc, 0x78c, 0x70c, 0x60c, 0x40c, 0x000},
|
||||
[ICON_VIEW] = {0x000, 0x000, 0x0f0, 0x30c, 0x462, 0x861, 0x861, 0x462, 0x30c, 0x0f0, 0x000, 0x000},
|
||||
[ICON_HELP] = {0x1f8, 0x30c, 0x606, 0x600, 0x300, 0x180, 0x0c0, 0x060, 0x060, 0x000, 0x060, 0x060},
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user