I made this a few years ago already while being bored.
It's Conways Game of Life, written in awk.
There's a seed generator
genlife.shand the actual game renderer
life.sh
## genlife.sh -- Jun 25 2010, by Patsie # generates random data for a first generation of Life # usage: genlife.sh [<width> [<height> [<fill percentage>] ] ] # defaults to a grid of 15x10 with 25% filling
Like the comment in the seed generator says, it accepts up to 3 parameters. A width, a height and a fill percentage
Since the game renderer has an extra statusbar line at the top and you need a free line at the bottom, you could generate a seed as big as your terminal like:
./genlife.sh $COLUMNS $((LINES-2))
## life.sh -- Jun 25 2010, by Patsie # awk implementation of the Game of Life. A simple automata # Usage: life.sh [<nr of runs> [<sleep interval>] ]
The game renderer takes a seed from stdin and runs it for a specified amount of frames/runs with a small 'sleep' interval in between each frame/run.
You can also specify these as arguments. To run for 100 frames with a 0.1 second sleep interval:
./life 100 0.1
Now lets combine the two to get something which actually produces some output:
./genlife.sh | ./life.shor
./genlife.sh $COLUMNS $((LINES-2)) | ./life.sh 100 0.1