QueTwo's Blog

thouoghts on telecommunications, programming, education and technology

Conway’s Game of Life in Flex

,,,,

So, over the past few months, I’ve collected a rather large set of examples that I have used in various classes, presentations and how-tos.  They’ve been sitting on my hard drive, rotting for the most part, so I’ve decided to post them on my blog. 

All the examples that I will be posting over the next few weeks (as I get time to clean them up and make them pretty) have the "Right-Click -> View Source" enabled. I encourage you to download the samples and play with them.  I’ve opened up the licensing on them so you can pretty much whatever you want with them (although, if I see my name in a book, or credit in a cool applicaiton, I might giggle like a school girl) 🙂

The first example I’m posting is a "Life Simulator".  It’s not as cool as it sounds, but it is based on the 1970’s works of the British mathematician John Horton Conway. His game (the Game of Life) is one of the best-known examples of cellular automation. 

Conway's Game of Life -- Click to Play

It is also considered a "zero player" game. You set up the seed of the game (by hitting Randomize), and then watch it go (watching it go, means starting the timer).  The cells will follow the rules of the game and show their results on the screen.  The rules, as per this wikipedia article state :

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  1. Any live cell with fewer than two live neighbours dies, as if by loneliness.
  2. Any live cell with more than three live neighbours dies, as if by overcrowding.
  3. Any live cell with two or three live neighbours lives, unchanged, to the next generation.
  4. Any dead cell with exactly three live neighbours comes to life.

This example shows how to use some of the basic "native" graphics capabilities in Flex, how to extend a component to make your own, and a good example of the seperation of the business layer and the display layer (the model is baked into the business layer in this example because of its simplicity).

Check it out and let me know what you think!!

Advertisements

3 responses to “Conway’s Game of Life in Flex

  1. polygeek October 6, 2008 at 12:16 am

    Love this stuff. Can’t wait to see more.

  2. Pingback: Conway’s Game of Life coming to a Flex app near you. | polyGeek.com

  3. Pingback: Hidden Place Blog » Blog Archive » Game of life en AS3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: