|

Download Life# (Life-Sharp) v1.0.Beta for .NET
Version 1.0.Beta of Life# is freeware.
Pre-requisites: .NET Framework
(v 1.1. or later, choose an appropriate download if you not already have .NET installed)
A Game of Life in C#
Just for the fun of it, I had to see how it would be to make a "Game of Life" in C#. It was pretty easy, but I
discovered that the board was too small, as I just used a matrix with a maximum of 3000 cells in each direction,
though "wrapping" around the borders. Increasing the matrix was not an option, as it didn't need much to cause a
memory overflow.
I then tried to use a combination of the Hashtable provided in the .NET Framework, and simple arrays instead of a
matrix, but it became painfully slow even with small patterns. Instead I invented my own hash table and improved the
algorithm a bit, which at least made it bearable.
The "board" now has a theoretical size of 4,611,686,018,427,390,000 cells with the x- and y-coordinates ranging
from -2,147,483,648 to +2,147,483,647. It will still "wrap" when exceeding values of those borders, because of the
internal handling of integer values in .NET, but it will most likely not be any problem... :-)
The "practical" size is depending on the capacity of your computer, but there is probably an issue of speed
whatever computer you run it on, which on my own machine becomes painfully slow when there are more than 10,000 live
cells. This is not depending on the size of the board, only the number of live cells.
To Load Patterns

Either click on the icon or select [Open
Pattern...] from the menu, and you'll get a File Dialog from where you can choose patterns with the suffixes *.lif
(Life 1.05 and Life 1.06) and *.rle (Run Length Encoded). It doesn't matter what suffix is actually used, as the
patterns are parsed depending on content rather than suffix (see Known Bugs below).

When the pattern is loaded, it appears with the pattern centered on the visual board.

You'll also notice the dotted lines (default blue), indicating where the origo of the pattern is (x = 0, y = 0).
You can hide those lines by unchecking the checkbox [Mark origo].
The dropdown lists

You can change the cell size in the range from 1 pixel to 10 pixels.
If the pattern includes more than one "Survival/Birth"-rule, you can also select between those. Otherwise the only
rule is the standard Conway rule of Survival = 2-3 adjacent live cells, Birth = 3 adjacent live cells.
The execution

You start the pattern by simply clicking on the button [Start].
You can also choose to step to the next generation with [Step].
The number of generations will be shown in the left label between the buttons.
The number of currently alive cells is shown in the right, green label.
Navigation
You can navigate in the universe with the buttons.

- Up-arrow = navigate north.
- Down-arrow = navigate south.
- Left-arrow = navigate west.
- Right-arrow = navigate east.
There are also six other navigational buttons in the upper toolbar, to make life more easy, especially after
changing the size of the cells or the size of the board itself.
 |
Places origo in the upper left corner. Can be useful for those patterns which doesn't start at negative x-
and y coordinates. |
 |
Places origo at the center of the visible board. |
 |
Places origo in the lower right corner. Can be useful for those patterns which start at negative x- and y
coordinates. |
 |
Places the pattern itself as far to the upper left corner as possible. I have encountered some patterns that
have used x- and y-coordinates that in my opinion have been ridiculously too far away from the origo. Note, this
only uses the coordinates of the cells at the starting position, so it will not follow all changes throughout the
life. |
 |
Places the pattern itself centered on the board. This is the default positioning of the pattern when loading
a new one. Note, this only uses the coordinates of the cells at the starting position, so it will not follow all
changes throughout the life. |
 |
Places the pattern itself as far to the lower right corner as possible. Note, this only uses the coordinates
of the cells at the starting position, so it will not follow all changes throughout the life. |
There's also an indicator showing where origo is in a distance from the upper left corner of the board.
Colors
For each cell you can configure different colors depending on have many generations it has survived, up to 9
generations. You can also choose colors for the board and the origo line.

You can also simplify it by choosing colors for all generations at the same time.
Note that for cells with a size less than 3 pixels, there will not be any border drawn.
Creating your own patterns
Yes, it's possible. Just click on the board to create a new pattern or to change a loaded one. This will not
affect the pattern file, from which the pattern has been loaded.
Either click on the icon or select [Save
Pattern...] from the menu, and you'll be given the possibility to save the current pattern on the board. At the
moment it will only be saved in "Life 1.06" format.
Work in progress and known bugs
These are the things I will work on in the future:
- Increasing the speed for large patterns
- Better parsing of pattern-files (e.g. complex RLE-files), including support for more formats (e.g. MCell,
bitmap images, etc.)
- Remove "flickering" on the screen
- Possibility to save patterns in multiple formats.
There's a significant decrease in performance as the number of live cells increases. I still struggle to come up a
more efficient algorithm to make it fast even with many alive cells. On my own machine it becomes painfully slow when
the number of live cells is more than 10,000 cells. At the moment I'm looking into making a more "native" hash table
in unmanaged C++ which I believe would be more efficient than a pure .NET hash table.
Only to some extent the file suffixes are connected to the actual format. I've discovered that many .lif-files
being around really contains RLE-code, so I have tried to ignore the suffixes and load the patterns from content
instead. Valid patterns at the moment are:
- Life 1.05 (dots and asterixes, should start with "#Life 1.05")
- Life 1.06 (coordinate pairs, should start with "#Life 1.06")
- Run Length Encoded (b's and o's, usually starts with the coordinates "x = ..., y = ...")
Note that some RLE's won't be parsed correctly, especially those with more than one block.
There is also an annoying "flickering" on the screen, as the whole board is redrawn for each new generation.
After dealing with those immediate problems, I will make it possible to select different speeds, as very small
patterns runs a bit too fast at the moment, so it's hard to see what's happening....
As the board only deals with live cells and their neighbor cells, there cannot be a "birth rule" of 0, as "dead"
cells with no live neighbors never will be investigated for birth. This "problem" I will probably not even try to
deal with, as it's not even a reasonable rule...
|