示例#1
0
 public void EvaluateSiblings(World world)
 {
     var livingSiblings = 0;
     for (Int32 degree = 0; degree < 360; degree += 45)
     {
         var sibling = world.Sibling(X, Y, degree);
         if (sibling != null && sibling.Alive)
             livingSiblings++;
     }
     LivingSiblings = livingSiblings;
 }
示例#2
0
 static void Main(string[] args)
 {
     Console.SetWindowSize(80, 25);
     var world = new World(79, 24);
     for (Int32 x = 22; x < 30; x++ )
         world.Grid[x, 10].Alive = true;
     for (Int32 times = 0; times < 50; times++ )
     {
         world.Iterate();
         for (Int32 y = world.Grid.GetLowerBound(1); y < world.Grid.GetUpperBound(1); y++)
         {
             for (Int32 x = world.Grid.GetLowerBound(0); x < world.Grid.GetUpperBound(0); x++)
             {
                 Console.SetCursorPosition(x, y);
                 if (world.Grid[x, y].Alive)
                     Console.Write('■');
                 else
                     Console.Write(' ');
             }
         }
     }
 }