示例#1
0
        public SearchResult GetBestMove(IState state, SearchCancellationToken token)
        {
            var timer = Stopwatch.StartNew();

            evaluations = 0;
            cancel      = token;

            var best = MiniMaxAlphaBeta(state, 0, 2, int.MinValue, int.MaxValue);

            // Iterative deepening
            for (int i = 4; i < 100 && !cancel.Cancelled; i++)
            {
                var test = MiniMaxAlphaBeta(state, 0, i, int.MinValue, int.MaxValue);
                if (!test.Cancelled)
                {
                    best = test;
                }
            }

            return(new SearchResult
            {
                BestMove = best.Move,
                Milliseconds = timer.ElapsedMilliseconds,
                Evaluations = evaluations
            });
        }
示例#2
0
        public SearchResult GetBestMove(IState state, int depth)
        {
            var timer = Stopwatch.StartNew();

            evaluations = 0;
            cancel      = new SearchCancellationToken(() => false);

            var best = MiniMaxAlphaBeta(state, 0, depth, int.MinValue, int.MaxValue);

            return(new SearchResult
            {
                BestMove = best.Move,
                Milliseconds = timer.ElapsedMilliseconds,
                Evaluations = evaluations
            });
        }
示例#3
0
        public SearchResult GetBestMove(IState state, SearchCancellationToken token)
        {
            var timer = Stopwatch.StartNew();

            _visitedNodes = 0;

            cancel = token;

            var best = GetBestMove(state);

            return(new SearchResult
            {
                BestMove = best,
                Evaluations = _visitedNodes,
                Milliseconds = timer.ElapsedMilliseconds
            });
        }
示例#4
0
        public SearchResult GetBestMove(IState state, SearchCancellationToken token)
        {
            var timer = Stopwatch.StartNew();

            visitedNodes    = 0;
            simulationCount = 0;

            cancel = token;

            var best = GetBestMove(state);

            return(new SearchResult
            {
                BestMove = best,
                Evaluations = visitedNodes,
                Simulations = simulationCount,
                Milliseconds = timer.ElapsedMilliseconds,
                DebugStatus = debugStatus
            });
        }