//a straightforward implementation of the alpha-beta search, using iterative deepening search
        public MoveResult AlphaBeta(CheckersBoard game, ref int maxDepth)
        {
            var iterativeDepth = _lastSuccessfulDepth;
            const int alpha = NegativeInfinity;
            const int beta = PositiveInfinity;

            int totalNodesGenerated = 0, totalMaxPrunes = 0, totalMinPrunes = 0;

            //limits itself to the difficulty level's max depth
            AlphaBetaReturnValue lastCompletedMove = null;
            while (iterativeDepth <= (int)_difficultyLevel)
            {
                ResetCounts();

                maxDepth = 0;
                var currentDepth = 0;
                var copy = game.Clone();

                var v = MaxValue(copy, alpha, beta, Color, ref currentDepth, ref maxDepth, iterativeDepth);

                if (v != null)
                {
                    lastCompletedMove = v;

                    Console.WriteLine(
                        "\tSearch at depth {0} completed. Optimal move found with value {1}; time to find move: {2}.\n" +
                        "\tNodes generated: {3}, max prunes: {4}, min prunes: {5}.\n",
                        maxDepth, lastCompletedMove.Value, DateTime.Now - AlphaBetaStartTime,
                        NodesGenerated, NumberOfMaxPrunes, NumberOfMinPrunes);

                    //keeps a running total of the total stats for the IDS
                    totalNodesGenerated += NodesGenerated;
                    totalMaxPrunes += NumberOfMaxPrunes;
                    totalMinPrunes += NumberOfMinPrunes;
                }
                else break;

                if (maxDepth == 0 || !_depthCutoffHit || iterativeDepth == (int)_difficultyLevel)
                    break;

                if(iterativeDepth != (int)_difficultyLevel)
                    iterativeDepth++;
            }

            _lastSuccessfulDepth = iterativeDepth;

            Console.WriteLine(
                "IDS ended. Optimal move found with value {0}; IDS stopped at depth {1}; time to find move: {2}.\n" +
                "Total completed IDS stats: \n\tNodes generated: {3}. \n\tMax prunes: {4}. \n\tMin prunes: {5}.\n",
                lastCompletedMove.Value, iterativeDepth, DateTime.Now - AlphaBetaStartTime,
                totalNodesGenerated, totalMaxPrunes, totalMinPrunes);
            return lastCompletedMove.Move;
        }