Giter VIP home page Giter VIP logo

conways-game-of-life's Introduction

... is a cellular automaton devised by Mathematician John Conway. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input.

image

Rules

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, (in this project a 60 x 80 grid of square cells) each of which is in one of two possible states, live (1) or dead (0) (or populated and unpopulated, respectively). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time (or simply generation) , the following transitions occur:

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

Implementation in Python

For the game's implementation we have made use of the pygame and numpy modules.

The update() method takes an array of cells (60 x 80 in size), and returns an array of cells of the corresponding next generation, after applying the above mentioned rules.

main()

As the program begins, it is paused, i.e. by click-dragging your mouse over the square cells, you can make them alive. As soon as SPACEBAR is pressed, it resumes and the generations begin to change.

game_of_life_demo.mp4

Example gameplay


Big thanks to Neural Nine! Was really helpful in Understanding the game mechanics and efficient implementation

conways-game-of-life's People

Contributors

ternion-1121 avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

lakshya-chauhan

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.