/// <summary>
        ///     Initializes a new instance of the <see cref="EnginePlayerMoveSearcher"/> class
        ///     using the specified parameters.
        /// </summary>
        internal EnginePlayerMoveSearcher(
            [NotNull] ILogger logger,
            [NotNull] GameBoard rootBoard,
            int plyDepth,
            [NotNull] BoardHelper boardHelper,
            [CanBeNull] TranspositionTable transpositionTable,
            [CanBeNull] VariationLineCache previousIterationVariationLineCache,
            [NotNull] GameControlInfo gameControlInfo,
            bool useMultipleProcessors,
            [NotNull] MoveHistoryStatistics moveHistoryStatistics)
        {
            if (plyDepth < CommonEngineConstants.MaxPlyDepthLowerLimit)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(plyDepth),
                          plyDepth,
                          $@"The value must be at least {CommonEngineConstants.MaxPlyDepthLowerLimit}.");
            }

            _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
            _rootBoard          = rootBoard ?? throw new ArgumentNullException(nameof(rootBoard));
            _plyDepth           = plyDepth;
            _boardHelper        = boardHelper;
            _transpositionTable = transpositionTable;
            _previousIterationVariationLineCache = previousIterationVariationLineCache;
            _gameControlInfo       = gameControlInfo ?? throw new ArgumentNullException(nameof(gameControlInfo));
            _useMultipleProcessors = useMultipleProcessors;
            _moveHistoryStatistics = moveHistoryStatistics ?? throw new ArgumentNullException(nameof(moveHistoryStatistics));
            _evaluator             = new Evaluator(gameControlInfo, boardHelper);

            VariationLineCache = new VariationLineCache(rootBoard);
        }
Esempio n. 2
0
        public MultiTaskController(
            [NotNull] GameControlInfo gameControlInfo,
            int threadCount,
            [NotNull] ICollection <Func <TResult> > tasks)
        {
            if (threadCount <= 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(threadCount),
                          threadCount,
                          @"The value must be positive.");
            }

            if (tasks is null)
            {
                throw new ArgumentNullException(nameof(tasks));
            }

            if (tasks.Any(item => item is null))
            {
                throw new ArgumentException(@"The collection contains a null element.", nameof(tasks));
            }

            _syncLock        = new object();
            _gameControlInfo = gameControlInfo ?? throw new ArgumentNullException(nameof(gameControlInfo));
            _taskSlots       = tasks.Select(obj => new TaskSlot(obj)).ToArray();
            _threads         = Enumerable.Range(1, threadCount).Select(index => CreateThread(index, threadCount)).ToArray();
            _exceptions      = new List <Exception>();

            _state     = InternalState.Ready;
            _taskIndex = 0;
        }
Esempio n. 3
0
 internal Evaluator([NotNull] GameControlInfo gameControlInfo, [NotNull] BoardHelper boardHelper)
 {
     _gameControlInfo = gameControlInfo ?? throw new ArgumentNullException(nameof(gameControlInfo));
     _boardHelper     = boardHelper ?? throw new ArgumentNullException(nameof(boardHelper));
 }