Conway’s Game Of Life

      No Comments on Conway’s Game Of Life

What Is Conway’s Game Of Life

Conway’s game of life is a zero players game. It is played on a rectangular grid where each box is know as cell. A Cell can be alive or dead depending on its neighbours or initial configuration of the grid. It only needs an initial configuration and then the cells on the grid evolves on their own.


Rules Of Conway’s Game Of Life

Conway’s game of life has only 4 rule:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  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, as if by over-population.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.


I have implemented this game in JavaScript, Html and Css. The code is available on github. To implement this game you will need below things.

  1. Create a grid which will represent your cells.
  2. A Cell can be dead or alive. So have two css classes, one for alive and one for dead.
  3. Figure out neighbours of a cell.
  4. Apply above rules and figure out if the cell will be alive or dead for the next generation.
  5. Store the cells which needs to be moved to next generation.
  6. Store the cells which will not survive or will die in next generation.
  7. Iterate over the list of cells moving to next generation, and mark them as alive by adding alive css class to them
  8. Iterate over the list of cells which will die in next generation and mark them as dead by adding dead css class to them.
  9. Run the steps from 3-8 all over again after a small time interval.

Source Code

Thats all folks, enjoy the game 🙂

About Ajit Singh

Hi, I am Ajit Singh, author of I work on a lot of different technologies and tools. I started my career as a software engineer in Chennai (India) and recently I moved to Gurgaon near to my home town. I like reading and writing about technology.

Leave a Reply

Your email address will not be published. Required fields are marked *