Automata
This is where I keep a collection of the automata that I have explored. I find much of the work done in this area fascinating. I'm also very intrigued by Stephen Wolfram's A New Kind of Science.
To assist myself, I created a simple drawing library that can print a 2-dimensional array. The accepted array input has type integer and a delegate function is used to translate the integer into a color for the square. Reading the code explains it best.
// Author: Grant Jenks // File: Draw.cs // Build: csc.exe /out:Automata.Draw.dll /target:library Draw.cs // Copyright 2009 using System; using System.Drawing; using System.Drawing.Imaging; namespace Automata { public static class Draw { public delegate Color Viewer ( int i ); public static void Write ( string fileName, int sideCount, int squareSize, int[,] input, Viewer viewer ) { // Calculate the length of the image's side (in pixels). int imageSideLength = sideCount * squareSize; // Create a new image and initialize it by drawing a white rectangle. Image image = new Bitmap(imageSideLength, imageSideLength); Graphics g = Graphics.FromImage(image); g.FillRectangle(Brushes.White, 0, 0, imageSideLength, imageSideLength); // Print text to track progress while generating the image. Console.WriteLine("Generating Image"); Console.WriteLine("0% |==========| 100%"); Console.Write("0% |"); // Initialize variables used to track progress while generating the // image. long total = (sideCount * sideCount); long current = 0; long oldPercentage = 0; // Iterate over all the rows and columns in the input. for (int i = 0; i < input.GetLength(0); i++) { for (int j = 0; j < input.GetLength(1); j++) { // Draw a rectangle corresponding to the 2-D array position. // This calls the supplied Automata.Draw.Viewer function to // get the color for the square. g.FillRectangle(new SolidBrush(viewer(input[i,j])), j * squareSize, imageSideLength - (i * squareSize) - squareSize, squareSize, squareSize); // Do accounting to track progress. current++; long newPercentage = (current * 100) / total; if (oldPercentage + 10 == newPercentage) { oldPercentage = newPercentage; Console.Write("="); } } } Console.Write("| 100%"); // Save the image to disk. image.Save(fileName, ImageFormat.Jpeg); } } }