I've been working the last few days to create a simple application of John Conway's Game of Life. It's a game (of sorts) run by a simple set of rules.
The first thing to note... each cell has 8 neighbors. (1)above, (2)below, (3)left, (4)right, (5)upper-left corner, (6)lower-left corner, (7)upper-right corner and (8)lower-right corner.
Each cell's neighbors determine it's existence, demise, or re-birth.
The game rules are:
- A live cell with fewer than two live neighbors dies.
- A live cell with more than three live neighbors dies.
- A live cell with two or three live neighbors lives, to the next generation.
- A dead cell with exactly three live neighbors will come back to life.
This project got me thinking about my apartment building. There are exactly 8 apartments in this building. It's a big cube with 4 residences on the first floor and 4 on the second, with the common entrance/stairway/foyer in the center. In pre-COVID times, people would come and go all day long. (live = occupied apartments, dead = empty apartments) If these rules were applied to our building there would be many variations throughout the day. It would be fascinating to simulate The Game of Life on the comings and goings of my neighbors, but I have a feeling they might find it strange if I sat by the door and monitored each time they entered or exited the building.
The project was really enjoyable to create. I began with a great tutorial from freeCodeCamp.org (https://www.youtube.com/watch?v=PM0_Er3SvFQ) and then I added some additional React components. It's simple and nothing fancy, but it's still pretty neat to see those cells dance delightfully across the grid.
https://cs-build-week-1.leesahmasko.vercel.app/
Feel free to check it out, create a random pattern by clicking cells to set them as alive, (or choose the seed button) hit play and watch what happens! (Also, I apologize that it isn't very mobile friendly. The grid is happiest on desktop view)
While doing this project I had the privilege to learn more about the creator John Conway and I found him to be quite a fascinating character. Sadly, he recently died from complications due to COVID-19. It's rather somber to think as I worked through this project, still adhering to the shelter-in-place order, that I am doing my small part to help prevent the spread of the virus that took his life.
Cheers to John Conway! A life well lived, surrounded by numbers. May we all find ways to follow our passions and leave a legacy for others.
Top comments (0)