Пример #1
0
 /// Iterates one time. Tries to spread viruses from poisoned computers.
 /// Returns true if all computers are poisoned.
 public static bool Iteration(Net net)
 {
     Net new_net = net;
     bool notAllPoisoned = true;
     for (int i = 0; i < net.Matrix.GetLength(0); ++i)
     {
         if (net.Comps[i].isPoisoned())
         {
             for (int j = 0; j < net.Matrix.GetLength(1); ++j)
             {
                 if (j == i)
                 {
                     continue;
                 }
                 if (net.Matrix[i, j])
                 {
                     if (!net.Comps[j].isPoisoned())
                     {
                         new_net.Comps[j].Poison(net.Comps[i].Virus);
                     }
                 }
             }
         }
         else
         {
             notAllPoisoned = false;
         }
     }
     net = new_net;
     return notAllPoisoned;
 }
Пример #2
0
 void newGame()
 {
     mNet = new Net(
         delegate(String s) { this.Text = s; return true; },
         new ControllerPlayer(win("Blue player win!")),
         new ControllerComp(win("Red player win!")),
         9, 3, 3, this.Width, this.Height);
 }
Пример #3
0
 public void OnSelectGameMode(int count, int lineCount, int blueCount, int redCount, bool firstComp, bool secondComp)
 {
     Wait = firstComp && secondComp;
     mNet = new Net.Net(
         delegate(String s) { return(true); },
         (firstComp ? (Controller) new ControllerComp(win("Blue player win!")) : new ControllerPlayer(win("Blue player win!"))),
         (secondComp ? (Controller) new ControllerComp(win("Red player win!")) : new ControllerPlayer(win("Red player win!"))),
         count, lineCount, blueCount, redCount, this.Width, this.Height);
 }
Пример #4
0
 /// Launches net poisoning process until all computers are not poisoned.
 public static ulong MainProcess(IReader reader, IViewer viewer)
 {
     var input = reader.ReadFromFile();
     var net = new Net(input.adjacencyMatrix, input.computers);
     ulong iteration = 0;
     while (!Logic.Iteration(net))
     {
         viewer.View(net, iteration++);
     }
     viewer.View(net, iteration++);
     return iteration;
 }
Пример #5
0
        void newGame()
        {
            mNet = null;
            Form2.Show();

/*			mNet = new Net.Net(
 *                              delegate (String s) { this.Text = s; return true; },
 *                              new ControllerPlayer(win("Blue player win!")),
 *                              new ControllerComp(win("Red player win!")),
 *                              9, 3, 3, this.Width, this.Height);*/
/*			mNet = new Net.Net(
 *                              delegate (String s) { this.Text = s; return true; },
 *                              new ControllerComp(win("Red player win!")),
 *                              new ControllerPlayer(win("Blue player win!")),
 *                              9, 3, 3, this.Width, this.Height);*/
        }
Пример #6
0
 public void View(Net net, ulong iteration)
 {
     Console.WriteLine("Iteration number {0}. Current Matrix:", iteration);
     for (int i = 0; i < net.Matrix.GetLength(0); ++i)
     {
         for (int j = 0; j < net.Matrix.GetLength(1); ++j)
         {
             Console.Write("{0} ", Convert.ToInt16(net.Matrix[i, j]));
         }
         Console.WriteLine();
     }
     Console.WriteLine("Current computers status:");
     foreach (var comp in net.Comps)
     {
         Console.WriteLine("Os - {0}, virus - {1}.", comp.Os.Name, comp.Virus.Name);
     }
     Console.WriteLine();
 }
Пример #7
0
 public void View(Net.Net net, ulong iteration)
 {
 }
Пример #8
0
 public void View(Net.Net net, ulong iteration)
 {
 }