#!/usr/bin/env bash # Jon Millen's 1D Game of Life in pure Bash (zero dependencies) # Usage: echo 'state' | 1dlife [iterations] # Created by Luxferre in 2026, released into public domain ITERS="$1" if [[ -z "$ITERS" ]]; then # get the iteration count dynamically shopt -s checkwinsize # enable checking the terminal size :|: # trigger the WINCH signal to get the size ITERS=$((LINES - 1)) # the row count is now in LINES fi [[ -z "$RENDER_CHAR" ]] && RENDER_CHAR='#' # read and process the state IFS= read -r state state="${state//[[:space:]]/0}" state="${state//[^0]/1}" slen=$((${#state} - 1)) # length + 4 (temporary padding) - 5 # complete rule mapping declare -ar rule=(0 0 0 1 0 0 0 1 0 1 1 1 0 1 1 0 \ 0 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1) for ((i=0; i