Tom Taylor - Software Engineer

Game Of Life

Game Of Life

A recreation of Conway's Game of Life written in Object Pascal for the Delphi VCL. This was one of my early Delphi projects, created to deepen my understanding of the language and its capabilities after starting work at a primarily Delphi focused company.

Technologies used

  • Language: Object Pascal / Dephi
  • Framework & Development Tools: Delphi VCL (Written for Delphi 7 but forward compatible.)
  • Version Control: Github

Conway's Game Of Life Rules

Conway's Game of Life is a zero-player game that uses the following rules:

  • Live cell with fewer than two neighbours dies (underpopulation).
  • Live cell with two or three neighbours survives.
  • Live cell with more than three neighbours dies (overpopulation).
  • Dead cell with exactly three neighbours becomes a live cell (reproduction).

This implementation of the game wraps the edges of the board round on each other, making the play room infinite. Because of this, patterns like 'shooters' and 'gliders' are capable of potentially running infinitely and forever.

Patterns

Even though the rules of the simulation are simple, the patterns that can emerge from the game are complex and fascinating.

The 'Gosper Glider' is a type of pattern that, if the board is unbounded, will walk in this pattern indefinitely:

Gosper Glider

It gets interesting when you use another pattern, the 'Gosper Gun', which produces a stream of the above gliders... Again, indefinitely!

Gosper Gun

A final example I'd like to show is the 'Exploder.' This incredibly simple pattern at it's first generation, simply a line of cells, when started will explode out into a beautiful and complex pattern, eventually always dying out after it's 49th generation.

Exploder Pattern

I am fascinated by the concept of complexity through simplicity, and nothing more exemplifies that more than Conway's Game of Life.

Techniques applied

  • Object oriented principles: Applied strong object-oriented principles in Object Pascal to keep code maintainable.
  • Memory management: Ensured robust memory management in low-level graphics code to prevent leaks.
  • Backwards compatibility: Maintained backward compatibility with legacy Delphi versions (Delphi 7+), and by extension old Windows versions such as XP.
  • Strong algorithmic design: Uses strong and well optimised algorithms to ensure a perfectly deterministic simulation, matching the original specification.
  • Complex pixel by pixel rendering: Implemented custom rendering routines for pixel-perfect simulation without a game engine directly into a Windows forms canvas.
  • Custom options: Import/export features for pattern sharing and board configuration, allowing users to save and load their own patterns.

See for yourself

The code for this project is available on Github, linked at the top of the page, and it would be great for you to download for yourself and give it a go!

On the Github releases page, I have Windows excecutables available on there to immediately download, but it can also be compiled from source using Delphi.