Glider triplet collision tiling generator

For scripts to aid with computation or simulation in cellular automata.
Post Reply
Naszvadi
Posts: 1250
Joined: May 7th, 2016, 8:53 am
Contact:

Glider triplet collision tiling generator

Post by Naszvadi » December 14th, 2016, 7:32 am

It was hard to find an appropriate glider collision for this:

So created a bash script, which was useful for searching a high period gun in B36/S237[8] rules.

Code: Select all

#!/bin/bash
# AUTHOR: NASZVADI P., 2016, no commercial use, no violation of author's country's law
set -u
genstream() {
    # arguments
    local Repeat="$1"
    local PeriodX="$2"
    local PeriodY="$PeriodX"
    local Lx="$3"
    local Ly="$4"
    local Gtype="${5:-g3p1}"
    local i
    # selecting glider direction
    case "${Gtype:1:1}" in
        1)
            Ly=$((Ly-3))
            PeriodY="-$PeriodY"
        ;;
        3)
            Lx=$((Lx-3))
            Ly=$((Ly-3))
            PeriodX="-$PeriodX"
            PeriodY="-$PeriodY"
        ;;
        7)
        ;;
        9)
            Lx=$((Lx-3))
            PeriodX="-$PeriodX"
        ;;
        *) echo 'ERROR'
        ;;
    esac
    for ((i=0;i<Repeat;++i)); do
        echo "#P $((Lx+(i*PeriodX))) $((Ly+(i*PeriodY)))"
        eval 'echo -e "$'"${Gtype}"'"'
    done
}
g1p1='.*\n*\n***'
g1p2='*.*\n**\n.*'
g1p3='*\n*.*\n**'
g1p4='..*\n**\n.**'
g3p1='..*\n*.*\n.**'
g3p2='*\n.**\n**'
g3p3='.*\n..*\n***'
g3p4='*.*\n.**\n.*'
g7p1='**\n*.*\n*'
g7p2='.**\n**\n..*'
g7p3='***\n*\n.*'
g7p4='.*\n**\n*.*'
g9p1='***\n..*\n.*'
g9p2='.*\n.**\n*.*'
g9p3='.**\n*.*\n..*'
g9p4='**\n.**\n*'
cat <<END
#Life 1.05
#R 237/36
END
#P 0 0
#"P"ERIOD = 24/"glider period"
P=6
#"R"repeat times
R=12
# Gap aligned to 10n
GAP=$(( (((2*(4+P)*R)+9)/10)*10 ))
MAINX=0
MAINY=0
for ALL in {-4..0}_{0..4}x{0..4}_{-4..0}; do
    ARR=( $(echo $ALL | sed 's/ *[^ ]*x\(0_-*[0-2]\|[0-2]_0\) *\| *\(-[0-2]_0\|0_[0-2]\)x[^ ]* */ /g;y/x_/  /' ) )
    if [[ ${#ARR[@]} = 4 ]]; then
        for g9 in 1 2 3 4; do for g1 in 1 2 3 4; do
        genstream "$R" "$P" "$MAINX" "$MAINY"
        genstream "$R" "$P" "$((MAINX+ARR[0]))" "$((MAINY+ARR[1]))" g9p"$g9"
        genstream "$R" "$P" "$((MAINX+ARR[2]))" "$((MAINY+ARR[3]))" g1p"$g1"
        MAINX=$((MAINX+GAP))
        done; done
    fi
done
TODO: short explanation of (nonexistent) parameters, allow setting values of hardcoded parameters from CLI args...

User avatar
BlinkerSpawn
Posts: 1992
Joined: November 8th, 2014, 8:48 pm
Location: Getting a snacker from R-Bee's

Re: Glider triplet collision tiling generator

Post by BlinkerSpawn » December 14th, 2016, 11:31 am

Would you mind explaining precisely what this script is intended to do?
Is it just supposed to create a table of 3-glider collisions?
LifeWiki: Like Wikipedia but with more spaceships. [citation needed]

Image

Naszvadi
Posts: 1250
Joined: May 7th, 2016, 8:53 am
Contact:

Re: Glider triplet collision tiling generator

Post by Naszvadi » December 14th, 2016, 2:30 pm

BlinkerSpawn wrote:Would you mind explaining precisely what this script is intended to do?
Is it just supposed to create a table of 3-glider collisions?
Yes, into one huge pattern that is printed to standard output. It merges some 3-glider row collisions, where gliders are equidistant (24 generations are between two followings) if they came out from a barrel.

I wonder about some kind of automation: if it could be combined with a (not implemented) script that executes a goto.py and a glider detection+reporting on a certain part of the pattern's convex hull. Related: I am working now on a golly script which removes gliders on the border in all IRrelevant directions (where collisions are impossible).

Basically, after running ~96 generations, checked the resulting pattern manually. And profit, world domination.

Post Reply