private static void SetSecondTreeValues(SecondGameTree gameTree)
 {
     if (gameTree.list.Count > 0)
     {
         foreach (GameTree newGameTree in gameTree.list)
         {
             SetRestTreeValues(newGameTree, 2);
         }
         int min = 100;
         foreach (GameTree newGameTree in gameTree.list)
         {
             if (newGameTree.value < min)
                 min = newGameTree.value;
         }
         gameTree.value = min;
     }
 }
 public static void FirstGameCalculation(FirstGameTree gameTree)
 {
     sbyte row, col;
     if (CheckerPiece.CanAWhitePieceEatOnTheBoard(gameTree.board, out row, out col))
     {
         for (; row < 8; row++)
             for (; col < 8; col++)
                 if (CheckerPiece.CanAWhitePieceEat(gameTree.board, ref row, ref col))
                 {
                     List<sbyte[,]> list = new List<sbyte[,]>();
                     CheckerPiece.Eat(row, col, gameTree.board, list);
                     foreach (sbyte[,] board in list)
                     {
                         SecondGameTree newGameTree = new SecondGameTree(board);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                 }
     }
     else
     {
         for (sbyte i = 0; i < 8; i++)
             for (sbyte j = 0; j < 8; j++)
             {
                 if (gameTree.board[i, j] == 1)
                 {
                     if (CheckerPiece.CanPlus1MoveUpRight(gameTree.board, i, j))
                     {
                         sbyte[,] newBoard = Program.CopyBoard(gameTree.board);
                         CheckerPiece.MovePlus1UpRight(newBoard, i, j);
                         SecondGameTree newGameTree = new SecondGameTree(newBoard);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                     if (CheckerPiece.CanPlus1MoveUpLeft(gameTree.board, i, j))
                     {
                         sbyte[,] newBoard = Program.CopyBoard(gameTree.board);
                         CheckerPiece.MovePlus1UpLeft(newBoard, i, j);
                         SecondGameTree newGameTree = new SecondGameTree(newBoard);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                 }
                 else if (gameTree.board[i, j] == 2)
                 {
                     int amountOfMoves1 = CheckerPiece.AmoutOfPlus2UpRightMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves1; k++)
                     {
                         sbyte[,] newBoard = Program.CopyBoard(gameTree.board);
                         newBoard[i, j] = 0;
                         newBoard[i + k + 1, j - k - 1] = 2;
                         SecondGameTree newGameTree = new SecondGameTree(newBoard);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                     int amountOfMoves2 = CheckerPiece.AmoutOfPlus2UpLeftMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves2; k++)
                     {
                         sbyte[,] newBoard = Program.CopyBoard(gameTree.board);
                         newBoard[i, j] = 0;
                         newBoard[i + k + 1, j + k + 1] = 2;
                         SecondGameTree newGameTree = new SecondGameTree(newBoard);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                     int amountOfMoves3 = CheckerPiece.AmoutOfPlus2DownRightMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves3; k++)
                     {
                         sbyte[,] newBoard = Program.CopyBoard(gameTree.board);
                         newBoard[i, j] = 0;
                         newBoard[i - k - 1, j + k + 1] = 2;
                         SecondGameTree newGameTree = new SecondGameTree(newBoard);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                     int amountOfMoves4 = CheckerPiece.AmoutOfPlus2DownLeftMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves4; k++)
                     {
                         sbyte[,] newBoard = Program.CopyBoard(gameTree.board);
                         newBoard[i, j] = 0;
                         newBoard[i - k - 1, j - k - 1] = 2;
                         SecondGameTree newGameTree = new SecondGameTree(newBoard);
                         newGameTree.value = Program.CalculateAdvantage(gameTree.board);
                         gameTree.list.Add(newGameTree);
                         SecondGameCalculation(newGameTree);
                     }
                 }
             }
     }
 }
 private static void SecondGameCalculation(SecondGameTree gameTree)
 {
     sbyte row, col;
     if (CheckerPiece.CanABlackPieceEatOnTheBoard(gameTree.board, out row, out col))
     {
         for (; row < 8; row++)
             for (; col < 8; col++)
             {
                 if (gameTree.board[row, col] == -1)
                 {
                     List<sbyte[,]> list = new List<sbyte[,]>();
                     CheckerPiece.Eat(row, col, gameTree.board, list);
                     foreach (sbyte[,] board in list)
                     {
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, board, 2);
                     }
                 }
                 else if (gameTree.board[row, col] == -2)
                 {
                     List<sbyte[,]> list = new List<sbyte[,]>();
                     CheckerPiece.Eat(row, col, gameTree.board, list);
                     foreach (sbyte[,] board in list)
                     {
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, board, 2);
                     }
                 }
             }
     }
     else
     {
         for (sbyte i = 0; i < 8; i++)
             for (sbyte j = 0; j < 8; j++)
             {
                 if (gameTree.board[i, j] == -1)
                 {
                     if (CheckerPiece.CanMinus1MoveUpRight(gameTree.board, i, j))
                     {
                         CheckerPiece.MoveMinus1UpRight(gameTree.board, i, j);
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(gameTree.board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, gameTree.board, 2);
                         CheckerPiece.UndoMoveMinus1UpRight(gameTree.board, i, j);
                     }
                     if (CheckerPiece.CanMinus1MoveUpLeft(gameTree.board, i, j))
                     {
                         CheckerPiece.MoveMinus1UpLeft(gameTree.board, i, j);
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(gameTree.board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, gameTree.board, 2);
                         CheckerPiece.UndoMoveMinus1UpLeft(gameTree.board, i, j);
                     }
                 }
                 else if (gameTree.board[i, j] == -2)
                 {
                     int amountOfMoves1 = CheckerPiece.AmoutOfMinus2UpRightMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves1; k++)
                     {
                         gameTree.board[i, j] = 0;
                         gameTree.board[i - k - 1, j + k + 1] = -2;
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(gameTree.board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, gameTree.board, 2);
                         gameTree.board[i, j] = -2;
                         gameTree.board[i - k - 1, j + k + 1] = 0;
                     }
                     int amountOfMoves2 = CheckerPiece.AmoutOfMinus2UpLeftMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves2; k++)
                     {
                         gameTree.board[i, j] = 0;
                         gameTree.board[i - k - 1, j - k - 1] = -2;
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(gameTree.board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, gameTree.board, 2);
                         gameTree.board[i, j] = -2;
                         gameTree.board[i - k - 1, j - k - 1] = 0;
                     }
                     int amountOfMoves3 = CheckerPiece.AmoutOfMinus2DownRightMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves3; k++)
                     {
                         gameTree.board[i, j] = 0;
                         gameTree.board[i + k + 1, j - k - 1] = -2;
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(gameTree.board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, gameTree.board, 2);
                         gameTree.board[i, j] = -2;
                         gameTree.board[i + k + 1, j - k - 1] = 0;
                     }
                     int amountOfMoves4 = CheckerPiece.AmoutOfMinus2DownLeftMoves(gameTree.board, i, j);
                     for (int k = 0; k < amountOfMoves4; k++)
                     {
                         gameTree.board[i, j] = 0;
                         gameTree.board[i + k + 1, j + k + 1] = -2;
                         GameTree newGameTree = new GameTree(Program.CalculateAdvantage(gameTree.board));
                         gameTree.list.Add(newGameTree);
                         GameCalculation(newGameTree, gameTree.board, 2);
                         gameTree.board[i, j] = -2;
                         gameTree.board[i + k + 1, j + k + 1] = 0;
                     }
                 }
             }
     }
 }