Categories
Code

Game of Life in JavaScript

I recently had a period of time away from work to take care of my daughter at home. Of course, she would keep me busy most of the time, but being a computer enthusiast, I couldn’t resist a small side project to tinker with when otherwise idle.

My job mostly involves backend programming and architecture, so the obvious choice would be to do something entirely different. Also, the project needed to be small and manageable in size, so I could actually finish it. (My hobby computer projects tend to never truly end, but that’s another story.) There was little chance of getting any “zone time” programming done, since taking care of a small child demands much attention. So I decided to do an experiment with the HTML5 canvas element (specifically its 2D variant) and the JavaScript language. Both are rather easy to get into and easy to pick up whenever some time is available.

My canvas experiment is a “Game of Life” simulator-emulator-engine-thingy. Since the game of life is highly artificial with little resemblance to real life, it isn’t really simulating anything. Perhaps it’s emulating life at a “megascopic” scale of some sorts. At its core, it’s a game engine that draws cells, dead or alive, that evolve according to a set of simple rules. The frontend (page layout, input and controls) are separated. Code is JavaScript, of course. Should work across major modern browsers and mobile devices, though I haven’t really optimized it for touch input. It comes with a few interesting initial cell patterns and themes.

Anyway, here it is: Game of Life version 1-beta page. I doubt I’ll get much time to work with it in the coming months, but I plan to put it in my Github repo.

I’ll likely do a follow-up post later with some of my thoughts on the JavaScript language before and now, and standardization across browser implementations.