Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 6
0
 public AsyncSearchTask(TimeSpan timeout)
 {
     CancelSource = new CancellationTokenSource();
     Timer        = new MoveTimer();
     Timer.SetTimeout(timeout);
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 8
0
 public AsyncSearchTask(TimeSpan timeout)
 {
     CancelSource = new CancellationTokenSource();
     Timer = new MoveTimer();
     Timer.SetTimeout(timeout);
 }