Giter Site home page Giter Site logo

lelserslasers / gameoflife Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 684.22 MB

Game of Life (2d cellular automata described by John Conway) in C, C++, Javascript, Python, Rust (plain Rust and with GGEZ), and Java (plain Java and with libgdx)

Python 0.05% C 0.53% C++ 0.06% Java 0.23% JavaScript 0.05% Rust 47.73% Makefile 46.62% LLVM 4.74%
2d c cellular-automata cli cpp gameoflife gui java javascript python rust simulation

gameoflife's Introduction

Game of Life (John Conway)

https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

Normal View

My attempt to write John Conway's Game of Life in various programming languages:

  • C
  • C++
  • Java
  • Javascript
  • Python
  • Rust
  • The 'libgdx' and 'ggez' are the featured/main/primary/best versions
    • They are graphical apps (rather than a terminal one)
    • The 'libgdx' version is written in Java using the libgdx framework based on OpenGL (ES)
    • The 'ggez' version is written in Rust using the ggez framework based on LÖVE
    • See the READMEs in their respective folders for more information

Cell Rules:

Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  • Any live cell with fewer than two live neighbours dies, as if by underpopulation.
  • Any live cell with two or three live neighbours lives on to the next generation.
  • Any live cell with more than three live neighbours dies, as if by overpopulation.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

These rules, which compare the behavior of the automaton to real life, can be condensed into the following:

  • Any live cell with two or three live neighbours survives.
  • Any dead cell with three live neighbours becomes a live cell.
  • All other live cells die in the next generation. Similarly, all other dead cells stay dead.

Basic game info:

  • Game board is 45x27, the '@'s are alive cells
  • There is no way to exit the terminal apps without control+c

To Run:

  • DISCLAIMER: All of these were built in Windows 10 and work fine on my computer
    • All frameworks used are crossplatform so you should just need to built for your OS
      • Note: The main issue is problemly the screen "clearing" inbetween frames for the terminal apps
      • Note: In some of the terminal apps (Java, etc) the screen clearing does not work in the Windows Commmand Prompt
  • I THINK the C/C++ should just work (just run the EXE)
    • Or compile for your computer and run
  • Also I THINK the java should just work ('java GameOfLife')
  • The Javascript should be run with 'node gameOfLife.js'
  • The Python can just be run with 'python gameOfLife.py'
  • The Rust EXE (in Rust\game_of_life\target\release) should just work
    • If not, it can be run/build with 'cargo run -r'/'cargo build -r'
      • The '-r' is for '--release' meaning it is better optimized

gameoflife's People

Contributors

lelserslasers avatar lord-lelsers avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.