Conway's Game of Life
an out of date implementation
Controls
click on cells to mark them as alive/dead
I don't know how old this implementation actually is. But I believe I wrote it some 10+ years ago as a challenge for myself. (There are adaptaions which are from last/this year as you might see in the different variable declarations [var/let])
At the time I was really proud of it, nowadays I'd probably approach it differently. Using the <canvas>element
instead of appending a field of <span> elements directly to the DOM for example.
This implementation uses a toroidal field instead of using dead cells at the borders.
For me that comes, philosophicly, closest to an infinity/the infinite field Conway himself assumed.
There are other conceivable solutions, the best/most correct one I found is from David K. on Stackechange:
Unlike the decimal expansion of π
, the board after a finite number of moves has only a finite number of elements. If you really want to "do it right", it is possible to design the data structures and algorithms such that when cells need to be created "off the edge" the data structure extends to fit them. Of course, eventually, if you have too many occupied cells you'll run out of memory. But I have a hunch you'll decide the program has run long enough before that happens. –
David K