Skip to content

Conway's Game of Life terminal-saver script (curses + scipy.convolve2d)

License

Notifications You must be signed in to change notification settings

matomatical/life

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Life

Terminal-saver script inspired by unimatrix (but neither as flexible nor as pretty).

Implements Conway's Game of Life using python's curses and scipy's 2d convolution operation.

Configuration atop the script.

What have convolutions got to do with Life?

Convolutions are magical! The 2d convolution of the state array with the simple filter [[1 1 1] [1 0 1] [1 1 1]] counts, for all cells, the number of adjacent 'on' cells. This is exactly the kind of count we need!

The state update rule for Life is then succinctly implemented as follows:

c = convolve2d(a, [[1,1,1],[1,0,1],[1,1,1]], mode='same', boundary='wrap')
a = (a & (c == 2)) | (c == 3)

Animation of life in Magenta

TODO

  • Add multiple colours for newborn, stable, and recently dead cells.
  • Try fitting many more cells on the screen by using Braille glyphs.

Made with 💜 by Matt

About

Conway's Game of Life terminal-saver script (curses + scipy.convolve2d)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages