Home

Awesome

Conway's Game of Life Implementations

DOI

This Repository contains multiple implementations of Conway's Game of Life, each written in different programming languages. Each implementation follows the same basic logic for simulating the cellular automaton but demonstrates how different languages can approach the problem.

Files

Logic

Each file contains the necessary logic to run a basic Game of Life simulation. The grid is a 2D array of cells, which are either "alive" or "dead." The simulation follows these rules for cell evolution:

  1. Any live cell with two or three live neighbors survives.
  2. Any dead cell with exactly three live neighbors becomes a live cell.
  3. All other live cells die in the next generation, and all other dead cells stay dead.

Running Each Script

To run each script, ensure the necessary runtime or interpreter for the specific language is installed on your system. Each script can be executed directly from the terminal as they contain the necessary shebang line to specify the interpreter. Below are the commands to run the scripts in your terminal:

Languagerun withor
C./cgol.c
Dart./cgol.dartdart cgol.dart
Go./cgol.gogo run cgol.go
Java./cgol.javajavac cgol.java && java cgol; rm cgol.class; exit
JavaScript (Node.js)./cgol.jsnode cgol.js
PHP./cgol.phpphp cgol.php
Lua./cgol.lualua cgol.lua
Perl./cgol.plperl cgol.pl
Python./cgol.pypython3 cgol.py
R./cgol.RRscript cgol.R
Ruby./cgol.rbruby cgol.rb
Rust./cgol.rscargo script cgol.rs
Shell/Bash./cgol.shsh cgol.sh
Swift./cgol.swiftswift cgol.swift

if you encounter any permission issues, you may need to make the script executable by running chmod +x <script_name> before executing the script.

i only tested on macOS, but it should work on any Unix-based system. If not, you are invited to contribute to the repository.

Features

Contribution

Feel free to add more implementations or improve the existing ones.