DEV Community

Cover image for Conway's Game Of Life
prajyu
prajyu

Posted on

Conway's Game Of Life

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970

Wikipedia

Basically it runs on just two rules :-

  • Cell with less than two or more than three neighbours dies

  • Cell with two or three neighbours survives to next generation

Here's a neat working Life

! Made this just for small screens.

If the page is not working try cloning the repo and running it locally GITHUB

Top comments (3)

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

Doesn't work at all - numerous JS errors

Collapse
 
prajyu profile image
prajyu

I'm sorry to hear that, will be fixing the issues.
I made this for mobile phones not desktop users. Have you tried cloning the repository and running it locally.

Collapse
 
decker67 profile image
decker • Edited

That should be almost the same. A quick look into the debugger shows that you create an array with a decimal value rows:

let create2DArray = (rows,cols) =>{
        let ret = []
        for(let i=0;i<cols;i++){
          for(let j=0;j<rows;j++){
            ret[i] = new Array(rows).fill(0)
          }
        }
        return ret
      }
Enter fullscreen mode Exit fullscreen mode