Git Product home page Git Product logo

conway-s-game-of-life's Introduction

John Conway's game of life

Java based program for visualizing of John Conway's game of life. The program use Queue amnd multidimensional arrays for storing game datas. The program allows user to generate a random grid of cells or an empty grid of cell so users can edit each cell values later.

About the game of life

According to Wikipedia

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves. It is Turing complete and can simulate a universal constructor or any other Turing machine.

The game of life is unpredictable, with each new state is determined by the previous state based on a specific set of rules.

Rules

The rules are applied to every cells and its neighbors. Every cells will interact with eight neighbouring cells. A cell has two state, dead and alive.

  1. Any live cell with fewer than two live neighbours dies due to underpopulation.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies due to overpopulation.
  4. Any dead cell with exactly three live neighbours becomes a live cell from reproduction.

Usage

  1. Git clone the repo to your local folder and cd into Conway-s-game-of-life
  2. compiled all java files using the following terminal command
javac *.java
  1. than run LandscapeDisplay.java
java LandscapeDisplay
  1. The terminal will ask for your inputs for the game, go ahead and enter number of rows and columns you want for your simulation landscape

  2. After putting in the dimension, u will have two option.

    • Creating a blank landscape: for this option, the program will repeatedly ask you the coordinates and status you want to set for the cell. To finish setting up, press enter without writing anything.

    • Creating a landscape with randomly generated Cells with random state of alive and dead based on user-defined probability

  3. Enjoy watching the evolution of cells

The game will end when the program detect that the simulation has become a loop

By default, the simulation will output a file into the img folder with each frame of a run, you can turn that off by passing false as a parameter instead of true in line 138 of LandscapeDisplay.java

life.runSimulation(false);

conway-s-game-of-life's People

Contributors

minhphd avatar

Watchers

 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.