Ejemplo n.º 1
0
 public static void Gaming()
 {
     Logs.AddToLog("Game #" + GamesCount + ". " + firstPlayerFile + "(White) versus " + secondPlayerFile + "(Black). Let the battle begin!");
     var movesCount = 0;
     var white = new MyRemotePlayer(firstPlayerFile, Color.White);
     var black = new MyRemotePlayer(secondPlayerFile, Color.Black);
     var validator = new Validator();
     var field = new Game().CreateMap();
     while (true)
     {
         movesCount++;
         if (movesCount > 150)
         {
             Logs.AddToLog("i'm done. it's a draw");
             if (GamesCount != BestOf)
             {
                 GamesCount++;
                 var thr = new Thread(Gaming);
                 thr.Start();
                 Thread.CurrentThread.Abort();
             }
             else
             {
                 Environment.Exit(0);
                 Logs.Done();
             }
         }
         if (usingTimer && movesCount > 1)
         {
             time.Reset();
             time.Start();
         }
         validator.IsCorrectMove(white.MakeTurn(field), field, Color.White);
         if (usingTimer && movesCount > 1)
         {
             time.Stop();
             var ms = time.Elapsed.Milliseconds;
             Logs.AddToLog(ms.ToString());
             MaxWhite = Math.Max(MaxWhite, ms);
         }
         if (usingForm)
         {
             Window.BeginInvoke(new Action<Checker[,]>(Window.Update), new object[] { field });
             Thread.Sleep(TimeOutOfMove);
         }
         if (usingTimer && movesCount > 1)
         {
             time.Reset();
             time.Start();
         }
         validator.IsCorrectMove(black.MakeTurn(field), field, Color.Black);
         if (usingTimer && movesCount > 1)
         {
             time.Stop();
             var ms = time.Elapsed.Milliseconds;
             Logs.AddToLog(ms.ToString());
             MaxBlack = Math.Max(MaxBlack, ms);
         }
         if (usingForm)
         {
             Window.BeginInvoke(new Action<Checker[,]>(Window.Update), new object[] { field });
             Thread.Sleep(TimeOutOfMove);
         }
     }
 }
Ejemplo n.º 2
0
 public void SomeStrange3()
 {
     var field = GetMapFrom("Tests92.txt");
     var validator = new Validator();
     var moves = new List<Move>();
     moves.Add(new Move(new Point(0, 7), new Point(7, 0)));
     validator.IsCorrectMove(moves, field, Color.Black);
     var newField = GetMapFrom("Tests93.txt");
     Assert.AreEqual(Serializer.FieldToString(newField), Serializer.FieldToString(field));
 }
Ejemplo n.º 3
0
 void Test(List<Move> moves, Color color, bool answer, string mapname)
 {
     var validator = new Validator();
     var field = GetMapFrom(mapname);
     if (!answer)
         try
         {
             validator.IsCorrectMove(moves, field, color);
             Assert.Fail();
         }
         catch (NotImplementedException) { }
     else
         validator.IsCorrectMove(moves, field, color);
 }
Ejemplo n.º 4
0
 public void SomeStrange()
 {
     var field = GetMapFrom("Tests88.txt");
     var validator = new Validator();
     var moves = new List<Move>();
     moves.Add(new Move(new Point(0, 7), new Point(7, 0))); // дамка просто делает привязный ход и рубит другую дамку
     validator.IsCorrectMove(moves, field, Color.Black); //твой забаганный валидатор получает этот ход, поле и все такое.
     var newField = GetMapFrom("Tests89.txt"); //беру карту которая должна быть после хода (с дамкой)
     Assert.AreEqual(Serializer.FieldToString(newField), Serializer.FieldToString(field)); //обнаруживаю, что дамки ниха нет :С
 }