optimized 1dlife

This commit is contained in:
Luxferre
2026-05-29 08:33:23 +03:00
parent 235e330fb4
commit 3e1a133471
+3 -3
View File
@@ -18,15 +18,15 @@ state="${state//[^0]/1}"
slen=$((${#state} - 1)) # length + 4 (temporary padding) - 5
# complete rule mapping
declare -ar values=(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)
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<ITERS; ++i)); do
state="00${state}00" # pad the current state from both sides
newstate=''
for ((k=0; k<slen; ++k)); do
vidx="${state:k:5}"
newstate="${newstate}${values[$((2#$vidx))]}"
newstate="${newstate}${rule[$((2#$vidx))]}"
done
state="$newstate"
newstate="${newstate//0/ }"