Introduction
Conway's Game of Life is an example of cellural automation. It was created by British mathematican John Horton Conway in 1970, and according to wikipedia it is "best-known example of cellurar automation".
For some reason Conway's invention was always fascinating me. As a big fan of computer games myself, it was quite interesting to find out there is a game that involves no players! Because this is exactly what the Game of Life is - a unique kind of game that plays itself based only on its initial state.
Rules
Conway's Game of Life is a matrix of cells. Cell can be in active state (marked later as: ) or in inactive state (marked as: ). Every iteration (game loop step) is checking how many active neighbours particular cell has, and based on the number of neighbours it either activate or deactive itself. The rules are:
- Any live cell with less than 2 live neighbours dies, as if caused by underpopulation.
- Any live cell with more than 3 live neighbours dies, as if by overcrowding.
- Any live cell with 2 or 3 live neighbours lives on to the next generation.
- Any dead cell with exactly 3 live neighbours becomes a live cell.
My implementation
When I decided to write my own version of The Game, I knew I will do it in JavaScript. And yes, I know JavaScript is probably the last programming language we should consider for this task because it offers poor performance, especially when dealing with complex, multiple callculations but what the hell. Let's do it for for the sake of it.
Below is ready output from my script and few demos so you can preview it in action.
I also added recording option, so if you want to test your own input use the Record button.
TBC.
Post new comment