static void Main(string[] args) { // Set init values int length = 80; int steps = 29; int rule = 18; // Prepare array, set true in center bool[] cell = new bool[length]; cell[length / 2] = true; // Declare rule to generate RulesValidator.DeclareRule(rule); // Generate array and print it for (int i = 0; i < steps; i++) { for (int j = 0; j < cell.Length; j++) { Console.Write(cell[j] ? 'X' : ' '); } ; cell = RulesValidator.GenerateArray(cell); Console.WriteLine(); } Console.ReadLine(); }
public static bool[] GenerateArray(bool[] currentCell) { bool[] newCell = new bool[currentCell.Length]; for (int i = 0; i < currentCell.Length; i++) { for (int j = 0; j < RulesValidator.Rules.Length; j++) { bool[] rules = new bool[] { RulesValidator.GetPrevious(currentCell, i), currentCell[i], RulesValidator.GetNext(currentCell, i) }; if (RulesValidator.Rules[j].Validate(rules)) { newCell[i] = RulesValidator.Rules[j].GetValue(); break; } ; } ; } return(newCell); }