GithubHelp home page GithubHelp logo

dubliyu / game_of_life_terminal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evankozliner/game_of_life_terminal

0.0 0.0 0.0 8 KB

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

Python 100.00%

game_of_life_terminal's Introduction

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
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-----**-----**--------------------------------------------------------------------------------------
------**---**---------------------------------------------------------------------------------------
---*--*-*-*-*--*------------------------------------------------------------------------------------
---***-**-**-***------------------------------------------------------------------------------------
----*-*-*-*-*-*-------------------------------------------------------------------------------------
-----***---***--------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-----***---***--------------------------------------------------------------------------------------
----*-*-*-*-*-*-------------------------------------------------------------------------------------
---***-**-**-***------------------------------------------------------------------------------------
---*--*-*-*-*--*------------------------------------------------------------------------------------
------**---**---------------------------------------------------------------------------------------
-----**-----**--------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
---------------------------*------------------------------------------------------------------------
----------------------------*-----------------------------------------------------------------------
--------------------------***-----------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------

game_of_life_terminal's People

Contributors

evankozliner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.