private void Form1_Load(object sender, EventArgs e) { Lifeless life = new Lifeless(); Dead dead = new Dead(); int countOfDead = 0; while (countOfDead != 100) { for (int i = 0; i < Map.GetLength(0); i++) { for (int j = 0; j < Map.GetLength(1); j++) { if (Map[i, j] == dead.Dead) { MapTemp[i, j] = Map[i, j]; } if (Map[i, j] == life.Lifeless) { if (i > 0 && i < 99 && j > 0 && j < 99) { MiniMash[0, 0] = Map[i - 1, j - 1]; MiniMash[0, 1] = Map[i, j - 1]; MiniMash[0, 2] = Map[i + 1, j - 1]; MiniMash[1, 0] = Map[i - 1, j]; MiniMash[1, 1] = Map[i, j]; MiniMash[1, 2] = Map[i + 1, j]; MiniMash[2, 0] = Map[i - 1, j + 1]; MiniMash[2, 1] = Map[i, j + 1]; MiniMash[2, 2] = Map[i + 1, j + 1]; RewriteToSeconsArr.Checkking(MiniMash, ref MapTemp, i, j); } } } } Map = MapTemp; countOfDead++; } }
private void button1_Click(object sender, EventArgs e) { Lifeless life = new Lifeless(); Dead dead = new Dead(); for (int i = 0; i < Map.GetUpperBound(0) + 1; i++) { for (int j = 0; j < Map.GetUpperBound(0) + 1; j++) { Map[i, j] = dead.Dead; } } //We maked our map all dead if (comboBox1.AccessibilityObject.Value == "Rectangle") { DrawFigure(comboBox1.AccessibilityObject.Value); } if (comboBox1.AccessibilityObject.Value == "X") { DrawFigure(comboBox1.AccessibilityObject.Value); } if (comboBox1.AccessibilityObject.Value == "Plus") { DrawFigure(comboBox1.AccessibilityObject.Value); } //Later we can add new figures do { for (int i = 0; i < Map.GetUpperBound(0) + 1; i++) { for (int j = 0; j < Map.GetUpperBound(0) + 1; j++) { if (Map[i, j] == dead.Dead) { MapTemp[i, j] = Map[i, j]; } if (Map[i, j] == life.Lifeless) { if (i > 0 && i < 100 && j > 0 && j < 100) { MiniMash[0, 0] = Map[i - 1, j - 1]; MiniMash[0, 1] = Map[i, j - 1]; MiniMash[0, 2] = Map[i + 1, j - 1]; MiniMash[1, 0] = Map[i - 1, j]; MiniMash[1, 1] = Map[i, j]; MiniMash[1, 2] = Map[i + 1, j]; MiniMash[2, 0] = Map[i - 1, j + 1]; MiniMash[2, 1] = Map[i, j + 1]; MiniMash[2, 2] = Map[i + 1, j + 1]; RewriteToSeconsArr.Checkking(MiniMash, ref MapTemp, i, j); } } } } } while (true);//Условия на конец(все мертвое,все статическое,все повторяеться) }