/// <summary>
        /// The Euclidean or Stein algorithm calculates the greatest common divisor of any natural numbers.
        /// </summary>
        /// <param name="algorithm">Name for algorithm</param>
        /// <param name="numbInts">Array of natural numbers</param>
        /// <returns>Greatest common divisor of any natural numbers</returns>
        private int CommonAlgorithm(IAlgorithm algorithm, params int[] numbInts)
        {
            int boof = algorithm.Algorithm(numbInts[0], numbInts[1]);

            for (int i = 2; i <= numbInts.Length - 1; i++)
            {
                boof = algorithm.Algorithm(boof, numbInts[i]);
            }
            return(boof);
        }
        /// <summary>
        /// Time execution function
        /// </summary>
        /// <param name="algorithm">Interface for algorithm</param>
        /// <param name="a">First number</param>
        /// <param name="b">Second number</param>
        /// <returns>Time execution</returns>

        public string ExecutionTimeOfAlgorithm(IAlgorithm algorithm, int a, int b)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            algorithm.Algorithm(a, b);
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            return($"{ts.Hours:00}:{ts.Minutes:00}:{ts.Seconds:00}.{ts.Milliseconds / 10:00}");
        }
Beispiel #3
0
        private void ComputerMove()
        {
            string computerSymbol;
            string playerSymbol;

            if (firstPlayerIsAComputer)
            {
                computerSymbol = GameField.FirstPlayerSymbol;
                playerSymbol   = GameField.SecondPlayerSymbol;
            }
            else
            {
                computerSymbol = GameField.SecondPlayerSymbol;
                playerSymbol   = GameField.FirstPlayerSymbol;
            }

            var moveCoordinate = Algorithm.Algorithm(GetGameField, level, playUntil, computerSymbol, playerSymbol);

            MakeMove(moveCoordinate.Item1, moveCoordinate.Item2);
        }
 public (int, int) CheckForBreakingTheOpponentSequence(IAlgorithm algorithm, string[,] gameField, int maxDeph, int playUntil)
 {
     return(algorithm.Algorithm(gameField, maxDeph, playUntil, computerGameSymbol, playerGameSymbol));
 }