예제 #1
0
        public IBestMoveResult BestMove(Board board, SearchConfig config, MoveTimer timer, CancellationToken cancelToken)
        {
            _config = config;
            _timer = timer;
            _numNodesQuiessenceSearched = 0;

            return BestMoveInternal(board, _config.DepthLimit, int.MinValue, int.MaxValue, cancelToken);
        }
예제 #2
0
        public IBestMoveResult BestMove(Board board, SearchConfig config, MoveTimer timer, CancellationToken cancelToken)
        {
            _config = config;
            _timer  = timer;
            _numNodesQuiessenceSearched = 0;

            return(BestMoveInternal(board, _config.DepthLimit, int.MinValue, int.MaxValue, cancelToken));
        }
예제 #3
0
        public IBestMoveResult BestMove(Board board, SearchConfig config, MoveTimer timer, CancellationToken cancelToken)
        {
            // initialize stats
            _config = config;
            _timer = timer;
            _nodesGeneratedByDepth = Enumerable.Range(1, _config.DepthLimit).ToDictionary(x => x, x => 0);
            _numNodesAtDepthLimit = 0;
            _numNodesQuiessenceSearched = 0;

            var result = BestMoveInternal(board, _config.DepthLimit, int.MinValue, int.MaxValue, cancelToken);

            // fill stats
            result.Config = _config;
            result.NumNodesAtDepthLimit = _numNodesAtDepthLimit;
            result.NodesGeneratedByDepth = _nodesGeneratedByDepth;
            result.NumNodesQuiessenceSearched = _numNodesQuiessenceSearched;
            result.TimedOut = _timedOut;

            return result;
        }
예제 #4
0
        public IBestMoveResult BestMove(Board board, SearchConfig config, MoveTimer timer, CancellationToken cancelToken)
        {
            // initialize stats
            _config = config;
            _timer  = timer;
            _nodesGeneratedByDepth      = Enumerable.Range(1, _config.DepthLimit).ToDictionary(x => x, x => 0);
            _numNodesAtDepthLimit       = 0;
            _numNodesQuiessenceSearched = 0;

            var result = BestMoveInternal(board, _config.DepthLimit, int.MinValue, int.MaxValue, cancelToken);

            // fill stats
            result.Config = _config;
            result.NumNodesAtDepthLimit       = _numNodesAtDepthLimit;
            result.NodesGeneratedByDepth      = _nodesGeneratedByDepth;
            result.NumNodesQuiessenceSearched = _numNodesQuiessenceSearched;
            result.TimedOut = _timedOut;

            return(result);
        }
예제 #5
0
        public IBestMoveResult BestMove(Board board, SearchConfig config, MoveTimer timer, CancellationToken cancelToken)
        {
            _timer       = timer;
            _cancelToken = cancelToken;

            if (_isWalledOff)
            {
                var longestPath = NextMoveOnLongestPath(board, board.PlayerToMove);
                return(new BestMoveResult(longestPath.Item1, longestPath.Item2));
            }
            else // otherwise fall back to alpha beta
            {
                var ab = new AlphaBeta().BestMove(board, config, timer, cancelToken);

                // but if alpha beta thinks we'll lose, do longest move
                if (ab.Score == int.MinValue)
                {
                    var longestPath = NextMoveOnLongestPath(board, board.PlayerToMove);
                    return(new BestMoveResult(longestPath.Item1, longestPath.Item2));
                }

                return(ab);
            }
        }
예제 #6
0
 public AsyncSearchTask(TimeSpan timeout)
 {
     CancelSource = new CancellationTokenSource();
     Timer        = new MoveTimer();
     Timer.SetTimeout(timeout);
 }
예제 #7
0
        public IBestMoveResult BestMove(Board board, SearchConfig config, MoveTimer timer, CancellationToken cancelToken)
        {
            _timer = timer;
            _cancelToken = cancelToken;

            if (_isWalledOff)
            {
                var longestPath = NextMoveOnLongestPath(board, board.PlayerToMove);
                return new BestMoveResult(longestPath.Item1, longestPath.Item2);
            }
            else // otherwise fall back to alpha beta
            {
                var ab = new AlphaBeta().BestMove(board, config, timer, cancelToken);

                // but if alpha beta thinks we'll lose, do longest move
                if (ab.Score == int.MinValue)
                {
                    var longestPath = NextMoveOnLongestPath(board, board.PlayerToMove);
                    return new BestMoveResult(longestPath.Item1, longestPath.Item2);
                }

                return ab;
            }
        }
예제 #8
0
 public AsyncSearchTask(TimeSpan timeout)
 {
     CancelSource = new CancellationTokenSource();
     Timer = new MoveTimer();
     Timer.SetTimeout(timeout);
 }