Git Product home page Git Product logo

conways-game-of-life's Introduction

Conway's Game of Life

This is a simulation coded in Python of the cellular automaton model created by John H Conway.

image

Usage

Get Started

  1. Download this repo and store it in your computer.
  2. Open Powershell and go to the folder's root directory where the repo was stored.
  3. Install needed dependencies by typing:
$: pip install numpy
$: pip install matplotlib
  1. In order to run the simulation with Example 1, now type:
$: python conway.py -s 80 -g 200 -i config.dat

This will make a Conway Simulation with grid size 80x80 and run 200 generations, with the initial configuration defined in the file config.dat, which is in the same folder as the conway.py script.

  1. At the end of the simulation, you will see the text file report.txt with all the reported Life beings that were tracked throughout every moment in time during the simulation, as well as their percentage of appearance at the bottom of the document.

Further Runs

$: python conway.py -s <size_number> -g <number_of_generations> -i <init_file>

With <size_number> and <number_of_generations> as integer number parameters, and <init_file> as the file name of the initial configuration input file.

Run Example 1

This is the coolest interesting example I found on the web to debug and test. This is the example you run on step 4.

$: python conway.py -s 80 -g 200 -i config.dat

This example is on the root folder so you don't need to move any file from the repo as it is.

To run the following examples, go to folder other-configs and move the .dat file you want to test to the root folder, then you can type the commands below.

The folder contains the corresponding output report to each configuration if you want to check them.

Run Example 2

This is another interesting example I found on the web.

$: python conway.py -s 80 -g 200 -i config2.dat

Run Example 3

Small example. Debugs how the pogram works with Others category and Rotation of seeds.

$: python conway.py -s 40 -g 20 -i config3.dat

Run Example 4

Another quite interesting example of a glider gun.

$: python conway.py -s 42 -g 200 -i config4.dat

Run Example 5

Small example. Another quite interesting example to check gliders and oscilators.

$: python conway.py -s 20 -g 60 -i config5.dat

Specifications

Language: Python 3.8.1

Input

  • The simulation always takes as input file the config.dat file, which defines the initial configuration of the simulation.
  • This config.dat file was written through an auxiliar script called write-config-test.py, that writes every 'alive' cell as j i grid coordinates on a single line each, where j (x) and i (y) are separated by spaces. If you have a i j format file it's ok, your example will only be rotated 90°.
  • Optional: You can create your own initial config by changing the choice list inside the write-config-test.py script. Then, open Powershell and type:
$: python write-config-test.py

Or you can write the file manually following the format.

Output

  • After running the simulation, the program writes an output file called report.txt.The file report.txt contains:
    • All the number of Life beings detected during each generation by their category.
    • Beings out of the Life patterns are detected during each generation and counted under 'Others' category.
    • The percentage of appearance throughout the simulation. Logically, this percentage is computed after all generations are counted, and therefore can be found at the end of the file.

Important: the report file reaches information until the N-1 frame, where N is the input number given in -s argument.

Special Features

This simulation reports at every generation how many Life seed patterns are found by its category, and also other entities are counted as 'Others'. At the end of the simulation, a report with such information can be found.

Seeds are defined following Conway's standards, but the program also generates all their possible rotations and transposed positions, so that the report identifies rotated seeds as well.

For example, the following configuration will be identified by the program as two beehives, even though one is rotated.

image

Handy Links

Initial Configuration Example

conways-game-of-life's People

Contributors

the-other-mariana 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.