Skip to content

Conway's Game of Life, but it plays in the terminal with no external dependencies like numpy.

Notifications You must be signed in to change notification settings

evankozliner/game_of_life_terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of life, but in the terminal

I've seen a lot of GoL simulations online, but I wanted one where you could choose the placement of your patterns/creatures on the grid, and I wanted it to run in the terminal. Also, I saw almost all of the ones online run numpy, which can be a pain for beginners to install and understand. So I wrote this guy.

Notes

  • Not really high-quality. Feel free to put up a PR to clean things up. The bulk of the logic was written one morning
  • Accompanies a blog post that I'm still writing.
  • Complimentary elementary CA printer here: https://github.com/evankozliner/elementary-CAs

Requirements

  • python3
  • No other dependencies!

WIP. Things work, but needs features

Conway's Game of Life https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
usage: Main.py [-h] [-e EVOLUTIONS] [-t TICK_RATE] [-w WIDTH] [-r ROWS]
               [--glider] [-p PLACEMENT_FILE]

Runs Conway's game of life in the terminal.

optional arguments:
  -h, --help            show this help message and exit
  -e EVOLUTIONS, --evolutions EVOLUTIONS
                        The number of steps to run the game of life for.
  -t TICK_RATE, --tick_rate TICK_RATE
                        The time between ticks in game (in seconds, default
                        0.3). Try something like 0.05 to watch the game evolve
                        faster.
  -w WIDTH, --width WIDTH
                        The width (number of columns) of the game.
  -r ROWS, --rows ROWS  The height (number of rows) of the game.
  --glider              Adds a simple glider to the game to give you an idea
                        of what patterns are like.
  -p PLACEMENT_FILE, --placement_file PLACEMENT_FILE
                        The location of the placement file. You can use these
                        to place patterns into the game. Be sure the patterns
                        fall within the allocated width/rows

TODO

  • Refactor into files
  • More oscillators, unbounded growths, etc
  • Custom placement
  • Option for saving to a gif

Bugs

  • Pressing enter will print more rows that don't do anything

Examples

A simple glider

$ python3 Main.py -e 10 -t .05 -r 10 -w 25 -p placement_files/glider.csv 
Conway's Game of Life https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
-------------------------
-------------------------
-------------------------
-------------------------
---*-*-------------------
----**-------------------
----*--------------------
-------------------------
-------------------------
-------------------------

Unbounded growth

$ python3 Main.py -e 500 -t .05 -r 50 -w 100 -p placement_files/grower.csv 
Conway's Game of Life https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-------------*----*---------------------------------------------------------------------------------
------------*-*--**---------------------------------------------------------------------------------
-------------*---*-*--------------------------------------------------------------------------------
------------------***-------------------------------------------------------------------------------
-------------*-----**-------------------------------------------------------------------------------
------------**--------------------------------------------------------------------------------------
----------**--*-------------------------------------------------------------------------------------
----------*---*-****--------------------------------------------------------------------------------
--------------------*-------------------------------------------------------------------------------
--------*-**-------*--------------------------------------------------------------------------------
------**-*-********---------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-----------*----------------------------------------------------------------------------------------
-------*--*-----------------------------------------------------------------------------------------
--------*-------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-------**-------------------------------------------------------------------------------------------
------*--*------------------------------------------------------------------------------------------
-------**-------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

A pulsar with a glider

$ python3 Main.py -e 5 -t .05 -r 50 -w 100 -p placement_files/pulsar-and-glider.csv 
Conway's Game of Life https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-----**-----**--------------------------------------------------------------------------------------
------**---**---------------------------------------------------------------------------------------
---*--*-*-*-*--*------------------------------------------------------------------------------------
---***-**-**-***------------------------------------------------------------------------------------
----*-*-*-*-*-*-------------------------------------------------------------------------------------
-----***---***--------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-----***---***--------------------------------------------------------------------------------------
----*-*-*-*-*-*-------------------------------------------------------------------------------------
---***-**-**-***------------------------------------------------------------------------------------
---*--*-*-*-*--*------------------------------------------------------------------------------------
------**---**---------------------------------------------------------------------------------------
-----**-----**--------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
---------------------------*------------------------------------------------------------------------
----------------------------*-----------------------------------------------------------------------
--------------------------***-----------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

About

Conway's Game of Life, but it plays in the terminal with no external dependencies like numpy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages